Subject: RE: [xsl] differences between xsl:analyze-string and XPath2.0 matches()? From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Tue, 29 Sep 2009 18:32:02 +0100 |
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: [xsl] 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] differences between xsl:a, Georges Schmitz | Thread | [xsl] css link in XSLT ignored in I, Anthony L |
Re: [xsl] differences between xsl:a, Georges Schmitz | Date | [xsl] css link in XSLT ignored in I, Anthony L |
Month |