Closed Bug 275824 Opened 20 years ago Closed 20 years ago

Essential node navigation in XSLT fails

Categories

(Core :: XSLT, defect)

1.7 Branch
x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 187620

People

(Reporter: mitchgould, Assigned: peterv)

References

Details

Although many examples from "XSLT Quickly" by Bob Ducharme succeed in Mozilla,
some others fail without an error message, resulting in a gray client window.
This includes important node-navigation tasks in XSLT (attached).

/////////////////////////////////////

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     version="1.0">
<xsl:output method="xml" omit-xml-declaration="yes" indent="no"/>
<?startSampleFile ?>

<!-- xq103.xsl applies style to xq102.xml -->
<!-- Fails in Firefox: client area just becomes a gray window -->
<!-- Works fine in IE6 -->
<!-- Excellent demo of node navigation in XSLT -->
<!-- XSLT Quickly by Bob Ducharme -->

<xsl:template match="item[3]">
~~~~ Start of item element's template ~~~~
1. This node: {<xsl:apply-templates/>}
2. First node: {<xsl:value-of select="../item[1]"/>}
3. Last node: {<xsl:value-of select="../item[last()]"/>}
4. Preceding node: 
   {<xsl:value-of select="preceding-sibling::item[1]"/>}
5. Next node: {<xsl:value-of select="following-sibling::item[1]"/>}
6. flavor attribute value of first node: 
   {<xsl:value-of select="../item[1]/@flavor"/>}
~~~~ End of item element's template ~~~~
</xsl:template>

<?endSampleFile ?>

<!-- Dont bother with the other ones. -->
<xsl:template match="item"/>

</xsl:stylesheet>

/////////////////////////////////////////////////

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="xq103.xsl"?>

<!-- xq102.xml - style it using xq103.xsl -->
<!-- Fails in Firefox: client area just becomes a gray window -->
<!-- Works fine in IE6 -->
<!-- Excellent demo of node navigation in XSLT -->
<!-- XSLT Quickly by Bob Ducharme -->
<list>
<item flavor="mint">First node.</item>
<item flavor="chocolate">Second node.</item>
<item flavor="vanilla">Third node.</item>
<item flavor="strawberry">Fourth node.</item>
</list>
*** Bug 275825 has been marked as a duplicate of this bug. ***
Assignee: firefox → peterv
Component: General → XSLT
Product: Firefox → Core
QA Contact: firefox.general → keith
Version: 1.0 Branch → 1.7 Branch
The problem is that the stylesheet doesn't create a complete document. The
stylesheet tries to create a bunch of text, but this text is insert directly in
the root of the document. However, since textnodes aren't allowed there they are
ignored.

Note that the stylesheet isn't broken per se. XSLT does allow you to create
results that aren't complete documents. So it could be argued that we should be
able to deal.

To work around this place a element around the created contents, like:
<xsl:template match="item[3]">
<result>
~~~~ Start of item element's template ~~~~
...
~~~~ End of item element's template ~~~~
</result>
</xsl:template>


or add an <output method="text">

*** This bug has been marked as a duplicate of 187620 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.