[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Moving (promoting) XML elements through XSL


Subject: Re: [xsl] Moving (promoting) XML elements through XSL
From: "Mark Peters" <flickrmeister@xxxxxxxxx>
Date: Fri, 30 Jun 2006 10:46:34 -0400

You've been a great help, David. I have one last question (for you or
the list), if you don't mind. I'm going to next my topic elements.

For example:

<?xml version="1.0"?>
<topic>
   <title>
      <indexterm>Software Requirements</indexterm>Software Requirements
   </title>
    <prolog>
          <metadata>
             <keywords>
                <indexterm>
                   <indexterm>Software Requirements</indexterm>
                </indexterm>
             </keywords>
          </metadata>
    </prolog>
   <body>
      <p>Some sample text</p>
   </body>

  <topic ..>
     ..
      <topic ..>
       ..
      </topic>
  </topic>
</topic>

How would I include the topic subnodes in my output?  Your suggestion
to process my title, insert prolog, and then process body, worked like
a charm for the input XML I gave you. But of course, my nested topic
elements don't appear in the output.

I tried adding a statement to select everything that wasn't a title,
indexterm, or body element (namely, the nested topic), but I either
encountered errors about inserting attributes after an element was
processed, or the apply-templates statement didn't make any difference
in the output.

<xsl:apply-templates select="@*"/>

Thanks,
Mark


process title, insert your prolog, then process body

so instead of

                       <prolog>
                       .....
                      </prolog>
                      <xsl:apply-templates select="node()"/>


do


                      <xsl:apply-templates select="title"/>
                       <prolog>
                       .....
                      </prolog>
                      <xsl:apply-templates select="body"/>

David


Current Thread
Keywords
xml