Subject: Re: [xsl] Applying Templates to document loaded with document() function From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Mon, 15 Apr 2002 10:03:50 +0100 |
Hi Kunal, > I wish to try to match a template in my stylesheet to the nodes > selected from the 'document("Author.xml")'. When you match nodes, you can't specifically say that they come from one document or another document. However, there are two ways that you could approach this problem. First, when you apply templates to the Author elements from Author.xml, you could apply templates in a mode that you only use when applying templates to Author elements from that document. For example: <xsl:variable name="authors" select="document('Author.xml')" /> <xsl:key name="authors" match="Author" use="@ID" /> <!-- template for Author elements in source document --> <xsl:template match="Author"> <xsl:variable name="ID" select="@ID" /> <xsl:for-each select="$authors"> <xsl:apply-templates select="key('authors', $ID)" mode="Author.xml" /> </xsl:for-each> </xsl:template> <!-- template for Author elements in Author.xml --> <xsl:template match="Author" mode="Author.xml"> ... </xsl:template> Alternatively, you have a situation where the Author elements in Author.xml have a different kind of structure to the Author elements in the source document. So you could devise a match pattern that would only match those Author elements from Author.xml since (for example) only those Author elements have element children: <!-- template for Author elements in Author.xml --> <xsl:template match="Author[*]"> ... </xsl:template> The first is the more general solution. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Applying Templates to documen, Kunal H. Parikh | Thread | [xsl] RE: [sly] Applying Templates , Kunal H. Parikh |
RE: [xsl] non-existing file in docu, Michael Kay | Date | [xsl] regd String Tokeniser, william locksman |
Month |