[Home] [By Thread] [By Date] [Recent Entries]


Title: matching text with regexp in xpath
I don't know if Xalan does it yet, but it should be straightforward to plug in regexp support, either from Apache's regexp (I forget its name) or even JDK 1.4's.
 
As a minimal approach it might be interesting to build some regexp based on XSLT's inbuilt string manipulating/matching functionality, things like your examples should already be possible (but don't look nice), i.e. modularise stuff like : 
 
  <xsl:variable name="thing" select=./@this:whatever />
 
<xsl:choose>
 
<xsl:when test="contains($thing))">
   <xsl:call-template name="gotdatting"/>    
</xsl:when>
 
<xsl:otherwise>                   
</xsl:otherwise>
 
</xsl:choose>
</xsl:template>
 

---
Danny Ayers
<stuff> http://www.isacat.net/ </stuff>

Idea maps for the Semantic Web
http://ideagraph.net/

-----Original Message-----
From: Wannheden, Knut [mailto:knut.wannheden@p...]
Sent: 08 August 2002 11:33
To: xml-dev@l...
Subject: matching text with regexp in xpath

Hi,

I was wondering if anybody knows of an extension function to XPath which allows me to match text and attribute values in XML documents against regular expressions.  I'd like to be able to write something like:

        /a/b[re:match(@c, '{.}')]

to match all elements where an attribute has a value matching the regexp {.} (AVT) or:

        /a/b/@c[re:match(., '{.}')]

to match the attribute elements themselves.

If there isn't such a thing yet I imagine it shouldn't be to hard to write.  Can somebody give me some hints/directions on how to get started with this?

Thanks,

--
knut


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member