[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Regex string function question

Subject: Re: Regex string function question
From: Miloslav Nic <nicmila@xxxxxxxxx>
Date: Wed, 24 Jan 2001 09:32:38 +0100
function of nic
Random thoughts :

<aaa>
  <bbb>123</bbb>
  <bbb>ZYX</bbb>
  <ccc>123</ccc>
  <date-time>a nice time was 2001-01-24T09:20:25<date-time>
</aaa>


Select all nodes containing a number :

<xsl:apply-templates select="//*[match-regexp(.,'\d')]"/>

=======================================================
All nodes with names starting with b or c:
<xsl:apply-templates 
     select="//*[match-regexp(name(),'\A[bc]')]"/>

===============================================================
Text nodes creation:
<xsl:apply-templates 
    
select="create-text-nodes-regexp(//date-time,'\s+(\d{4})-(\d{2})-(\d{2})T')"
     mode= "format-date" />

<xsl:template match="text()" mode="format-date">
   ...
  <xsl:when test="position()=1">Year: <xsl:value-of
select="."/></xsl:when>
  <xsl:when test="position()=2">Month: <xsl:value-of
select="."/></xsl:when>
  <xsl:when test="position()=3">Day: <xsl:value-of
select="."/></xsl:when>


Every word character from a string change to a text node if followed by
non-word character:

<xsl:apply-templates select="create-text-nodes-regexp('Hello, world! How
are you?','(\w)\W')"/>

Eric van der Vlist wrote:
> 
> Nic,
> 
> Miloslav Nic wrote:
> >
> > If it had my dream would come true.
> > But unfortunately they do not appear in XSLT 1.1 proposal.
> > What a pity.
> 
> It's also one of my dreams and I am sure we are not the only ones.
> 
> Why won't us put a prosal for a standardised extension ?
> 
> More precisly, my dream takes the form of functions taking a string (or
> a XPath expression ?) and a regular expression as parameters and
> returning a node set with the results.
> 
> Borowing an exemple from the PHP manual [1]:
> 
> preg_match_all("Call 555-1212 or 1-800-555-1212 or (612) 555-1313",
>         "/\(? (\d{3})? \)? (?(1) [\-\s] ) \d{3}-\d{4}/x")
> 
> would return a nodeset whose structure could be:
> 
> <matches>  <!-- maybe we don't need a document element here ? -->
>  <match>
>   <part>555-1212</part>
>  </match>
>  <match>
>   <part>1-800-555-1212</part>
>  </match>
>  <match>
>   <part>(612) 555-1313</part>
>  </match>
> </matches>
> 
> What do you think ?
> 
> Eric
> 
> [1] http://www.php.net/manual/en/function.preg-match-all.php
> 
> > --
> > ******************************************
> > <firstName> Miloslav </firstName>
> > <surname>   Nic      </surname>
> >
> > <mail>    nicmila@xxxxxxxxx    </mail>
> > <support> http://www.zvon.org  </support>
> > <zvonMailingList>
> >     http://www.zvon.org/index.php?nav_id=4
> > </zvonMailingList>
> --
> ------------------------------------------------------------------------
> Eric van der Vlist       Dyomedea                    http://dyomedea.com
> http://xmlfr.org         http://4xt.org              http://ducotede.com
> ------------------------------------------------------------------------
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

-- 
******************************************
<firstName> Miloslav </firstName>    
<surname>   Nic      </surname>     

<mail>    nicmila@xxxxxxxxx    </mail>   
<support> http://www.zvon.org  </support>
<zvonMailingList> 
    http://www.zvon.org/index.php?nav_id=4 
</zvonMailingList>

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.