xsl-list
[Top] [All Lists]

Re: [xsl] Very simple? Text processing from document data

2008-07-30 05:32:02
<p>Some body <b>text</b> some more</p>

And I want to replace the word 'body' only in the text of <p> but ignore
text in <b> so I've been looking at something like this:

<xsl:template match="p">
  <p>
       <xsl:value-of select="substring-before(./text(), 'body')"/>
       <xsl:value-of select="'replace_body'"/>
       <xsl:value-of select="substring-after(./text(), 'body')"/>
  </p>
</xsl:template>

How do I separately select #text before, between and after an arbitrary
number of interruptions (could be tables, images etc) and process those
interruptions in document order?

Use:

<xsl:template match="p/text()">
  <xsl:analyze-string......

instead of your <p> matching template.

If you are stuck with 1.0, then you'll have to use a recursive named
template to process the string.

cheers
-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

--~------------------------------------------------------------------
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>
--~--