|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: How to find all parents having the same child?
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








