xsl-list
[Top] [All Lists]

[xsl] How to split mixed content

2009-02-15 06:46:33
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>