Subject: Re: Interesting(?) XSLT task From: "Steve Muench" <smuench@xxxxxxxxxxxxx> Date: Fri, 5 Nov 1999 11:19:29 -0600 |
Terris, There are probably more elegant solutions, but here is one... Given "terris.xml" ----------------- <?xml version="1.0"?> <!DOCTYPE file SYSTEM "terris.dtd"> <file> <User id="id5"/> <Login id="id1" user="id5" name="bar"/> <Login id="id2" user="id5" name="foo"/> <User id="id6"/> <Login id="id3" user="id6" name="barbar"/> <Login id="id4" user="id6" name="foofoo"/> </file> And "terris.xsl" ---------------- <UserList xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:for-each select="/file/User"> <User id="{@id}"> <xsl:attribute name="logins"> <xsl:variable name="id" select="@id"/> <xsl:for-each select="/file/Login[@user=$id]/@id"> <xsl:value-of select="."/> <xsl:if test="position() != last()"> <xsl:text> </xsl:text> </xsl:if> </xsl:for-each> </xsl:attribute> </User> </xsl:for-each> </UserList> Will produce the output ----------------------- <UserList> <User id="id5" logins="id1 id2"/> <User id="id6" logins="id3 id4"/> </UserList> _________________________________________________________ Steve Muench, Consulting Product Manager & XML Evangelist Business Components for Java Development Team http://technet.oracle.com/tech/java http://technet.oracle.com/tech/xml ----- Original Message ----- From: Terris <terris@xxxxxxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxx> Sent: Friday, November 05, 1999 11:57 AM Subject: Interesting(?) XSLT task | Let's say I have the following document which | has IDs and IDREFs: | | <User id="id5"/> | <Login id="id1" user="id5" name="bar"/> | <Login id="id2" user="id5" name="foo"/> | | I want to produce: | | <User id="id5" logins="id1 id2"/> | | I add a new attribute called logins which | contains the ids of the objects that reference | the user. | | Can someone show me a stylesheet that can | do this? I am having trouble with | concatenation two ids in the logins | attribute. | | Thanks, | Terris | | | | | | | XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list | XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Interesting(?) XSLT task, Terris | Thread | Re: Interesting(?) XSLT task, Eric van der Vlist |
Intercepting multiple output docume, Diarmuid Mac Carthy | Date | Interesting(?) XSLT task, Terris |
Month |