[xsl] Passing a node related to the current node as a template parameter

Subject: [xsl] 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
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">
	<Content>this message was received by user 77</Content>

The second document contains Persons:

<Person id="77">

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

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"/>
			<xsl:value-of select="position()"/>
			<xsl:value-of select="$person/UserName"/>
			<xsl:value-of select="Title"/>
			<xsl:value-of select="Content"/>

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:

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

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?



Current Thread