[xquery-talk] xpath1 text node contains attribute, equivalent in xpath2
e-letter
inpost at gmail.com
Fri Dec 27 04:03:35 PST 2013
On 27/12/2013, Liam R E Quin <liam at w3.org> wrote:
> On Fri, 2013-12-27 at 09:20 +0000, e-letter wrote:
>> 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;
>
> Better to use the XPath 2 Functions and Operators spec, which does
> indeed list fn:contains().
>
{
let $x := fn:doc("xmldatabasefile.xml")/bookstore/book/title[fn:contains(.,'Learning
XML')]/parent::*
return $x
}
returns:
...<p>
<book category="WEB">
<title lang="en">
Learning XML
</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</p>...
Why is the full stop applied before the comma, because this is not
specified as an option in the specification about 'fn:contains'?
>> Is it possible to remove the xml elements from the output file?
>
> Change return $x to return $x/text() maybe
>
Not quite, returns:
...<p>
</p>...
if 'return' is changed to 'return $x/element()', the result is as
'return $x', but interestingly a removal of new line white space.
More information about the talk
mailing list