Martin Honnen created XALANJ-2818: ------------------------------------- Summary: document-node() matches/selects more than document nodes Key: XALANJ-2818 URL: https://issues.apache.org/jira/browse/XALANJ-2818 Project: XalanJ2 Issue Type: Bug Security Level: No security risk; visible to anyone (Ordinary problems in Xalan projects. Anybody can view the issue.) Components: Xalan, Xalan-CmdLine, XPath Affects Versions: The Latest Development Code Environment: Java 8, Windows 11 Reporter: Martin Honnen Attachments: document-node-test1.xsl, document-node-test2.xsl, sample2.xml
This is a bug report against the XSLT 3.0 development branch of Xalan. I find that document-node() matches/selects a lot more than just document nodes. Here are two test cases: {code:java} <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:map="http://www.w3.org/2005/xpath-functions/map" xmlns:array="http://www.w3.org/2005/xpath-functions/array" exclude-result-prefixes="#all"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:value-of select="count(descendant-or-self::document-node())"/> </xsl:template> </xsl:stylesheet> {code} which should output 1 for any XML input but seems to output the number of nodes in the whole input document and {code:java} <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:map="http://www.w3.org/2005/xpath-functions/map" xmlns:array="http://www.w3.org/2005/xpath-functions/array" exclude-result-prefixes="#all"> <xsl:output method="text"/> <xsl:param name="count" as="xs:integer" select="1"/> <xsl:template match="document-node()"> <xsl:param name="count" select="$count"/> <xsl:text>Matching document-node() </xsl:text> <xsl:value-of select="$count"/> <xsl:text> </xsl:text> <xsl:apply-templates> <xsl:with-param name="count" select="$count + 1"/> </xsl:apply-templates> </xsl:template> </xsl:stylesheet> {code} which should process the single document nodes but with Xalan processes lots of nodes e.g. outputs {noformat} Matching document-node() 1 Matching document-node() 2 Matching document-node() 3 Matching document-node() 3 Matching document-node() 4 Matching document-node() 4 Matching document-node() 5 Matching document-node() 4 Matching document-node() 4 Matching document-node() 5 Matching document-node() 4 Matching document-node() 3 Matching document-node() 3 Matching document-node() 4 Matching document-node() 4 Matching document-node() 5 Matching document-node() 4 Matching document-node() 4 Matching document-node() 5 Matching document-node() 4 Matching document-node() 3{noformat} Input sample is e.g. {code:java} <root> <div> <para>This is a test.</para> <para>This is a test.</para> </div> <div> <para>This is a second test.</para> <para>This is a second test.</para> </div> </root>{code} -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@xalan.apache.org For additional commands, e-mail: dev-h...@xalan.apache.org