I have XML data
<logData>
<log>
<id>1</id>
</log>
<log>
<id>2</id>
</log>
<log>
<id>3</id>
</log>
<log>
<id>4</id>
</log>
</logData>
I want get only part of logs using xslt transformation using fn:subsequence function
here is my xslt
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:fn="http://www.w3.org/2006/xpath-functions" version="1.0" >
<xsl:output method="xml" indent="yes" />
<xsl:strip-space elements="*"/>
<xsl:template match="/logData" >
<xsl:element name="log">
<xsl:copy-of select="fn:subsequence(./log, 2, 3)"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
and I get
ERROR: 'The first argument to the non-static Java function 'subsequence' is not a valid object reference.'
I am using Java transformation API, part of Java SE 1.6.
Can you help me?
The function
subsequence()is defined in XPath 2.0 and is available only in an XSLT 2.0 processor.In XSLT 1.0 use:
Here is a complete transformation:
When this is applied on the provided XML document:
the wanted, correct result is produced: