[xsl] using call-template to call template from another xsl

Subject: [xsl] using call-template to call template from another xsl
From: Wate@xxxxxxxxx
Date: Fri, 4 May 2001 12:11:28 -0400
hi 

   i tried the apply-template it works.But now i have a different prob
my xml is 
<order>
	<admin>
		<pon>
			1234
		</pon>
		<reqtype>
			E
		</reqtype>
		<name>
			Shirish Wate
		</name>
	</admin>
	<billing>
		<firstname>
			Shirish
		</firstname>
		<lastname>
			Wate
		</lastname>
	</billing>
</order>


i want the output to something like this

<myorder>
	<adminsection>
		<purchaseordernumber>
			1234
		</purchaseordernumber>
		<myname>
			Shirish Wate
		</myname>
	</adminsection>
	<billingsection>
		<myfirstname>
			Shirish
		</myfirstname>
		<mylastname>
			Wate
		</mylastname>
	</billingsection>
</myorder>

i have written three xsls master.xsl,admin.xsl and billing.xsl
admin.xsl
---------------------------------------------------
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; >
	<xsl:output method = "xml" indent = "yes" omit-xml-declaration="yes"
/> 
	<xsl:template  name="tmpadmin" >
		<adminsection>
			<xsl:if test= "pon"
><purchaseordernumber><xsl:value-of select="pon" />
</purchaseordernumber></xsl:if>
			<xsl:if test= "name" ><myname><xsl:value-of
select="name" /> </myname></xsl:if>
		</adminsection>
	</xsl:template>
</xsl:stylesheet>

-------------------------------------------------
billing.xsl
-------------------------------------------------

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; >
	<xsl:output method = "xml" indent = "yes" omit-xml-declaration="yes"
/> 
	<xsl:template  name="tmpbill" >
		<adminsection>
			<xsl:if test= "firstname"
><myfirstname><xsl:value-of select="firstname" /> </myfirstname></xsl:if>
			<xsl:if test= "lastname" ><mylastname><xsl:value-of
select="lastname" /> </mylastname></xsl:if>
		</adminsection>
	</xsl:template>
</xsl:stylesheet>
-------------------------------------------------
----------------------------------------------------
master.xsl
---------------------------------------------------
 <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; >
	<xsl:import  href="admin.xsl"></xsl:import>
	<xsl:import  href="billing.xsl"></xsl:import>
	<xsl:template match="/order/admin">
		  <xsl:variable name="reqtype"><xsl:value-of select =
"ReqTyp" /> </xsl:variable>
	<myorder>
			<xsl:if test="contains($reqtype,'E')">
			<xsl:call-template name="tmpadmin">
	
<xsl:with-param name="reqtype"><xsl:value-of
select="$reqtype"></xsl:value-of></xsl:with-param>
	
</xsl:call-template>
			<xsl:call-template name="tmpbill">
	
<xsl:with-param name="reqtype"><xsl:value-of
select="$reqtype"></xsl:value-of></xsl:with-param>
	
</xsl:call-template>
	   </xsl:if>
	</myorder>
	</xsl:template>
</xsl:stylesheet>
----------------------------------------------------

i was using call-template as i need to pass a  parameter.How do i use
apply-templates  in this situation.Also i need to be able to
apply-template/call-template different templates based on the value of
$reqtype variable.

thankx in advance
shirish wate

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


Current Thread