[xquery-talk] xpath1 text node contains attribute, equivalent in xpath2

e-letter inpost at gmail.com
Fri Dec 27 01:20:22 PST 2013


Readers,

For an xml file:

...
<book
		category="WEB"
		>
		<title
			lang="en"
			>
			Learning XML
		</title>
		<author>Erik T. Ray</author>
		<year>2003</year>
		<price>39.95</price>
	</book>
	...
	
An xquery file was created and processed using jedit xml plugins:

<html>
<body>
<p>
	{
		let $x := fn:doc("xmldatabasefile.xml")/bookstore/book/title[contains(text(),'XML')]/parent::*
		return $x
	}
</p>
</body>
</html>

Xpath1 specification § 4.2 string functions
(http://www.w3.org/TR/xpath/#section-String-Functions) describes a
"contains" function, but this was not found in xpath2; what is the
equivalent function in xpath2 please?

The resultant output:

<html>
   <body>
      <p>
         <book category="WEB">
            		
            <title lang="en">
               			Learning XML
               		
            </title>
            		
            <author>Erik T. Ray</author>
            		
            <year>2003</year>
            		
            <price>39.95</price>
            	
         </book>
      </p>
   </body>
</html>

Is it possible to remove the xml elements from the output file?

An alternative xquery was attempted:

...<p>
	{
		let $x := fn:doc("xmldatabasefile.xml")/bookstore/book/title/text()
		return $x
	}
</p>...

Resultant output:

...<p>
         			Everyday Italian
         		
         			Harry Potter
         		
         			XQuery Kick Start
         		
         			Learning XML
         		
      </p>...


Is it possible to select a specific title text with this xquery syntax?



More information about the talk mailing list