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

Re: Move a section in XSL

Subject: Re: Move a section in XSL
From: "Bob DuCharme" <bob@xxxxxxxxx>
Date: Thu, 31 May 2001 16:11:31 -0400
xsl move
>I want to move the SUPPLIER section into the ARTICLE section and leave the
rest as it is. Please tell me
>how to do this ?

(After seeing your posting on xml-dev and then opening with a comment about
how xsl-list is a better place for XSL(T) stylesheet issues, I now see that
you cc'd your posting to xsl-list. I don't see any answer there yet, so I'll
forge ahead.)

One problem is that your XML couldn't be valid: the DOCTYPE declaration said
that the document element was ARTICLE, but the SUPPLIER element came before
the ARTICLE element. The document element has to enclose everything else.

To process it, you could do this: remove the DOCTYPE declaration and add
some other element (I'll call it TEMP) around the whole thing to make it
well-formed. The stylesheet below should then do what you need. I tried to
comment it a lot.

Bob DuCharme            www.snee.com/bob             <bob@
snee.com>      see http://www.snee.com/bob/xsltquickly for
info on upcoming "XSLT Quickly" from Manning Publications.


<!-------- beginning of stylesheet ------------->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      version="1.0">

  <xsl:template match="TEMP">
     <!-- Assumes that TEMP's only children are SUPPLIER and ARTICLE.
          Process ARTICLE child but not SUPPLIER child. -->
     <xsl:apply-templates select="ARTICLE"/>
  </xsl:template>

  <xsl:template match="ARTICLE">
    <ARTICLE xml:lang="en">
      <!-- Put SUPPLIER sibling after ARTICLE start
           tag, then ARTICLE's other children.        -->
      <xsl:apply-templates select="../SUPPLIER"/>
      <xsl:apply-templates/>
    </ARTICLE>
  </xsl:template>

  <!-- Copy any nodes not covered above. -->
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>


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


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.