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

RE: Can you break one node tree into two?

Subject: RE: Can you break one node tree into two?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 31 Jan 2005 23:48:52 -0000
break one
Try:

<xsl:template match="RootEle">
  <xsl:variable name="a" select="Letter/Address"/>
  <RootEle>
    <Letter>
      <xsl:copy-of select="$a | $a/preceding-sibling::*"/>
    </Letter>
  <RootEle>
  <RootEle>
    <Letter>
      <xsl:copy-of select="$a/following-sibling::*"/>
    </Letter>
  <RootEle>
</xsl:template>
 
Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Wilde Rebecca L SSgt HQ SSG/STS 
> [mailto:Rebecca.Wilde@xxxxxxxxxxxxx] 
> Sent: 31 January 2005 21:36
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Can you break one node tree into two?
> 
> Hello,
> 
> I'm trying to take some XML such as:
> 
> <RootEle xmlns="">
>   <Letter>
>       <From/>
>       <To/>
>       <Address/>
>       <Subject/>
>       <Body/>
>   </Letter>
> </RootEle>
> 
> And I would like my XSLT to output:
> 
> <RootEle xmlns="">
>    <Letter>
>        <From/>
>        <To/>
>        <Address/>
>    </Letter>
> </RootEle>
> <RootEle xmlns="">
>     <Letter>
>         <Subject/>
>         <Body/>
>     </Letter>
> </RootEle>
> 
> Basically I want to say as soon as I see the Address node I want to
> break it out and everything above it into one node tree and everything
> below it into a second node tree.  The nodes could be anything, but if
> an Address node is passed to me, I need to break the node 
> tree into two.
> 
> I am think I need to do something with the xsl:copy-of and the
> xsl:for-each, but my xslt knowledge is very limited and attempting to
> use this is not creating anything near what I had hoped for.
> 
> If it isn't possible to return two node trees (which I suspect it
> isn't),  how would I make it look like: <NewRoot>
>   <RootEle xmlns="">
>     <Letter>
>        <From/>
>        <To/>
>        <Address/>
>     </Letter>
>   </RootEle>
>   <RootEle xmlns="">
>     <Letter>
>         <Subject/>
>         <Body/>
>     </Letter>
>   </RootEle>
> </NewRoot>
> 
> Thank you,
> Becky

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.