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

How to split mixed content

Subject: How to split mixed content
From: Jesper Tverskov <jesper@xxxxxxxxxxx>
Date: Sun, 15 Feb 2009 12:46:03 +0100
 How to split mixed content
I'm looking for a way to split mixed content. Something like the
tokenize() function but for mixed content. Let us say inside a "p"
element containing escaped markup, real XHTML like "span" elements and
"br" elements.

I want to use the "br" element as splitter.

I have come up with the following solution that seems to work.

    <xsl:template match="p">
        <lines>
            <xsl:for-each-group select="node()" group-starting-with="br">
                <xsl:if test="position() = 1">
                    <line><xsl:copy-of select="current-group()"/></line>
                </xsl:if>
                <xsl:if test="position() > 1">
                <line><xsl:copy-of select="current-group() except  ."/></line>
                  </xsl:if>
            </xsl:for-each-group>
        </lines>
    </xsl:template>

Here is my question:

Is my solution the way to split mixed content or is there an easier or
a more elegant way?


Cheers,
Jesper Tverskov

http://www.xmlkurser.dk
http://www.xmlplease.com

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.