|
Subject: Re: [xsl] Re: file manipulation with recursion From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Tue, 23 Jul 2002 15:29:42 +0100 |
Hi Rick,
> Thanks for all your help. I have a little twist to this file
> however. Under each category node there could be zero, one or many
> product nodes. I want to just display the id and name of the product
> node as well, and they can appear under any category node. The
> initial file format would be of the following...
Then apply templates to the product elements as well as the category
elements, and have a template for the product elements that creates a
product element with the name and id inside:
<xsl:template match="category">
<xsl:copy>
<xsl:copy-of select="id" />
<xsl:copy-of select="name" />
<xsl:apply-templates select="category | product" />
</xsl:copy>
</xsl:template>
<xsl:template match="product">
<xsl:copy>
<xsl:copy-of select="id" />
<xsl:copy-of select="name" />
</xsl:copy>
</xsl:template>
(You could probably actually combine these templates into:
<xsl:template match="category | product">
<xsl:copy>
<xsl:copy-of select="id" />
<xsl:copy-of select="name" />
<xsl:apply-templates select="category | product" />
</xsl:copy>
</xsl:template>
if you wanted.)
The general pattern in XSLT is that for each element in your XML you
have a template that shows how to map from that element to the element
that you want to create in the result.
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] Re: file manipulation wit, Holmberg Rick-ra0119 | Thread | [xsl] Dynamic XSL Sorting - Is ther, Robert . Franklin |
| RE: [xsl] Re: file manipulation wit, Holmberg Rick-ra0119 | Date | Re: [xsl] Grouping problem, Jeni Tennison |
| Month |