Israel Viente wrote:
I have another question regarding this.
I want to be able to control the valid ending paragraph characters
from a config file in xml.
How can I read the set [.?"!] from an external xml? - say something like:
<ParagraphTerminator>
<Char>.</Char>
<Char>?</Char>
<Char>"</Char>
<Char>!</Char>
</ParagraphTerminator>
or any other xml representation that will be easy to read as the set
in the regular expression.
You can do that by pulling in that document with the doc function and
building the regular expression:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xpath-default-namespace="http://www.w3.org/1999/xhtml"
version="2.0">
<xsl:output method="xhtml"/>
<xsl:variable name="chars"
select="string-join(doc('chars.xml')/ParagraphTerminator/Char, '')"
xpath-default-namespace=""/>
<xsl:variable name="re1" select="concat('[', $chars, ']$')"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="p[span[(_at_)class ne 'chapter'] and
not(matches(span[(_at_)class ne 'chapter'][last()], $re1))]">
<xsl:copy>
<xsl:apply-templates select="@* | node() |
following-sibling::p[1]/node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="p[preceding-sibling::p[1][span[(_at_)class ne
'chapter'] and not(matches(span[(_at_)class ne 'chapter'][last()], $re1))]]"/>
</xsl:stylesheet>
There are however certain characters like '-' that would need to be
escaped. That applies to both solutions but is easier to forget and
overlook if the characters are read in from a file.
--
Martin Honnen
http://msmvps.com/blogs/martin_honnen/
--~------------------------------------------------------------------
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>
--~--