You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Martin Berkemeier (JIRA)" <xa...@xml.apache.org> on 2008/05/07 10:03:56 UTC

[jira] Commented: (XALANJ-2212) descendant-or-self isn't sorted

    [ https://issues.apache.org/jira/browse/XALANJ-2212?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12594816#action_12594816 ] 

Martin Berkemeier commented on XALANJ-2212:
-------------------------------------------

I encountered a similar problem:

If one applies the following stylesheet to the above XML

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />

<xsl:template match="/">
	Nodes: <xsl:value-of select="count(//descendant-or-self::d)" />
</xsl:template>

</xsl:stylesheet>

the result for xalan-j 2.7.1 is:

	Nodes: 5

If one uses xsltc (org.apache.xalan.xsltc.trax.TransformerFactoryImpl) the result is:

	Nodes: 1

This supports the assumption, that the descendant-or-self iterator doesn't return unique nodes (in interpreter mode) in this case.

If one uses the XPath API (using org.apache.xpath.jaxp.XPathFactoryImpl) with the same XPath expression, the size of the returned NodeList is 1.

	InputSource xmlSource = new InputSource(....);
	System.setProperty("javax.xml.xpath.XPathFactory:test", "org.apache.xpath.jaxp.XPathFactoryImpl");
	XPath xPathObject = XPathFactory.newInstance("test").newXPath();
	Object result = xPathObject.evaluate("//descendant-or-self::d", xmlSource, XPathConstants.NODESET);

Even if the XPath expression can be simplified, I think the different transformer implementations should not return different results and to my opinion the result set should contain only one node.

> descendant-or-self isn't sorted
> -------------------------------
>
>                 Key: XALANJ-2212
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2212
>             Project: XalanJ2
>          Issue Type: Bug
>          Components: XPath
>         Environment: Windows XP SP 2, JRE 1.4.2_05, Xalan 2.7.1
>            Reporter: David Landwehr
>            Priority: Minor
>
> Take the following instance:
> <a>
>   <b>
>     <c>
>       <d/>
>     </c>
>   </b>
> </a>
> And make a transformation with the following stylesheet:
> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> 	<xsl:template match="/">
> 	  Should Return:b1,c2 =
> 	  <xsl:for-each select="/descendant-or-self::*/descendant-or-self::*[ (local-name()='b' and position()=1) or (local-name()='c' and position()=3)]">
> 	    <xsl:value-of select="concat(local-name(), position())"/>,</xsl:for-each>
> 	  Should Return: b =
> 	  <xsl:value-of select="local-name(/descendant-or-self::*/descendant-or-self::*[ (local-name()='b' and position()=1) or (local-name()='c' and position()=3)])"/>
> 	  Should Return: 4=
>   	  <xsl:value-of select="count(/descendant-or-self::*/descendant-or-self::*)"/>
> 	</xsl:template>
> </xsl:stylesheet>
> The result should be (which it is when using xsltc):
> Should Return:b1,c2 =
> b1,c2,
> Should Return: b =
> b
> Should Return: 4=
> 4
> But the result is:
> Should Return:b1,c2 =
> c1,b2,
> Should Return: b =
> c
> Should Return: 4=
> 10
> It looks like the descendant-or-self::*/descendant-or-self::* isn't sorted and that the nodes returned from the iterator isn't unique (e.g. that the iterator believes it returns unique nodes).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org