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"> <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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] xsl:for-each-group and id, Jesper Tverskov | Thread | [xsl] Help needed with converting t, Ken Starks |
Re: [xsl] xsl:for-each-group and id, Owen Rees | Date | Re: [xsl] xsl:for-each-group and id, Jesper Tverskov |
Month |