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

RE: differences between xsl:analyze-string and XPath2.

Subject: RE: differences between xsl:analyze-string and XPath2.0 matches()?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 29 Sep 2009 18:32:02 +0100
RE:  differences between xsl:analyze-string and XPath2.
The regex attribute of xsl:analyze-string is an AVT. If the actual regex is
in a variable, you want

regex="{$feature.regex}"

Regards,

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

> -----Original Message-----
> From: Georges Schmitz [mailto:georges.schmitz@xxxxxxxxx] 
> Sent: 29 September 2009 17:59
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  differences between xsl:analyze-string and 
> XPath2.0 matches()?
> 
> I just can't get it working. I test an expression with 
> matches() before switching over to xsl:analyze-string and 
> both don't seem to match the same regex. The expression that 
> is tested is provided via the function parameter $exp and 
> contains "Feature(CM_USE_PROVINCE)=TRUE".
> 
> Are they supposed to behave differently? Because I run into 
> the non matching part with debug output as following:
> 
> > the non matching string is |Feature(CM_USE_PROVINCE)=TRUE|
> >             and doesn't match 
> > [Feature\((CM_USE_PROVINCE)\)=(TRUE|FALSE)]
> 
> 
> Thanks for any help,
> Georges
> 
> PS
> maybe I should say that I'm using
> Saxon 9.1.0.2J from Saxonica
> Java version 1.6.0_15
> 
> =======================================
> 
> <xsl:function name="proff:evaluate-globalsetup" as="xs:boolean">
>   <xsl:param name="exp" as="xs:string"/>
> 
>   <!-- CM_USE_PROVINCE will be replaced by another real regex 
> component -->
>   <xsl:variable
> name="feature.regex">Feature\((CM_USE_PROVINCE)\)=(TRUE|FALSE)
> </xsl:variable>
>   ...
>   <xsl:variable name="customer.configs" 
> select="gs:get-customer-configs($customer.setup, 
> $global.config.sets)"/>
>   <xsl:choose>
>     <xsl:when test="matches($exp, $feature.regex)">
>       <xsl:analyze-string select="$exp" regex="$feature.regex">
>         <xsl:matching-substring>
>           <xsl:if test="$debug gt 0">
>             <xsl:message>  checking for <xsl:value-of 
> select="$exp"/> found:
>             feature  name: <xsl:value-of select="regex-group(1)"/>
>             feature value: <xsl:value-of select="regex-group(2)"/>
>             </xsl:message>
>           </xsl:if>
>           <xsl:copy-of select="if ($customer.configs//config-item[
>                                           @name='Feature' and
>                                           @gen:usecase-enum = 
> regex-group(1)
>                                     ]/param = regex-group(2))
>                                 then true()
>                                 else false()"/>
>         </xsl:matching-substring>
>         <xsl:non-matching-substring>
>             <xsl:message>the non matching string is 
> |<xsl:value-of select="."/>|
>             and doesn't match [<xsl:value-of 
> select="$feature.regex"/>]
>             </xsl:message>
>         </xsl:non-matching-substring>
>       </xsl:analyze-string>
>     </xsl:when>
>     <xsl:when test="matches($exp, $lang.setting.regex)"> ...
>     </xsl:when>
>     <xsl:otherwise>
>       <xsl:message terminate="yes"> $$$ ERROR $$$
>       you are trying to have
>       "<xsl:value-of select="$exp"/>"
>       as a global setup condition, but this doesn't match
>       "<xsl:value-of select="$feature.regex"/>"
>       </xsl:message>
>     </xsl:otherwise>
>   </xsl:choose>
> </xsl:function>
> **************************************************************
> ********************************
> IMPORTANT NOTICE / WICHTIGER HINWEIS
> This communication contains information which is confidential 
> and may also be privileged. It is for the exclusive use of 
> the intended recipient(s). If you are not the intended 
> recipient(s) please note that any distribution, copying or 
> use of this communication or the information in it is 
> strictly prohibited. If you have received this communication 
> in error please notify us immediately by email or by 
> telephone and then delete this email and any copies of it.
> Diese E-Mail koennte vertrauliche und/oder rechtlich 
> geschuetzte Informationen enthalten. Wenn Sie nicht der 
> richtige Adressat sind oder diese E-Mail irrtuemlich erhalten 
> haben, informieren Sie bitte sofort den Absender und 
> vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die 
> unbefugte Weitergabe dieser Mail sind nicht gestattet.
> 
> HEITEC AG, Werner-von-Siemens-Str. 61, 91052 Erlangen, HRB 
> 7754, RG Fuerth, Vorstandsvorsitzender: 
> Richard Heindl, Vorstand: Harald Preiml, Finanzvorstand: 
> Rene-Oliver Rosner, Aufsichtsratsvorsitzender: Dr. 
> Lorenz M. Raith, WWW: http://www.heitec.de

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.