I am studying the concept of Node comparison in XPath 2.0.
I am working with precedes operator <<
and getting an error below:
The value of attribute "select" associated with an element type "xsl: sequence" must not contain the '<' character.
I tried with XPath 2.0 precedes operator
<xsl:sequence select="/Root/*[../H1[2] << .]"/>
The below is the code I tried.
Input:
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<H1>first</H1>
<p>Test</p>
<H1>second</H1>
<p/>
<p/>
<H1/>
<p/>
<p/>
</Root>
Processing: I am selecting the preceding element using <<
operator.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:sequence select="/Root/*[../H1[2] << .]"/>
</xsl:template>
</xsl:stylesheet>
Issue:
The value of attribute "select" associated with an element type "xsl:sequence" must not contain the '<' character.
Expected result:
To find the preceding element of H1[2] element by using <<
operator.
The XPath syntax is <<
but inside of an XML/XSLT document you need to escape it as <<
.