Last modified: 2013-03-11 19:20:32 UTC
Given this snippet of XML: <PROP name="cors" val="valox"/> <PROP name="spec" val="DAS"/> The following XPath should select the value 'valid': //PROP[@name='cors']/@val You can confirm this using xmlstarlet: # gives 'valox' xmlstarlet sel -t -v "//PROP[@name='cors']/@val" -n snippet.xml However, the = sign in the XPath messes with the way the data parameter takes values, namely as key=value pairs separated by commas. i.e. here is how my call looks: {{#get_web_data:url=http://www.dasregistry.org/das/sources |format=XML |use xpath |data=title=//@title,description=//@description,sourcesDoc=//PROP[@name='sourcesDoc']/@value }} I'm seeing 'external_values' for the title and description local variables, but not the sourcesDoc (which shows up 'blank').
Actually, investigating this, the = and , separators in the data parameter are fine, the issue here is simply the case of the XML attribute in question, sourcesDoc in this case... Complex XPATH works fine in the data string, except when the attribute is mixed case... | data=description=//@description,TITLE=//@title,spec=//prop[@name='spec']/@value,sourcesdoc=//prop[@name='sourcesDoc']/@value,sources=//prop[@name='sources']/@value,alertMe=//prop[@name='alertMe']/@value Only alertMe and sourcesDoc fail!
{{#get_web_data: url=http://localhost/~dbolser/sources-formatted.xhtml | format=xml | use xpath | data=description=//@description,TITLE=//@title,spec=//prop[@name='spec']/@value,sourcesdoc=//prop[@name='sourcesDoc']/@value,sources=//prop[@name='sources']/@value,alertMe=//prop[@name='alertMe']/@value }} * {{#external_value:description}} * {{#external_value:TITLE}} * {{#external_value:spec}} * {{#external_value:sources}} * {{#external_value:TITLE}} * {{#external_value:sourcesdoc}} * {{#external_value:alertMe}} Only sourcesdoc and alertMe EVs fail to return values. The XML looks like this: <sources> <source uri="DS_112" title="structure" description="A reference server for protein structure annotations. Serves 3D coordinates of protein structures."> <maintainer email="andreas.prlic@gmail.com"/> <version uri="DS_112" created="2005-03-21T16:33:59+0000"> <coordinates uri="http://www.dasregistry.org/dasregistry/coordsys/CS_DS7" source="Protein Structure" authority="PDBresnum" test_range="1.10.8.10-SSG5-1">PDBresnum,Protein Structure</coordinates> <capability type="das1:structure" query_uri="http://das.sanger.ac.uk/das/structure/structure"/> <prop name="sources" value="valid"/> <prop name="cors" value="valid"/> <prop name="error-segment" value="valid"/> <prop name="structure" value="valid"/> <prop name="entry_points" value="valid"/> <prop name="spec" value="DAS/1.6E"/> <prop name="leaseTime" value="2012-12-13T13:16:00+0000"/> <prop name="alertMe" value="1"/> <prop name="sourcesDoc" value="http://das.sanger.ac.uk/das/"/> <prop name="projectName" value="test for windows"/> <prop name="projectDesc" value="windows test of image upload"/> <prop name="projectIcon" value="http://www.dasregistry.org/ProjectIcon?id=86"/> <prop name="projectHome" value="http://www.google.com"/> </version> </source>
My suggested fix (entirely from discussion with Yaron): When parsing the data field in ED_ParserFunctions.php, the call should actually be to "paramToArray( $args['data'], false, false )" in the case of using XPath! This should be simple enough to implement. I'll submit a patch at some point (if you don't beat me to it).
This is now fixed in the Git code, as far as I know - marking it as "fixed".