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[(_at_)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
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--