Closed Bug 184249 Opened 22 years ago Closed 22 years ago

document() function doesn't seem to work in template in included xsl-file

Categories

(Core :: XSLT, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 179231

People

(Reporter: johan, Assigned: peterv)

References

Details

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2) Gecko/20021204 Debian/1.2.1-1
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2) Gecko/20021204 Debian/1.2.1-1

When including a xsl file(<xsl:include href... />) and calling a template in
that included xsl file(<xsl:call-template name=... /> using the document()
function in this template gives no result data. Sablotron gives me with this
construction the expected results.
 

Reproducible: Always

Steps to Reproduce:
1. Create an xml file (test.xml)
2.1  Create an xsl file (test.xsl)
2.2  Include another xsl document (include.xsl)
2.3  Call a template in the second xsl file 
2.4  Try to access an external xml file (include.xml)
2.4.1 For example with <xsl:value-of select="document('include.xml')/include" />
2.4.2 Or with <xsl:for-each select="document('include.xml')/include"> ... </...>
2.4.3 No Data is shown from the external xml file 

Files:
test.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<root>
  <data>data</data>
</root>

include.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<include>
  <data>Included data</data>
</include>

test.xsl:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:include href="include.xsl" />
   <xsl:template match="/">
      <html>
         <body>
            Root data: <xsl:value-of select="root/data" /> <br />
            <xsl:call-template name="include" />
            Included data from first xsl: <xsl:value-of
select="document('include.xml')/include/data" /> <br />
         </body>
      </html>
  </xsl:template>
</xsl:stylesheet>

include.xsl:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:template name="include">
      Template include.xsl:include entered <br />
      Included data: <xsl:value-of select="document('include.xml')/include/data"
/> <br />      Template include.xsl:include left <br />
   </xsl:template>
</xsl:stylesheet>
Actual Results:  
Root data: data
Template include.xsl:include entered
Included data:
Template include.xsl:include left
Included data from first xsl: Included data

Expected Results:  
Root data: data
Template include.xsl:include entered
Included data: Included data
Template include.xsl:include left
Included data from first xsl: Included data
this is probably a dup of bug 179231, but i'll mark it as dependant until i've
investigated some more
Depends on: 179231
*** Bug 186646 has been marked as a duplicate of this bug. ***

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