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

RE: regex in XSLT 2.0: problems with XPath

Subject: RE: regex in XSLT 2.0: problems with XPath
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 13 Feb 2009 16:40:46 -0000
RE:  regex in XSLT 2.0: problems with XPath
The XPath parser has seen an expression beginning with "<". There are no
expressions beginning with this character in XPath, only in XQuery, hence
the error message.

Your regular expression needs to be in quotes, for example <xsl:if
test="matches($x, '&lt;\[')">

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



> -----Original Message-----
> From: Manuel Souto Pico [mailto:manuel.souto@xxxxxxxxxxxxxx]
> Sent: 13 February 2009 16:23
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  regex in XSLT 2.0: problems with XPath
>
> Hi again,
>
> I was glad to find out that XSLT 2.0 supports regular
> expressions (although I was surprised they weren't supported
> already in 1.0). I'm trying to use them to capture some
> element if its contents match some expression.
>
> It seems that I need to use XSLT 2.0, so I believe I must
> change the definition in the XSLT document (see 2nd line in
> the preamble of my doc just below) as well as the processor
> version (I used Saxon 6.5.5. with XSLT 1.0, now I've chosen
> Saxon-SA 9.1.0.3). I do all of this in oXygen 10 and I
> haven't done anything else to use XSLT 2.0.
>
> <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet
> version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>     <xsl:output method="xml" version="1.0" encoding="UTF-8"
> indent="yes" />
> (...)
>
> The area of code where I want to use regular expressions look
> like (using the syntax matches(elem, expr):
>
>                                 <xsl:for-each
> select="../category[@domain='tag'][@nicename]">
>                                     <xsl:if
> test="matches(../category[@domain='tag'][@nicename],
> &lt;!\[CDATA\[economia\]\]&gt;)">
>                                         <descrip type='subjectfield'>
>                                             <xsl:value-of
> select="../category[@domain='tag'][@nicename]"/>
>                                         </descrip>
>                                     </xsl:if>
>                                 </xsl:for-each>
>
> However, when I run the debugger, I get this error message:
>
>     SystemID: vds2tbx.xsl
>     Description: Failed to compile stylesheet. 1 error detected.
>
>     SystemID: vds2tbx.xsl
>     Location: 37:0
>     Description: XPath syntax error at char 47 on line 37 in
>     {...y[@domain='tag'][@nicename]...}:
>         Node constructor expressions are allowed only in
> XQuery, not in
>     XPath
>     URL: http://www.w3.org/TR/xpath20/#ERRXPST0003
>
> Googling that error I couldn't find any useful pages, so I am
> quite stuck. What am I doing wrong? Am I using the old
> version of XPath?
>
> I hope my questions are interesting for the list!
> Regards, Manuel
>
> --
> Manuel Souto Pico
> Terminslogo / Responsable de servicio ticnico
>
> *STAR Servicios Ling|msticos, SL*
> C. Sardenya, 195-197 (baixos)
> E-08013 Barcelona
> Tel. +34 932 440 881
> Fax: +34 932 471 273
>
> manuel.souto@xxxxxxxxxxxxxx <mailto:manuel.souto@xxxxxxxxxxxxxx>
> http://www.star-spain.com

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.