Closed Bug 1119498 Opened 9 years ago Closed 9 years ago

Embedding an XSLT into an XML document does not work

Categories

(Core :: XSLT, defect)

34 Branch
defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: bogser, Unassigned)

Details

(Keywords: reproducible, testcase)

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0
Build ID: 20141126041045

Steps to reproduce:

Open TestXslEmbeddingInFirefox.xml attached (this xml has XSLT embedded). The content of the file is the following:

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="#stylesheet"?>
<catalog>

<xsl:stylesheet xml:id="stylesheet" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
  <body>
  <h2>My CD Collection</h2>
    <table border="1">
      <tr bgcolor="#9acd32">
        <th>Title</th>
        <th>Artist</th>
      </tr>
      <xsl:for-each select="catalog/cd">
      <tr>
        <td><xsl:value-of select="title"/></td>
        <td><xsl:value-of select="artist"/></td>
      </tr>
      </xsl:for-each>
    </table>
  </body>
</html>
</xsl:template>
</xsl:stylesheet>

    <cd>
        <title>Empire Burlesque</title>
        <artist>Bob Dylan</artist>
        <country>USA</country>
        <company>Columbia</company>
        <price>10.90</price>
        <year>1985</year>
    </cd>
    <cd>
        <title>Hide your heart</title>
        <artist>Bonnie Tyler</artist>
        <country>UK</country>
        <company>CBS Records</company>
        <price>9.90</price>
        <year>1988</year>
    </cd>
</catalog>


Actual results:

Firefox displays error:
Error loading stylesheet: Parsing an XSLT stylesheet failed.


Expected results:

Firefox should display a well-formed table.

Google Chrome 39 displays TestXslEmbeddingInFirefox.xml without any problems. Seems Firefox does not fully support xml:id attribute and therefore cannot find an embedded XSLT referenced in xml-stylesheet processing instruction.

According to XSLT spec (http://www.w3.org/TR/xslt20/#embedded) xml:id is allowed in case of XSLT embedding.
Component: Untriaged → XSLT
Product: Firefox → Core
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows 7 → All
Hardware: x86_64 → All
Gecko does not support xmlid, and we don't plan to. So we don't recognize the "xml:id" attribute as an id attribute.

Instead we, in accordance with the most recent DOM specs, treat the 'id' attribute as id on all elements.

So just change <xsl:stylesheet xml:id="stylesheet" to <xsl:stylesheet id="stylesheet" and it should work just fine.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → WONTFIX
Excellent, changing 'xml:id' to 'id' really solves the problem. But unfortunately it breaks Google Chrome 39.0 that does not treat 'id' attribute as an id. So for now to support both Firefox and Chrome both id and xml:id attributes should be specified on xsl::stylesheet element. This is an acceptable solution I think.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: