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

RE: Could not use matches in Regular Expression (XSLT

Subject: RE: Could not use matches in Regular Expression (XSLT 2.0)
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sat, 1 May 2010 15:12:10 +0100
RE:  Could not use matches in Regular Expression (XSLT
I find it hard to believe that this stylesheet delivered anything other than
an error: the regular expression needs to be in quotes (as a string literal)
and it's also missing an opening square bracket. If you want the 4 to be at
the start, you should also anchor it to the start: matches(., '^4[0-9]{6}')

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 


> -----Original Message-----
> From: Jack Bush [mailto:netbeansfan@xxxxxxxxxxxx] 
> Sent: 01 May 2010 14:56
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Could not use matches in Regular Expression (XSLT 2.0)
> 
> Hi Forum members,
> 
> I
> am new to XSLT 2.0 and would like to do the following basic 
> numeric string pattern matching using regular expression:
> 
> <xsl:template match="ns:p[ns:strong='Telephones:']">
>   <xsl:choose>
>     < -- If global parameter $TELEPHONE_AREA_CODE equals to 
> FAIRYLAND -->
>     <xsl:when test="$TELEPHONE_AREA_CODE = ''FAIRYLAND">
>       <xsl:for-each select="ns:a">
>       <-- Only accept the phone number that starts with 4 
> follow by six digits....   ---> 
>         <xsl:if test="matches(.,4[0-9][0-9][0-9]0-9][0-9][0-9])">
>           <phone_number><xsl:value-of select='.'/></phone_number>
>         </xsl:if>
>       </xsl:for-each>/>
>   ......
> 
> However, it is picking up phone numbers starting with 1 
> instead. Also tried the starts-with() with the same outcomes.
> 
> I am using JDK1.6.19, Netbeans 6.7, JDOM 1.1, Saxon 9.1 on Windows XP.
> 
> Your assistance would be much appreciated.
> 
> Thanks in advance,
> 
> Jack

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.