You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2002/08/27 19:16:53 UTC

DO NOT REPLY [Bug 12090] New: - iterates over phantome nodes.

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12090>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12090

<xsl:for-each> iterates over phantome nodes.

           Summary: <xsl:for-each> iterates over phantome nodes.
           Product: XalanJ2
           Version: 2.4Dx
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Xalan
        AssignedTo: xalan-dev@xml.apache.org
        ReportedBy: crowley_mark@yahoo.com


The XSL...

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

<xsl:template match="/">
	<xsl:apply-templates select="parent"/>
</xsl:template>

<xsl:template match="parent">
	<xsl:for-each select="child::node()">
name is <xsl:value-of select="name()"/> text is <xsl:value-of select="text()"/>
	</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

Used with the XML...

<?xml version="1.0" encoding="UTF-8"?>
<parent>
	<a>1</a>
	<b>2</b>
	<c>3</c>
	<d>4</d>
	<e>5</e>
</parent>

generates...

name is  text is 
name is a text is 1
name is  text is 
name is b text is 2
name is  text is 
name is c text is 3
name is  text is 
name is d text is 4
name is  text is 
name is e text is 5
name is  text is 

Each *real* node is intersperced with two *phantom* empty nodes.

Will attempt to look into this myself, just wondering if anyone has come across 
this.

Thanks in advance.

[Bug 12090] New: iterates over phantome nodes.

Posted by Santiago Pericas-Geertsen <Sa...@sun.com>.
On Tuesday 27 August 2002 13:16, bugzilla@apache.org wrote:
> Used with the XML...
>
> <?xml version="1.0" encoding="UTF-8"?>
> <parent>
> 	<a>1</a>
> 	<b>2</b>
> 	<c>3</c>
> 	<d>4</d>
> 	<e>5</e>
> </parent>
>
> generates...
>
> name is  text is
> name is a text is 1
> name is  text is
> name is b text is 2
> name is  text is
> name is c text is 3
> name is  text is
> name is d text is 4
> name is  text is
> name is e text is 5
> name is  text is
>
> Each *real* node is intersperced with two *phantom* empty nodes.

 I don't see any bug here: these are "\n" nodes. You can (i) get rid of new 
lines in your XML, (ii) use xsl:strip-space or (iii) use child::* to filter 
out text nodes.

 Hope this helps.

--
Santiago Pericas-Geertsen
Sun Microsystems