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

Re: Breaking paragraphs one linebreaks

Subject: Re: Breaking paragraphs one linebreaks
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 9 May 2019 21:06:36 -0000
Re:  Breaking paragraphs one linebreaks
Am 09.05.2019 um 22:16 schrieb Martin Honnen martin.honnen@xxxxxx:
Am 09.05.2019 um 21:55 schrieb Martin Honnen martin.honnen@xxxxxx:
Am 09.05.2019 um 21:42 schrieb Manuel Souto Pico terminolator@xxxxxxxxx:

@Martin, your example works really well. I had to edit the expression,
as in my real files sometimes they have used lists instead of

<xsl:param name="lb"

However, I can see what I would also need to split at the end of
sentences when there's no escaped tag but just final punctuation. To
avoid the transformation eating the punctuation, I have tried with a
lookbehind assertion but it seems it's not supported:

<xsl:param name="lb"

Any ideas?

In general, if there is markup, it might be better to try to parse it, in your initial sample you seemed to have simple HTML empty element syntax with <br> elements, now with the adapted regular expression it seems you expect opening and closing tags.

If you know the escaped markup is an XML fragment then I would try to
parse it with the "parse-xml-fragment" function, if it is HTML, then I
would look into using David Carlisle's HTML parser implementation done
in pure XSLT 2 or use an extension function like the commercial editions
of Saxon offer.

For HTML parsing with the XSLT based HTML parser (https://github.com/davidcarlisle/web-xslt/blob/master/htmlparse/htmlparse.xs l) it would look like

B <xsl:import href="https://github.com/davidcarlisle/web-xslt/raw/master/htmlparse/htmlpars e.xsl"/>

B  <xsl:template match="tu">
B B B B B  <xsl:variable name="split">
B B B B B B B B B  <xsl:apply-templates mode="split"/>
B B B B B  </xsl:variable>
B B B B B  <xsl:for-each-group select="$split/tuv/seg" group-by="position()
mod count($split/tuv[1]/seg)">
B B B B B B B B B  <tu tuid="{position()}">
B B B B B B B B B B B B B  <xsl:apply-templates
B B B B B B B B B  </tu>
B B B B B  </xsl:for-each-group>
B  </xsl:template>

B <xsl:mode name="split" on-no-match="shallow-copy"/>

B  <xsl:template match="seg" expand-text="yes" mode="split">
B B B B B  <xsl:for-each-group select="d:htmlparse(., '', true())/node()"
B B B B B B B B B  <xsl:if test=". instance of text()">
B B B B B B B B B B B  <seg>{.}</seg>
B B B B B B B B B  </xsl:if>
B B B B B  </xsl:for-each-group>
B  </xsl:template>


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.