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

Moving (promoting) XML elements through XSL

Subject: Moving (promoting) XML elements through XSL
From: "Mark Peters" <flickrmeister@xxxxxxxxx>
Date: Thu, 29 Jun 2006 16:41:56 -0400
xsl software
Hi folks,

I'm trying to apply XSL to my input XML document to accomplish two tasks:

1. Promote the indexterm elements in my XML doc to the same level as
my title and body elements.
2. Wrap the indexterm element in additional elements.


Input XML:


<topic id="i267011">
     <title>
        <indexterm>Hardware Requirements</indexterm>
        <indexterm>Software Requirements</indexterm>Software Requirements
     </title>
     <body>
   ..
     </body>
</topic>


Output XML:


<topic id="i267011">
     <title>Software Requirements
     </title>
     <prolog>
         <metadata>
             <keywords>
                <indexterm>Hardware Requirements</indexterm>
                <indexterm>Software Requirements</indexterm>
             </keywords>
          </metadata>
      </prolog>
     <body>
   ..
     </body>
</topic>


Based on XSL I've studied in the archive, the FAQ, and in other lists, I created the following stylesheet, which *should* at least promote the indexterm elements (I haven't figured gotten as far as wrapping the indexterm elements yet):

<xsl:stylesheet xmlns:xsl=" http://www.w3.org/1999/XSL/Transform"
version=" 1.0">
   <xsl:output indent="yes"/>
   <xsl:template match="/topic">
       <xsl:copy>
           <xsl:copy-of select="/title/indexterm"/>
           <xsl:apply-templates select="@*|node()"/>
       </xsl:copy>
   </xsl:template>
   <xsl:template match="indexterm"/>
   <xsl:template match="@*|node()">
       <xsl:copy>
           <xsl:apply-templates select="@*|node()"/>
       </xsl:copy>
   </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>


When I apply the stylesheet to my input XML doc, my indexterm elements disappear.

Current result:

<topic id="i267011">
     <title>Software Requirements
     </title>
     <body>
   ..
     </body>
</topic>


I'd be grateful for any assistance.


Thanks in advance!

Mark

--

Mark Peters
Senior Technical Writer
Saba Software

--

Mark Peters
Senior Technical Writer
Saba Software

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-2011 All Rights Reserved.