|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: manipulating text and not losing elements
> But what happens in the scenario where I want to remove the numbers
> right after the indent1 and paragraph tags, as far as I can see the
> only way to accomplish this is with substring, but using a substring
> requires outputting using <xsl:value-of> which negates all following
> children. Ultimately I would like the line tagged as <indent1> to
> read the following:
What you need to remember is that text is a node type, like any other.
So you can match on text(), and furthermore you can qualify the match
to strings with numbers in front of them, etc. The example below
shows a crude example of matching on text() and removing the first few
chars. There are other ways of modifying the string, but I'm not sure
what your text model is, and this reflects your original solution. :)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="indent1">
<p class="indent1">
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="italic">
<em>
<xsl:apply-templates/>
</em>
</xsl:template>
<xsl:template match="bold">
<strong>
<xsl:apply-templates/>
</strong>
</xsl:template>
<xsl:template match="text()[matches(., '\d+ .+')]">
<xsl:value-of select="substring(., 6)"></xsl:value-of>
</xsl:template>
</xsl:stylesheet>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
James A. Robinson jim.robinson@xxxxxxxxxxxx
Stanford University HighWire Press http://highwire.stanford.edu/
+1 650 7237294 (Work) +1 650 7259335 (Fax)
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








