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

Passing a node related to the current node as a templa

Subject: Passing a node related to the current node as a template parameter
From: Martynas Jusevicius <martynas.jusevicius@xxxxxxxxx>
Date: Fri, 23 Jan 2009 17:28:05 +0100
 Passing a node related to the current node as a templa
Hey list,

I have 2 XML documents which I would like to join.
The first one comes as document('arg://messages') and contains
Messages of such structure:

<Messages senderID="25" receiverID="77">
	<Title>test</Title>
	<Content>this message was received by user 77</Content>
</Messages>

The second document contains Persons:

<Person id="77">
	<UserName>admin</UserName>
</Person>

Depending on the situation (whether I'm transforming sent or received
Messages), Persons are passed either as document('arg://senders') or
document('arg://receivers').

Now, I would like to have one common template for Messages to build a
table, no matter if they were sent or received. So my idea is to pass
the Person who has either sent or received the Message as a parameter
for the Message template:

<xsl:template match="Message">
	<xsl:param name="person"/>
	<tr>
		<td>
			<xsl:value-of select="position()"/>
		</td>
		<td>
			<xsl:value-of select="$person/UserName"/>
		</td>
		<td>
			<xsl:value-of select="Title"/>
		</td>
		<td>
			<xsl:value-of select="Content"/>
		</td>
	</tr>
</xsl:template>

Now, the question is, how do I apply templates on
document('arg://messages') to get a received message table? I need to
join it with document('arg://receivers') on Message/@receiverID =
Person/@id. I was thinking about something along those lines:

<table>
	<xsl:apply-templates select="document('arg://messages')//Message">
		<xsl:with-param name="person"
select="document('arg://receivers')//Person[@id =
current()/@senderPersonID]"/>
	</xsl:apply-templates>
</table>

But the current() function does not help here because it returns not a
Person but a completely different node (and it should). So how do I
solve it? Or is there a more XSLT-like way to do this?

Thanks,


Martynas
xml.lt

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.