xsl-list
[Top] [All Lists]

Re: OT: request help with string-based/ RegEx problem

2004-04-01 03:18:40

  but also entities
  representing a character like this "∇" (up-turned
  delta)

Note that is not an entity reference but a numeric character reference.
In either case (character or entity reference) XSLT will not see the
reference as it is expanded by xml parser before xslt starts.


If you want to do this in xslt (rather than in ant about which I can't
say much)

So your requirent is just to spot one or two letter words.

The following is a "pseudo regex" expressing this idea:

if you used the XSLT2 draft (as implemented in saxon 7) you could use
such a regex directly.

In XSLT 1 the simplest is first to tokenize your input string based on
white space (extensions such as saxon:tokenize  help here oir use a
recursive template as often posted to this list or in Dimitre's fxsl
library)

The context would be trivial to specify in xslt as you'd just call this
tokenizing code from a suitable template matching the elements where you
want to do the search.

so using saxon:tokenize it would just be something like

<xsl:template match="xref">
<xref>
<xsl:copy-of select="@*"/>
<xsl:for-each select="saxon:tokenize(.)">
 <xsl:choose>
   <xsl:when test="string-length(.) &lt;3"><sym><xsl:value-of 
select="."/></sym></xsl:when>
   <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
 M/xsl:choose>
<xsl:text> </xsl:text>
</xsl:for-each>
</xref>
</xsl:template>

David

-- 
http://www.dcarlisle.demon.co.uk/matthew

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________


<Prev in Thread] Current Thread [Next in Thread>