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

Creating a container element for siblings which have

Subject: Creating a container element for siblings which have different start and end elements
From: "Michael Friedman sumarimike@xxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 29 Jan 2015 16:25:06 -0000
 Creating a container element for siblings which have
I have some XML which has certain elements Id like to move into a containing
element. Im having trouble.
The current XML is arranged this way:
<para>Planes have wings so they can <tech:revst
type="Airline"/>fly<tech:revend/> in the sky and get us to places wed like to
visit faster <tech:revst type="Airline"/>than if wed walked there.<caution>
<para>Please stay in the airplane at all
In this older method of indicating a revision markup area, <tech:revst/> is
used to indicate a start of a change and <tech:revend> is used to indicate the
end. There can be multiple instances of this revision markup anywhere,
surrounding text within elements, or surrounding multiple elements and text.
These containers produce change bars in PDF and background-color areas in
I am producing PDF and HTML output. In order to create a <span> or <div> in
HTML output, Id like to pre-process the XML to produce the following desired
XML output structure.
Desired output:
<para>Planes have wings so they can <tech:revst
type="Airline">fly</tech:revst><tech:revend/> in the sky and get us to places
wed like to visit faster <tech:revst type="Airline">than if wed walked
<para>Please stay in the airplane at all
Essentially, Id like to encapsulate the siblings between the <tech:revst/>
and <tech:revend/> into the <tech:revst>. The <tech:revend/> is left in for FO
Using XSLT 2.0, Ive been able to get the first <tech:revst> in a given
sibling structure partially handled. However, the remaining ones (in this
case) are omitted. Im using saxon 6 via our publishing app to do the heavy
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    <xsl:output method="xml" indent="no" doctype-public="-//Tech//DTD
FlightBook XML V4.0//EN" doctype-system="flightbook.dtd"/>

    <xsl:template match="/|*|comment()|processing-instruction()">
       <xsl:call-template name="do_copy"/>

    <xsl:template match="tech:revst">
            <xsl:element name="tech:revst">
                  <xsl:for-each select="@*">
                        <xsl:attribute name="{name(.)}">
                  <xsl:value-of select="."/>
                        <xsl:for-each select="@*">

      <xsl:template name="do_copy">
            <xsl:for-each select="@*">
The following is produced from this stylesheet:
<para>Planes have wings so they can <tech:revst type="Airline">fly in the sky
and get us to places wed like to visit faster than if wed walked
I found some useful suggestions on grouping on the dpawson.co.uk site, but
each one I tried didnt quite get me what I was looking for. In particular,
there was a Working with pairs of siblings that used sequences, but I still
couldnt get that to work when there were multiple <tech:revst/><tech:revend/>
pairs in a set of siblings.
Michael Friedman

Current Thread


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.
First Name
Last Name
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.