[xsl] RE: [sly] Applying Templates to document loaded with document() function

Subject: [xsl] RE: [sly] Applying Templates to document loaded with document() function
From: "Kunal H. Parikh" <kunal@xxxxxxxxxx>
Date: Mon, 15 Apr 2002 23:23:07 +1000
Hi !

Thanks for your reply !

But, I think I posed the question incorrectly, thinking, it was the same
situation.

Here is what I really am trying to do.

I have another XML files called stage.xml which refers to Authors and I
wish to apply the template of Authors to the nodes in
StageList/Stage/Author.

I have updated the contents of stage.xml, tutorial.xsl, tutorial.xml.

TIA,

Kunal

==== Tutorial.xml ====
<?xml version="1.0" encoding="UTF-8" ?>
<Tutorial>
	<AuthorList>
		<Author ID = "ID0001" />
		<Author ID = "ID0002" />
	</AuthorList>

	<StageList>
		<Stage ID = "ID0001" />
		<Stage ID = "ID0002" />
	</StageList>
</Tutorial>
==== End of Tutorial.xml ====

==== Stage.xml ====
<StageList>
	<Stage ID = "ID0001">
		<AuthorList>
			<Author ID = "ID0001" />
			<Author ID = "ID0002" />
		</AuthorList>
	</Stage>
	<Stage ID = "ID0002">
		<AuthorList>
			<Author ID = "ID0001" />
			<Author ID = "ID0002" />
		</AuthorList>
	</Stage>
</StageList>

==== End of Stage.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:variable name="stages" select="document('Stage.xml')" />
	<xsl:key name="stages" match="Stage" 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="Stage">
		<xsl:variable name="ID" select="@ID" />
		<xsl:for-each select="$stages">
			<xsl:copy-of select="key('stages', $ID)" />
		</xsl:for-each>
	</xsl:template>

</xsl:stylesheet>
==== End of Tutorial.xsl ====


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


Current Thread