Subject: Re: [xsl] Wrapping around textual and element node at the same time From: "Imsieke, Gerrit, le-tex" <gerrit.imsieke@xxxxxxxxx> Date: Thu, 09 Sep 2010 10:59:15 +0200 |
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:saxon="http://saxon.sf.net/" version="2.0" exclude-result-prefixes="saxon xs" >
<xsl:output method="xml" indent="yes" saxon:suppress-indentation="seg" />
<xsl:template match="@* | *" mode="#all"> <xsl:copy> <xsl:apply-templates select="@* | node()" mode="#current"/> </xsl:copy> </xsl:template>
<xsl:template match="text()" mode="insert-sep"> <xsl:analyze-string select="." regex="\s+"> <xsl:matching-substring> <sep/> </xsl:matching-substring> <xsl:non-matching-substring> <xsl:value-of select="." /> </xsl:non-matching-substring> </xsl:analyze-string> </xsl:template>
Dear All,
I am trying to wrap around words in a paragraph which looks like this.
<text><p><gliph>T</gliph>his is a very short parapraph.<gliph>I</gliph>t is also tricky.</p> </text>
The result what I would like, should look like this.
<text> <p> <seg><gliph>T</gliph>his</seg> <seg>is</seg> <seg>a</seg> <seg>very</seg> <seg>short</seg> <seg>parapraph.</seg> <seg><gliph>I</gliph>t</seg> <seg>is</seg> <seg>also</seg> <seg>tricky.</seg> </p> </text>
For wrapping around all words I use this template.
<xsl:template match="text/p/text()">
<xsl:analyze-string select="." regex="\w+">
<xsl:matching-substring>
<seg><xsl:value-of select="."/></seg>
</xsl:matching-substring> <xsl:non-matching-substring> <xsl:value-of select="."/> </xsl:non-matching-substring> </xsl:analyze-string> </xsl:template>
However, this template wraps around only the textual nodes but cannot do this:
<seg><gliph>T</gliph>his</seg>.
Is there any way to wrap around a textual node and an element node together?
Or should I do the wrapping first and then moving the gliph element later?
Thanks,
Gabor
-- Gerrit Imsieke Geschdftsf|hrer / Managing Director le-tex publishing services GmbH Weissenfelser Str. 84, 04229 Leipzig, Germany Phone +49 341 355356 110, Fax +49 341 355356 510 gerrit.imsieke@xxxxxxxxx, http://www.le-tex.de
Registergericht / Commercial Register: Amtsgericht Leipzig Registernummer / Registration Number: HRB 24930
Geschdftsf|hrer: Gerrit Imsieke, Svea Jelonek, Thomas Schmidt, Dr. Reinhard Vvckler ---------------------------------------------------------------------- Besuchen Sie uns auf der Frankfurter Buchmesse in Halle 4.2, Stand G446.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Wrapping around textual and e, Gábor Tóth | Thread | Re: [xsl] Wrapping around textual a, Imsieke, Gerrit, le- |
[xsl] Wrapping around textual and e, Gábor Tóth | Date | Re: [xsl] Wrapping around textual a, Imsieke, Gerrit, le- |
Month |