|
Subject: RE: [xsl] Processing Nested Lists From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Mon, 26 Feb 2007 16:24:09 -0000 |
The structure of your input and output seems to be essentially the same, so
an ordinary recursive tree-walk using apply-templates should do the job:
<xsl:template match="TaxonomyNode">
<xsl:copy>
<xsl:copy-of select="@*">
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="Description">
<Description>
<w:r>
<w:t><xsl:value-of select="."/></w:t>
</w:r>
</Description>
</xsl:template>
Or have I missed something?
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: Andy Carr1 [mailto:CARRA@xxxxxxxxxx]
> Sent: 26 February 2007 16:13
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Processing Nested Lists
>
> Hi
>
> Does anybody know how do you process nodes within a tag that
> are nested to an undefined depth.
>
> I have a tag structure that looks like this:
>
> <TaxonomyEntries>
> - - -<TaxonomyNode> (1 to infinity)
> - - - - - -<Description />
> - - - - - -<TaxonomyNode /> (0 to infinity)
> - - -<TaxonomyNode>
> <TaxonomyEntries>
>
> And I have some XML that looks like this:
>
> <TopTag>
> <TaxonomyEntries>
> <TaxonomyNode name="Arbitrary Name"> -----Top
> Level Node
> <Description>any description</Description>
> <TaxonomyNode name="another name">
> <TaxonomyNode name="yet another name">
> <Description>any description</Description>
> <TaxonomyNode name="and yet another name">
> <Description>any description</Description>
> </TaxonomyNode>
> </TaxonomyNode>
> </TaxonomyNode>
> </TaxonomyNode>
> <TaxonomyNode name="Arbitrary Name"> -----Top
> Level Node
> <Description>any description</Description>
> <TaxonomyNode name="another name">
> <Description>any description</Description>
> </TaxonomyNode>
> </TaxonomyNode>
> </TaxonomyEntries>
> </TopTag>
>
> I need to apply a stylesheet (XSL v2.0) to this XML to create
> a Table in Word so that each Top Level TaxonomyNode is in a
> separate Table Row and the children and childrens-children
> are all nested accordingly with their descriptions displayed.
>
> <w:tbl>
> <w:tblPr>
> <w:tblGrid>
> <w:tr>
> <TaxonomyEntries>
> <w:tr>
> <w:tc>
> <w:p>
> <TaxonomyNode name="Arbitrary Name">
> <Description>
> <w:r>
> <w:t>any description</w:t>
> </w:r>
> </Description>
> <TaxonomyNode name="another name">
> <Description>
> <w:r>
> <w:t>any description</w:t>
> </w:r>
> </Description>
> <TaxonomyNode name="yet another name">
> <Description>
> <w:r>
> <w:t>any description</w:t>
> </w:r>
> </Description>
> <TaxonomyNode name="and yet another name">
> <Description>
> <w:r>
> <w:t>any description</w:t>
> </w:r>
> </Description>
> </TaxonomyNode>
> </TaxonomyNode>
> </TaxonomyNode>
> </TaxonomyNode>
> </w:p>
> </w:tc>
> </w:tr>
> <w:tr>
> <w:tc>
> <w:p>
> <TaxonomyNode name="Arbitrary Name">
> <Description>
> <w:r>
> <w:t>any description</w:t>
> </w:r>
> </Description>
> <TaxonomyNode name="another name">
> <Description>
> <w:r>
> <w:t>any description</w:t>
> </w:r>
> </Description>
> </TaxonomyNode>
> </TaxonomyNode>
> </w:p>
> </w:tc>
> </w:tr>
> </TaxonomyEntries>
> <w:tbl>
>
> Could any one give me some pointers on how to achieve this
> nesting. It seems to me that some sort of recursion is in
> order but I'm not sure how to implement it when there is no
> fixed depth to the nesting i.e there is no break-out parameter.
>
> Hopefully
> Andy
>
>
>
>
>
>
>
> Unless stated otherwise above:
> IBM United Kingdom Limited - Registered in England and Wales
> with number 741598.
> Registered office: PO Box 41, North Harbour, Portsmouth,
> Hampshire PO6 3AU
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Processing Nested Lists, Andy Carr1 | Thread | Re: [xsl] Processing Nested Lists, Adam Retter |
| [xsl] Processing Nested Lists, Andy Carr1 | Date | Re: [xsl] Processing Nested Lists, Adam Retter |
| Month |