xsl-list
[Top] [All Lists]

Re: Why can't I use document() inside a template rule to match the te mplate ?

2003-11-17 07:05:37
you can't match the to-be-determined content of what the document function
returns.
to use document(), assign it to a var or use it in some expression

----- Original Message -----
From: "Narender S chauhan" <nchauhan(_at_)quark(_dot_)co(_dot_)in>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Monday, November 17, 2003 7:46 AM
Subject: [xsl] Why can't I use document() inside a template rule to match
the te mplate ?


Hi,
 I want to use document function in a template rule like below in which
primary XML and referenced XML through document() function may be entirely
different:

<xsl:template match="/">
<xsl:apply-template select="document('Tes.xml')" />
</xsl:template>

<xsl:template match="document(Tes.xml)"> // Browser throws error at
this point.
<span>TEST</span>
</xsl:template>

My question is, why can't I use document function in the template rule or
is
there any alternative to such a problem.
A typical example would be as follows:
--->doc1.xml
<books>
<book>
<author>Graddy Booch</author>
<title>UML User Guide</title>
</book>
<book>
<author>Gamma</author>
<title>Design Patterns</title>
</book>
</books>

---> doc2.xml
<readers>
<reader>
<name>naren</name>
<occupation>Software Engineer</occupation>
</reader>
</readers>

---->doc.xsl
<?xml version='1.0' encoding="windows-1252"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="html" />

<xsl:template match="/">
<html>
<body>
<span>
<xsl:for-each select="books/book/author">
<xsl:value-of select="." />
<br />
</xsl:for-each>
<xsl:apply-templates
select="document('doc2.xml')" />
</span>
</body>
</html>
</xsl:template>
<xsl:template match="document('doc2.xml')"> // Browser gives an error to
this
<span>Test</span>
</xsl:template>
</xsl:stylesheet>

Any help would be great.
~Naren

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>