Subject: RE: [xsl] How to find all parents having the same child? From: Jarno.Elovirta@xxxxxxxxx Date: Wed, 18 Jun 2003 11:12:15 +0300 |
Hi, > Here an example: > > <Quries> > <Query name="query1"> > <Query name="query2"> > <Table name="table1"/> > <Table name="table2"/> > <Query name="query3"> > <Table name="table3"/> > </Query> > </Query> > </Query> > <Query name="query4"> > <Table name="table1"/> > <Table name="table2"/> > <Table name="table3"/> > </Query> > </Queries> > > Given that, I would like to extract all parents for > each leaf like the following: > > table3: query4, query3 > table1: query4, query1 did you mean table1: query4, query2 as query1 is not a direct parent of table1. > query3: query2 > query2: query1 > > An example from you on how to get that cross-reference > list would help me a lot. Hopefully this will get you started. <xsl:key name="x" match="Table | Query" use="@name"/> <xsl:output method="text"/> <xsl:template match="Queries"> <xsl:for-each select="descendant::*[generate-id(.) = generate-id(key('x', @name))]"> <xsl:if test="key('x', @name)[parent::Query]"> <xsl:value-of select="@name"/>: <xsl:text/> <xsl:for-each select="key('x', @name)"> <xsl:if test="not(position() = 1)">, </xsl:if> <xsl:value-of select="../@name"/> </xsl:for-each> <xsl:text>
</xsl:text> </xsl:if> </xsl:for-each> </xsl:template> Cheers, Jarno - Chris C: Vengeance Is Mine XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] How to find all parents h, Michael Kay | Thread | RE: [xsl] How to find all parents h, Bita Jooooooon |
RE: [xsl] How to find all parents h, Bita Jooooooon | Date | Re: [xsl] XML XSL Question about in, David Carlisle |
Month |