[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: grouping elements under a new single parent elemen

Subject: RE: grouping elements under a new single parent element
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 11 Dec 2008 09:23:01 -0000
RE:  grouping elements under a new single parent elemen
Try this:

<xsl:template match="author-group">
  <author-group>
    <authors>
      <xsl:apply-templates select="author"/>
    </authors>
    <xsl:apply-templates select="*[not(self::author)]"/>
  </author-group>
</xsl:template> 

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

> -----Original Message-----
> From: arut che [mailto:arutche@xxxxxxxxx] 
> Sent: 11 December 2008 05:34
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  grouping elements under a new single parent element
> 
> Hi all,
>   I am new to appl xslt/xml conversion,
> 
> I want to club multiple elements to a cluster and become 
> childs of a new parent element.
> 
> Input is :
> 
> <author-group>
> <author>
>   <given-name>A.N.</given-name>
>   <surname>Chiardfsf</surname>
>   <cross-ref refid="aff1">
>    <sup>a</sup>
>   </cross-ref>
>   <cross-ref refid="cor1">
>    <sup>wkqwj<sup>
>   </cross-ref>
>   <e-address type="email">asd@xxxxxxxxxx</e-address>
>  </author>
>  <author>
>   <given-name>L.J.</given-name>
>   <surname>Tfwqqf</surname>
>   <cross-ref refid="aff1">
>    <sup>a</sup>
>   </cross-ref>
>  </author>
>  <author>
>   <given-name>W.F.</given-name>
>   <surname>Eqwfq</surname>
>   <cross-ref refid="aff2">
>    <sup>b</sup>
>   </cross-ref>
>  </author>
> <affiliation id="aff1">
>   <label>a</label>
>   <textfn>zsg Divisionsdfgsfg, sgs</textfn>  </affiliation>  
> <affiliation id="aff2">
>   <label>b</label>
>   <textfn>DGD, USA</textfn>
>  </affiliation>
>  <correspondence id="cor1">
>   <label>rewt</label>
>   <text>Corresponding author. Tel:MKKWE W QWQWE</text>  
> </correspondence> </author-group>
> 
> 
> I want to club all "author" elements and need to placed under 
> a parent "authors" as follows:
> 
> 
> required output:
> 
> 
> <author-group>
> <authors>
>  <author>
>   <given-name>A.N.</given-name>
>   <surname>Chiardfsf</surname>
>   <cross-ref refid="aff1">
>    <sup>a</sup>
>   </cross-ref>
>   <cross-ref refid="cor1">
>    <sup>wkqwj<sup>
>   </cross-ref>
>   <e-address type="email">asd@xxxxxxxxxx</e-address>
>  </author>
>  <author>
>   <given-name>L.J.</given-name>
>   <surname>Tfwqqf</surname>
>   <cross-ref refid="aff1">
>    <sup>a</sup>
>   </cross-ref>
>  </author>
>  <author>
>   <given-name>W.F.</given-name>
>   <surname>Eqwfq</surname>
>   <cross-ref refid="aff2">
>    <sup>b</sup>
>   </cross-ref>
>  </author>
> </authors>
>    <affiliation id="aff1">
>   <label>a</label>
>   <textfn>zsg Divisionsdfgsfg, sgs</textfn>  </affiliation>  
> <affiliation id="aff2">
>   <label>b</label>
>   <textfn>DGD, USA</textfn>
>  </affiliation>
>  <correspondence id="cor1">
>   <label>rewt</label>
>   <text>Corresponding author. Tel:MKKWE W QWQWE</text>  
> </correspondence> </author-group>
> 
> 
> Regards
> Aruthce

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.