RE: [xsl] Grouping multiple tags into one parent tag

Subject: RE: [xsl] Grouping multiple tags into one parent tag
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sun, 15 Feb 2009 18:22:10 -0000
You can't do this grouping in the template rule for body elements, because
that template is only processing one body element at a time. It needs to be
done in template rule for the parent element. And the way you do it depends
on whether that parent element contains other things besides body elements.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Chad Chelius [mailto:cchelius@xxxxxxxxxx] 
> Sent: 15 February 2009 17:55
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Grouping multiple tags into one parent tag
> 
> 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.
> 
> I've been using
> 
>    <xsl:template match="body">
>         <field name="body">
>             <xsl:apply-templates/>
>         </field>
> 
> because the parent element needs to be <field name="body"> 
> but each original body element needs to be converted to <p> tags.
> 
> Can anyone assist me with this?
> 
> 
> 
> 
> chad

Current Thread