xml editor

Supported platforms

Compatible with Windows7 & Mac OS X Snow Leopard

Ready for data server software
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] How to split mixed content


Subject: [xsl] How to split mixed content
From: Jesper Tverskov <jesper@xxxxxxxxxxx>
Date: Sun, 15 Feb 2009 12:46:03 +0100

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
Keywords
XML Editor | XML Author | WYSIWYG Editors | Schema Editor | XSD Documentation | XSL/XSLT Editor | XQuery | XML Databases | SVN Client
© 2002-2011 SyncRO Soft Ltd. All rights reserved. | Sitemap | Privacy Policy | This website was created & generated with <oXygen/>®XML Editor