This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: flatten XML tree


<xsl:for-each select="//article">
  <xsl:copy-of select="*"/>
  <xsl:copy-of select="ancestor::issue/number"/>
  <xsl:copy-of select="ancestor::issue/topic">
</xsl:for-each>

Michael Kay
Software AG
home: Michael.H.Kay@ntlworld.com
work: Michael.Kay@softwareag.com

> -----Original Message-----
> From: owner-xsl-list@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Robert
> Sösemann
> Sent: 18 March 2002 16:20
> To: xsl-list@lists.mulberrytech.com
> Subject: [xsl] flatten XML tree
>
>
> Hello,
>
> how can I flatten my XML like that?
>
> This is the source:
>
> <archive>
>     <issue>
>         <number>2</number>
>         <topic>Genetic Diseases</topic>
>         <articles>
>             <article>
>                 <title>The magic of DNA</title>
>                 <author>Ronald Mueller</author>
>                 <keywords>genetics,dna</keywords>
>             </article>
>             <article>
>                 <title> DNA demystified</title>
>                 <author>Arnold Breed</author>
>                 <keywords>genetics,dna</keywords>
>             </article>
>             *many articles*
>         </articles>
>     </issue>
>     *many magazines*
> </archive>
>
> and I want:
>
> <archive>
>             <article>
>                 <number>2</number>
>                 <topic>Genetic Diseases</topic>
>                 <title>The magic of DNA</title>
>                 <author>Ronald Mueller</author>
>                 <keywords>genetics,dna</keywords>
>             </article>
>             <article>
>                 <number>2</number>
>                 <topic>Genetic Diseases</topic>
>                 <title> DNA demystified</title>
>                 <author>Arnold Breed</author>
>                 <keywords>genetics,dna</keywords>
>             </article>
>     *many articles*
> </archive>
>
> All that I want to define is that I only want the root and an
> amount of
> article nodes.
> The children of article can stay as they are.
> All ancestors like number and topic that semantically belong
> also to an
> article schould became direct childs of article.
>
> Would that be possible? And could this even be undone?
>
> Thanks in advance.
>
> Rob
> ..............................................................
> ..............
> ..........
>  ROBERT SÖSEMANN  (robert.soesemann@web.de)
>
>  schwärzlocherstr. 29/1 | 72070 tübingen
>  tel : 07071 / 400 880
>
>  icq# : 100 467 870
>  pgp-keys : www.webspace-journey.de/pgp.asc
> ..............................................................
> ..............
> ..........
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]