[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

How do I pass params from <xsl:apply-templates> and r

Subject: How do I pass params from <xsl:apply-templates> and receive params from the template?
From: sudheshna iyer <sudheshnaiyer@xxxxxxxxx>
Date: Sun, 3 Oct 2010 04:54:35 -0700 (PDT)
 How do I pass params from <xsl:apply-templates> and  r
How do I pass params from <xsl:apply-templates> and receive params from the template?

This is same problem as I posted in "Mapping from two sources". But I am trying different method of using <xsl:apply-templates> with param.

I need to have two sources:

input1 and input2. 

input1:
<?xml version="1.0" encoding="ISO-8859-1"?>
<Order>
	<OrderLine>
			<OLN>1</OLN>
			<Fname>aa</Fname>
	</OrderLine>
	<OrderLine>
			<OLN>2</OLN>
			<Fname>bb</Fname>
	</OrderLine>	
</Order>


input2:
<?xml version="1.0" encoding="ISO-8859-1"?>
<POOrder>
	<POOrderLine>
			<OLN>1</OLN>
			<ID>123</ID>
			<LName>aa</LName>
	</POOrderLine>
	<POOrderLine>
			<OLN>2</OLN>
			<ID>324</ID>
			<LName>bb</LName>
	</POOrderLine>	
	<POOrderLine>
			<OLN>3</OLN>
			<ID>456</ID>
			<LName>bb</LName>
	</POOrderLine>	
</POOrder>

I need the output from both sources combined. Please note that first two elements are coming from input1 and thrid element is from input2. What is the 
optimal way of doing this?

<?xml version="1.0" encoding="ISO-8859-1"?>
<OrderResponse>
	<Oline>
		<OLN>1</OLN>
		<Fname>aa</Fname>
		<ID>123</ID>
	</Oline>
	<Oline>
		<OLN>2</OLN>
		<Fname>bb</Fname>
		<ID>324</ID>
	</Oline>
</OrderResponse>

So I did the following:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:template match="POOrder">
		<xsl:param name="param1"/>
		<xsl:param name="param2"/>
		<xsl:value-of select="$param1"/>  ==========> But I am not able to receive params that I am passing???
		<xsl:value-of select="$param2"/>
	</xsl:template>
	
	<xsl:template match="Order">
		<OrderResponse>
			<xsl:for-each select="OrderLine">
				<Oline>
					<xsl:apply-templates select="document('C:/temp/input2.xml')"/>
					<xsl:variable name="vOln">
						<xsl:apply-templates select="POOrder">
							<xsl:with-param name="param1"><xsl:value-of select="OLN"/></xsl:with-param>
							<xsl:with-param name="param2">OLN</xsl:with-param>
						</xsl:apply-templates>
					</xsl:variable>
					<OLN><xsl:value-of select="$vOln"/></OLN>
					<Fname><xsl:value-of select="Fname"/></Fname>
					<Email><xsl:value-of select="Email"/></Email>			
				</Oline>
			</xsl:for-each>
		</OrderResponse>
	</xsl:template>
</xsl:stylesheet>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.