This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Applying Templates to document loaded with document() function
- From: "Kunal H. Parikh" <kunal at kaypee dot net>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Mon, 15 Apr 2002 11:02:32 +1000
- Subject: [xsl] Applying Templates to document loaded with document() function
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi !
I wish to try to match a template in my stylesheet to the nodes selected
from the 'document("Author.xml")'.
I have attached the file structures. Can someone please help ?
TIA,
Kunal
File Structures:
==== Tutorial.xml ====
<?xml version="1.0" encoding="UTF-8" ?>
<Tutorial>
<AuthorList>
<Author ID = "ID0001" />
<Author ID = "ID0002" />
</AuthorList>
</Tutorial>
==== End of Tutorial.xml ====
==== Author.xml ====
<?xml version="1.0" encoding="UTF-8" ?>
<AuthorList>
<Author ID = "ID0001">
<Title>Mr.</Title>
<FirstName>Kunal</FirstName>
<LastName>Parikh</LastName>
<E-MailAddress>String</E-MailAddress>
<Affiliation>String</Affiliation>
<WebsiteAddress>http://www.project42.net</WebsiteAddress>
<OtherInformation>String</OtherInformation>
</Author>
<Author ID = "ID0002">
<Title>Mr.</Title>
<FirstName>Kunal</FirstName>
<LastName>Parikh</LastName>
<E-MailAddress>String</E-MailAddress>
<Affiliation>String</Affiliation>
<WebsiteAddress>http://www.project42.net</WebsiteAddress>
<OtherInformation>String</OtherInformation>
</Author>
</AuthorList>
==== End of Author.xml ====
==== Tutorial.xsl ====
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:import href="Identity.xsl"/>
<xsl:output method="xml" indent="yes" />
<xsl:variable name="authors" select="document('Author.xml')" />
<xsl:key name="authors" match="Author" use="@ID" />
<xsl:template match="Author">
<xsl:variable name="ID" select="@ID" />
<xsl:for-each select="$authors">
<xsl:copy-of select="key('authors', $ID)" />
</xsl:for-each>
</xsl:template>
<xsl:template match="FirstName">
<TestElement>SuccessFull</TestElement>
</xsl:template>
</xsl:stylesheet>
==== End of Tutorial.xsl ====
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list