This is my first post to Stack so please let me know if I haven't posted enough information. I have however, looked through many of the other answered questions and tried many of those solutions which as a result have ended me here.
I am having trouble getting the data out of a series of around 800 xml files. I would like the following data frame.
Model Species PubChemID out of "rdf:li*
Abiotrophia_defectiva_ATCC_49176 M_10fthf__91__c__93__ 122347
Abiotrophia_defectiva_ATCC_49176 M_10m3hddcaACP__91__c__93__ N/A
I can clean the rest of the URL out after its in a data frame for the PubChemID
From the following xml example.
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level3/version1/core" xmlns:fbc="http://www.sbml.org/sbml/level3/version1/fbc/version2" xmlns:groups="http://www.sbml.org/sbml/level3/version1/groups/version1" level="3" version="1" fbc:required="false" groups:required="false">
<model metaid="Abiotrophia_defectiva_ATCC_49176" id="Abiotrophia_defectiva_ATCC_49176" name="Abiotrophia defectiva ATCC 49176" fbc:strict="true">
<notes>
<body xmlns="http://www.w3.org/1999/xhtml">
<div>
<h1>Abiotrophia_defectiva_ATCC_49176</h1>
<h2>Description</h2>
<p>This is a metabolism reconstruction of Abiotrophia defectiva ATCC 49176</p>1.03<p>Authors: Stefania Magnusdottir, Almut Heinken, Laura Kutt, Dmitry A. Ravcheev, Eugen Bauer, Alberto Noronha, Kacy Greenhalgh, Christian Jaeger, Joanna Baginska, Paul Wilmes, Ronan M.T. Fleming, and Ines Thiele.</p>
<h3>Draft information</h3>
<p>
<ul>
<li> PubSEED ID: Abiotrophia defectiva ATCC 49176 (592010.4)</li>
<li> Draft reconstruction ID: Seed592010_4_124632</li>
<li> Draft platform: ModelSEED</li>
<li> Draft created: 7/1/2014</li>
</ul>
</p>
<p>This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.</p>
<p>When using this model in your research works, please cite: Magnusdottir et al., Generation of genome-scale metabolic reconstructions for 773 members of the human gut microbiota, Nat Biotechnol, 2016.</p></div>
</body>
</notes>
<annotation>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#" xmlns:vCard4="http://www.w3.org/2006/vcard/ns#" xmlns:bqbiol="http://biomodels.net/biology-qualifiers/" xmlns:bqmodel="http://biomodels.net/model-qualifiers/">
<rdf:Description rdf:about="#Abiotrophia_defectiva_ATCC_49176">
<bqbiol:is>
<rdf:Bag>
<rdf:li rdf:resource="http://identifiers.org/taxonomy/592010"/>
</rdf:Bag>
</bqbiol:is>
</rdf:Description>
</rdf:RDF>
</annotation>
<listOfUnitDefinitions>
<unitDefinition id="mmol_per_gDW_per_hr">
<listOfUnits>
<unit kind="mole" exponent="1" scale="-3" multiplier="1"/>
<unit kind="gram" exponent="-1" scale="0" multiplier="1"/>
<unit kind="second" exponent="-1" scale="0" multiplier="3600"/>
</listOfUnits>
</unitDefinition>
</listOfUnitDefinitions>
<listOfCompartments>
<compartment metaid="c" id="c" name="Cytoplasm" constant="false"/>
<compartment metaid="e" id="e" name="Extracellular" constant="false"/>
</listOfCompartments>
<listOfSpecies>
<species metaid="M_10fthf__91__c__93__" id="M_10fthf__91__c__93__" name="10-Formyltetrahydrofolate" compartment="c" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false" fbc:charge="-2" fbc:chemicalFormula="C20H21N7O7">
<annotation xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#" xmlns:vCard4="http://www.w3.org/2006/vcard/ns#" xmlns:bqbiol="http://biomodels.net/biology-qualifiers/" xmlns:bqmodel="http://biomodels.net/model-qualifiers/">
<rdf:Description rdf:about="#M_10fthf__91__c__93__">
<bqbiol:is>
<rdf:Bag>
<rdf:li rdf:resource="http://identifiers.org/hmdb/HMDB00972"/>
<rdf:li rdf:resource="http://identifiers.org/kegg.compound/C00234"/>
<rdf:li rdf:resource="http://identifiers.org/pubchem.compound/122347"/>
</rdf:Bag>
</bqbiol:is>
</rdf:Description>
</rdf:RDF>
</annotation>
</species>
<species metaid="M_10m3hddcaACP__91__c__93__" id="M_10m3hddcaACP__91__c__93__" name="10-methyl-3-hydroxy-dodecanoyl-ACP" compartment="c" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false" fbc:charge="-1" fbc:chemicalFormula="C24H45N2O9PRS"/>
<species metaid="M_10m3hundecACP__91__c__93__" id="M_10m3hundecACP__91__c__93__" name="10-methyl-3-hydroxy-undecanoyl-ACP" compartment="c" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false" fbc:charge="-1" fbc:chemicalFormula="C23H43N2O9PRS"/>
<species metaid="M_10m3oddcaACP__91__c__93__" id="M_10m3oddcaACP__91__c__93__" name="10-methyl-3-oxo-dodecanoyl-ACP" compartment="c" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false" fbc:charge="-1" fbc:chemicalFormula="C24H43N2O9PRS"/>
</listOfSpecies>
</model>
</sbml>
I have been successful in converting to a list in r and calling the first element that should apply to the other 800 xml
library(xml2)
list <- xmlToList("StackExample.xml")
list[["model"]][["notes"]][["body"]][["div"]][["h1"]]
I also can get all of the species out but the fact that some of the nodes contain more hierarchy has got me a bit baffled.
species.list <- list$model$listOfSpecies
specieslist <- lapply(species.list, '[[', 1)
How does one add an if/else type function into "lapply" so that it looks for "/rdf:resources" in the additional hierarchy?
Lastly, I am pretty sure that applying whatever script to the remainder of the files should be doable.
Thanks
Related
I am trying to replace text node with element if document matches that text, below query I have tried but it is giving error "Target is not an element, text, attribute, comment or pi" below is my query.
inputXML:
<book>
<p>Isn't it lovely here? Very smart. We'll be like three queens when you've finished with us,
Edie. You doing well then?</p>
<p>
<name type="person">April De Angelis</name>’ plays include <title type="work">Positive
Hour</title> (Out of Joint) <title type="work">Playhouse Creatures</title> (<name
type="org">Sphinx Theatre Company</name>), <title type="work">Hush</title> (<name
type="org">Royal Court</name>), <title type="work">Soft Vengeance</title>, <title
type="work">The Life and Times of Fanny Hill</title> (adapted from the <name type="org"
>John Cleland novel</name>) and <title type="work">Ironmistress</title>. Her work for
radio includes <title>The Outlander</title> (<name type="org">Radio 5</name>), which won the
<name type="org">Writers’ Guild Award</name> (<date>1992</date>), and, for opera, <title
type="work">Flight</title> with composer <name type="person">Jonathan Dove</name> (<name
type="place">Glyndebourne</name>, <date>1998</date>).</p>
</book>
Expected output:
<book>
<p>Isn't it lovely here? Very smart. We'll be like three <highlight>>queens</highlight> when
you've finished with us, Edie. You doing well then?</p>
<p>
<name type="person">April De Angelis</name>’ plays <highlight>include</highlight>
<title type="work">Positive Hour</title> (Out of Joint) <title type="work">Playhouse
Creatures</title> (<name type="org">Sphinx Theatre Company</name>), <title type="work"
>Hush</title> (<name type="org">Royal Court</name>), <title type="work">Soft
Vengeance</title>, <title type="work">The Life and Times of Fanny Hill</title> (adapted
from the <name type="org">John Cleland novel</name>) and <title type="work"
>Ironmistress</title>. Her work for radio includes <title>The Outlander</title> (<name
type="org">Radio 5</name>), which won the <name type="org">Writers’ Guild Award</name>
(<date>1992</date>), and, for opera, <title type="work">Flight</title> with composer
<name type="person">Jonathan Dove</name> (<name type="place">Glyndebourne</name>,
<date>1998</date>).</p>
</book>
I am using BaseX version 9.5.1 below is the code.
let $body := <indexedterms>
<content>
<terms>
<term>include</term>
<term>Queens</term>
</terms>
<uri>/IEEE/IEEE/test.xml</uri>
</content>
</indexedterms>
for $contents in $body/content
let $uri := $contents/uri
let $doc := fn:doc($uri)
for $selectedterm in $contents/terms/term/string()
let $Modifieddoc := copy $c := $doc
modify
(
for $nodes in $c//*//text()[fn:matches(.,$selectedterm)]/parent::*
return
if($nodes/node()[fn:matches(.,$selectedterm)]/parent::*:highlight)
then ()
else
replace node $nodes/$selectedterm with <highlight>{$selectedterm}</highlight>
)
return $c
return
db:replace('IEEE',substring-after($uri,'/IEEE'),$Modifieddoc)
Previously I was using the "replace node $nodes/node()[fn:contains(.,$selectedterm)] with {$selectedterm} " instead of "replace node $nodes/$selectedterm with {$selectedterm}" it was doing the work but where terms like steam e.g.(include, includes) so it was matching the both words which is not correct so I have changed the code to "replace node "$nodes/$selectedterm with {$selectedterm}"
$nodes/$selectedterm is probably the culprit and most likely not what you want as the $selectedterm variable is a sequence of string values (you bind for $selectedterm in $contents/terms/term/string()). It might help us understand what you want to achieve if you show us a sample document you load with the doc function and the update you want to do on that with BaseX, for instance, for the two sample terms you have shown in your code snippet.
Your task of identifying and wrapping search terms in your text contents can be done nicely in XSLT 3 or 3 which you can run with BaseX if you put Saxon 9.9 or 10 or 11 on the class path:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="3.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
exclude-result-prefixes="#all"
expand-text="yes">
<xsl:param name="terms" as="xs:string*" select="'include', 'Queens'"/>
<xsl:output method="xml" indent="no"/>
<xsl:template match="p//text()">
<xsl:apply-templates select="analyze-string(., string-join($terms, '|'), 'i')/node()"/>
</xsl:template>
<xsl:template match="fn:match">
<highlight>{.}</highlight>
</xsl:template>
<xsl:template match="fn:non-match">
<xsl:apply-templates/>
</xsl:template>
<xsl:mode on-no-match="shallow-copy"/>
</xsl:stylesheet>
As the used analyze-string function exists also in BaseX/XQuery you should also be able to use XQuery update on the result calling that function, i.e. by replacing fn:match elements with highlight elements.
I have two images in my xml:
<?xml version="1.0" encoding="UTF-8"?>
<description>
<title>Letter from Waldemar Schultze to Jennie Schultze</title>
<creator type="author">
<name type="personal">Schultze, Waldemar</name>
</creator>
<date>1943-06-30</date>
<source>Special Collections and University Archives, W. E. B. Du Bois Library,
University of Massachusetts Amherst.</source>
<citation>Robert and Waldemar Schultze Papers (MS 528). Special Collections and
University Archives, W.E.B. Du Bois Library, University of
Massachusetts Amherst.</citation>
</description>
<text>
<header type="letterhead">
<imageGroup>
<image xlink:href="mums528-i001-001.png"/>
<caption>page 1</caption>
</imageGroup>
<imageGroup>
<image xlink:href="mums528-i001-002.png"/>
<caption>page 2</caption>
</imageGroup>
<organization>Unites States Disciplinary Barracks</organization>
<location>Fort Leavenworth, Kansas</location>
<date format="M/DD/YY">6/30/43</date>
<recipient>
<name type="personal">Mrs. W.J. Schultze</name>
<address>875 Richmond Av., Buffalo, N.Y.</address>
<relation>Mother</relation>
</recipient>
</header>
<body>
<salutation>Dear Mother,</salutation>
<p><line>This is the first letter I have had</line>
<line>an opportunity to write you since leaving Fort</line>
<line>Jay, and I know you must be anxious to hear from me.</line></p>
<p><line>Bob and I are both feeling as well as</line>
<line>can be expected considering our present cir-</line>
<line>cumstances. We both have high blood</line>
<line>pressure, mine has been 160/100 for the past</line>
<line>2 days, and Bob's 158/96, but my sinus</line>
<line>infection has not caused me quite so much</line>
<line>trouble since leaving N.Y. State. I believe</line>
<line>the air is dryer here and is responsible</line>
<line>for any alleviation that has taken place.</line></p>
<p><line>While a prisoner here remains in their</line>
<line>so-called 1st grade, he is able to write</line>
<line>twice a week, in second grade once a week,</line>
<line>and in third grade once a month. These</line>
<line>grades refer to classifications that ostensibly</line>
<line>are for conduct while here. It is quite possible</line>
<line>to lose a conduct rating, as I understand it,</line>
<line>by not having a perpetually rusting tin cup polished</line>
<pb n="2"/>
<line>brightly for daily inspection, although the tin plating long ago dis-</line>
<line>appeared and the cup is rusty again within 2 hours after wetting.</line></p>
<p><line>The food here is good and is well-cooked,</line>
<line>with one exception, the gravy, which is nothing but</line>
<line>flour, water, and bacon grease, Strangely enough, how-</line>
<line>ever, no condiments, not even salt, are provided on</line>
<line>the table, to the detriment of otherwise very good</line>
<line>meals. While meat here is unrationed and is plentiful,</line>
<line>toilet paper; believe it or not, is rationed. A</line>
<line>5¢ roll must last a prisoner 45 days, or else -- ?</line>
<line>Perhaps, however, a prisoner can purchase additional</line>
<line>if it should be necessary.</line></p>
<p><line>Please see that my subscriptions are transferred</line>
<line>here as soon as possible from Fort Jay. Give Florence</line>
<line>and Helen my regards, and thank Joe for his</line>
<line>efforts in my behalf in managing my business.</line>
<line>Find out from Joe how tube deliveries are at the</line>
<line>present time, first to satisfy my curiosity; and</line>
<line>also let me know if you are receiving your</line>
<line>remittance regularly from him. If he is not</line>
<line>taking care of your support in accordance with</line>
<line>the instructions I left him, I wish to know it,</line>
<line>so I can write, and correct the matter.</line>
<line>You can tell Joe to subscribe to Electronics</line>
<line>magazine for me and send it to this address</line>
<line>direct from the publisher. He should also have a copy</line>
<line>of Palmer's "Calculus for Home Study," sent me by the publisher,</line>
<line>whose name he can obtain from Ulbrichs. In future letters I'll</line>
<line>copy the "Prisoner's Handbook" issued here, and the</line>
<line>contents of the detached letter form stub.</line>
</p>
<valediction>Love, Waldemar</valediction>
</body>
</text>
I want to transform the xml so that ONLY the images and their captions are displayed. Here's my xsl:
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" type="text/css" href="letter.css"/>
<title>Letter</title>
</head>
<body>
<div>
<xsl:apply-templates/>
</div>
</body>
</html>
</xsl:template>
<xsl:template match="//imageGroup">
<xsl:if test="//imageGroup">
<div class="image">
<xsl:for-each select="//imageGroup">
<img src="{image/#xlink:href}"/>
<span class="caption"><xsl:value-of select="caption"/></span>
</xsl:for-each>
</div>
</xsl:if>
</xsl:template>
The problem is, my output still shows all the text, and my images are doubled. How do I fix it without changing anything in the xml?
Replace the <xsl:apply-templates/> with <xsl:apply-templates select="//imageGroup"/>, then of course your template for those elements should not employ any for-each, but simply display each image, e.g.
<xsl:template match="imageGroup">
<img src="{image/#xlink:href}"/>
<span class="caption"><xsl:value-of select="caption"/></span>
</xsl:template>
I have a SQL Server database, and I need to populate it with returned xml from an api call.
This is the xml code that's returned(not in a file):
<petfinder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://api.petfinder.com/schemas/0.9/petfinder.xsd">
<header>
<version>0.1</version>
<timestamp>2013-04-08T14:52:23Z</timestamp>
<status>
<code>100</code>
<message/>
</status>
</header>
<lastOffset>25</lastOffset>
<pets>
<pet>
<id>18589607</id>
<shelterId>OK98</shelterId>
<shelterPetId>11C-0015</shelterPetId>
<name>Sam</name>
<animal>Cat</animal>
<breeds>
<breed>Domestic Short Hair</breed>
<breed>Tabby</breed>
</breeds>
<mix>yes</mix>
<age>Adult</age>
<sex>M</sex>
<size>XL</size>
<options>
<option>altered</option>
<option>hasShots</option>
<option>housebroken</option>
</options>
<description>
<![CDATA[
<div>This guy loves the camera. Look at him pose and show off! Sam is about 5 years old and is a cream Tabby. He is good with other cats and is house trained. He has turquoise eyes and is a sweet sweet cat. Sam loves to be the right hand man and assist you on any task you may have. Sammy is not the type of cat that likes to be held but will sit right next to you for some rubbing and head butting. Our adoption fee is $100 for dogs and $75 for cats. This adoption fee includes the spay or neutering and rabies shot. </div>
]]>
</description>
<lastUpdate>2012-07-24T14:50:17Z</lastUpdate>
<status>A</status>
<media>
<photos>
<photo id="1" size="x">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-1-x.jpg
</photo>
<photo id="1" size="fpm">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-1-fpm.jpg
</photo>
<photo id="1" size="pn">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-1-pn.jpg
</photo>
<photo id="1" size="pnt">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-1-pnt.jpg
</photo>
<photo id="1" size="t">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-1-t.jpg
</photo>
<photo id="2" size="x">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-2-x.jpg
</photo>
<photo id="2" size="fpm">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-2-fpm.jpg
</photo>
<photo id="2" size="pn">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-2-pn.jpg
</photo>
<photo id="2" size="pnt">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-2-pnt.jpg
</photo>
<photo id="2" size="t">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-2-t.jpg
</photo>
<photo id="3" size="x">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-3-x.jpg
</photo>
<photo id="3" size="fpm">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-3-fpm.jpg
</photo>
<photo id="3" size="pn">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-3-pn.jpg
</photo>
<photo id="3" size="pnt">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-3-pnt.jpg
</photo>
<photo id="3" size="t">
http://photos.petfinder.com/photos/US/OK/OK98/18589607/OK98.18589607-3-t.jpg
</photo>
</photos>
</media>
<contact>
<address1>714 Martin Luther King Jr Ave</address1>
<address2/>
<city>Duncan</city>
<state>OK</state>
<zip>73533</zip>
<phone/>
<fax/>
<email/>
</contact>
</pet>
...
More specifically, I need to take the nodes for ID, name, animal, description, and several others, and insert them into their respectful columns in my database.
And it must repeat this for each "pet" node that these are all in.
Can I do this in VB.net without saving a file, just as an xml string?
Please help, I've been stuck on this for days.
Assuming you have your XML structure in a variable (or stored procedure parameter) of type XML, you can do something like this:
CREATE PROCEDURE dbo.InsertXmlData
#XmlData XML
AS BEGIN
INSERT INTO dbo.YourTable(ID, PetName, Animal, Description)
SELECT
ID = Pet.value('(id)[1]', 'int'),
PetName = Pet.value('(name)[1]', 'varchar(50)'),
Animal = Pet.value('(animal)[1]', 'varchar(50)'),
[Description] = Pet.value('(description)[1]', 'varchar(500)')
FROM
#XmlData.nodes('/petfinder/pets/pet') AS xTBL(Pet)
END
That gives you the info in those nodes as a set of rows and columns which you can easily insert into a SQL Server table. So now you just need to find a way to call this stored procedure from your VB.NET code and pass in the XML into the #XmlData parameter
Here's an example of how you can extract the data for each pet from the XML using XPath and the XmlDocument class:
Dim doc As XmlDocument = New XmlDocument()
doc.LoadXml(xmlString)
For Each pet As XmlNode In doc.SelectNodes("/petfinder/pets/pet")
Dim id As String = pet.SelectSingleNode("id").InnerText
Dim name As String = pet.SelectSingleNode("name").InnerText
' ...
Next
I'm assuming you know how to save the data to your SQL database from there.
Precisely... can multiple <content:encoded> elements exist inside an <item> in a valid feed?
Full Story: I am modding the markup of my blog's RSS feeds for Google Currents, and for the app to display image galleries in articles as slideshows, the markup of my feed should look like this:
<rss version="2.0" ... xmlns:media="http://search.yahoo.com/mrss/">
...
<item>
<title>Item One</title>
<link>http://example.com/news/item-one</link>
<description>
<p>This is an example feed item</p>
</description>
...
<pubDate>Thu, 04 Aug 2011 19:41:00 GMT</pubDate>
<guid>http://example.com/news/item-one</guid>
<media:content height="84" type="image/jpeg" width="140" url="http://static.example.com/photo1.jpg">
<media:description>Caption for Photo 1</media:description>
</media:content>
<media:content height="100" type="image/jpeg" width="200" url="http://static.example.com/photo2.jpg">
<media:description>Caption for Photo 2</media:description>
</media:content>
<content:encoded><![CDATA[
<p>All the content goes here.</p>
<p>This is another line.</p>
]]></content:encoded>
...
</item>
...
</rss>
But due to the way my WordPress blog works, the galleries are shown within the article (which is usual), which means, the same happens in the RSS feeds as well. But the <media:content> element cannot be a sub-element of <content:encoded>.
So, I am wondering if I can do it like this and it'd still be valid RSS feed:
<rss version="2.0" ... xmlns:media="http://search.yahoo.com/mrss/">
...
<item>
<title>Item One</title>
<link>http://example.com/news/item-one</link>
<description>
<p>This is an example feed item</p>
</description>
...
<pubDate>Thu, 04 Aug 2011 19:41:00 GMT</pubDate>
<guid>http://example.com/news/item-one</guid>
<content:encoded><![CDATA[
<p>All the content goes here.</p>
]]></content:encoded>
<media:content height="84" type="image/jpeg" width="140" url="http://static.example.com/photo1.jpg">
<media:description>Caption for Photo 1</media:description>
</media:content>
<media:content height="100" type="image/jpeg" width="200" url="http://static.example.com/photo2.jpg">
<media:description>Caption for Photo 2</media:description>
</media:content>
<content:encoded><![CDATA[
<p>This is another line.</p>
]]></content:encoded>
...
</item>
...
</rss>
As you can see, I'd basically be splitting the <content:encoded> element into two, to give way for the slideshow markup. So, there'll be two <content:encoded> elements inside an <item>. Is that okay?
Having run my feed through W3C's Feed Validation Service, the answer seems to be "YES", multiple <content:encoded> elements can exist inside an <item> in a feed.
I'm creating a voicexml appliacation.
I want to store an user input into a global variable.
I wondered, the input should be stored in the fieldvar. shouldn't it? After I tried it with this, i tried to store it in an global variable:
<assign name="myvar" expr="'myinput'"/>
but somehow it didn't work. I used value expr="var" as expr.
<?xml version="1.0" encoding="UTF-8"?>
<vxml xmlns="http://www.w3.org/2001/vxml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2001/vxml
http://www.w3.org/TR/voicexml20/vxml.xsd"
version="2.0">
<var name="myProdukt" />
<form id="test">
<field name="var">
<prompt bargein="true" bargeintype="hotword" >Sagen Sie ein Produkt</prompt>
<grammar root="main" version="1.0" xml:lang="de-DE">
<rule id="main" scope="public">
<one-of>
<item> p1 </item>
<item> p2 </item>
<item> p3 </item>
<item> p4 </item>
</one-of>
</rule>
</grammar>
<filled>
<assign name="myProdukt" expr="<value expr="var"/>"/>
</filled>
</field>
</form>
<<!--[...] Here i want to use the input.-->
</vxml>
thanks in advance
---------------EDIT:
now i used this:
<filled>
test
<assign name="myProdukt" expr="var" />
</filled>
I only changed that. The Applications says "test" but then there is an error.
It isn'T allowed to use "var" instead I used an other name :-)
Did you try a simple assignment of field var to the variable myProdukt like so ?
<filled>
<assign name="myProdukt" expr="var"/>
</filled>
Which would be fine except that according to Section 5.1, Variables and Expressions of the Voice XML specification:
VoiceXML variables, including form
item variables, must not contain
ECMAScript reserved words.
So, you'll need to rename the field var to something that is not a reserved word in ECMAscript, say productSelection:
<field name="productSelection">
<!-- .. prompt, grammar as before .. -->
<filled>
<assign name="myProdukt" expr="productSelection"/>
</filled>
</field>