[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Chad Chelius wrote:
Write a template for the parent element of those 'body' elements. Assuming it is named 'foo'
<xsl:template match="foo">
<field name="body">
<xsl:apply-templates select="body"/>
</field>
</xsl:template>
<xsl:template match="body">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
If the 'foo' element has further children and you want to process them as well then you need to do that in the match="foo" template but obviously it depends on what you want to do with those elements exactly.
--
Re: [xsl] Grouping multiple tags into one parent tag
Subject: Re: [xsl] Grouping multiple tags into one parent tag From: Martin Honnen <Martin.Honnen@xxxxxx> Date: Sun, 15 Feb 2009 19:02:00 +0100 |
Chad Chelius wrote:
I have xml with a section structured like this:
<body>content here</body> <body>content here</body> <body>content here</body>
I'd like to change all of the body elements to <p> tags and group all of those original body elements (now <p> tags) into a parent element.
Write a template for the parent element of those 'body' elements. Assuming it is named 'foo'
<xsl:template match="foo">
<field name="body">
<xsl:apply-templates select="body"/>
</field>
</xsl:template>
<xsl:template match="body">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
If the 'foo' element has further children and you want to process them as well then you need to do that in the match="foo" template but obviously it depends on what you want to do with those elements exactly.
--
Martin Honnen http://JavaScript.FAQTs.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Grouping multiple tags in, G. Ken Holman | Thread | Re: [xsl] Grouping multiple tags in, G. Ken Holman |
Re: [xsl] Grouping multiple tags in, G. Ken Holman | Date | Re: [xsl] Grouping multiple tags in, G. Ken Holman |
Month |
Keywords