[ https://issues.apache.org/jira/browse/XALANJ-2818?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17957014#comment-17957014 ]
Martin Honnen commented on XALANJ-2818: --------------------------------------- Joe, I do disagree with your resolution, try an XSLT 3.0 processor like Saxon 12 and you will find that {code:java} <xsl:template match="/"> <xsl:value-of select="count(descendant-or-self::document-node())"/> </xsl:template>{code} selects one node/counts one node. I know how to count a document node but the test case has been written to demonstrate that Xalan currently selects/matches nodes as document nodes that are not document nodes. So all descendants of a node are on the descendant-or-self axis, yes, but only one of them is a document-node(), so the node test document-node(), even if used on the descendant-or-self axis, should select a single node. See https://www.w3.org/TR/xpath-31/#node-tests. > 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 > Assignee: Joe Kesselman > Priority: Major > 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