Re: [xsl] xslt 2.0 regex

Subject: Re: [xsl] xslt 2.0 regex
From: davep <davep@xxxxxxxxxxxxx>
Date: Sat, 17 Mar 2012 16:14:27 +0000
On 17/03/12 16:03, Dimitre Novatchev wrote:
It seems to me that in this subexpression:

| - | . | [0-9]

The dot needs to be escaped. Dot is a special character and in its
unescaped form means "accept any character at the current position".
On the other side:

\.

means literally the dot character.


Cheers, Dimitre

Good catch Dimitre. Thanks. It's still not working

<xsl:variable name="NameStartChar.re" as="xs:string">
 &#x024;[A-Z]|_|[a-z] |
 [&#xC0;-&#xD6;] | [&#xD8;-&#xF6;] |
 [&#xF8;-&#x2FF;] | [&#x370;-&#x37D;] |
 [&#x37F;-&#x1FFF;] | [&#x200C;-&#x200D;] |
 [&#x2070;-&#x218F;] | [&#x2C00;-&#x2FEF;] |
 [&#x3001;-&#xD7FF;] | [&#xF900;-&#xFDCF;] |
 [&#xFDF0;-&#xFFFD;] | [&#x10000;-&#xEFFFF;]
</xsl:variable>

<xsl:variable name="NameChar.re"  as="xs:string"
	      select="concat($NameStartChar.re,' |
- | \. | [0-9] | &#xB7; | [&#x0300;-&#x036F;] |
[&#x203F;-&#x2040;]')"/>


<xsl:variable name='Name.re' select='concat($NameStartChar.re, "(", $NameChar.re,")*")'/>


<xsl:template match="*[@select]"> <xsl:variable name='this' select="."/> <xsl:if test="contains(@select,'$')"><!-- concat('(',$Name.re,')') --> <xsl:analyze-string select="@select" regex="{$Name.re}" flags="x"> <xsl:matching-substring> <xsl:message> "<xsl:value-of select="name($this)"/>"<xsl:text> </xsl:text> [<xsl:value-of select="regex-group(0)"/>] <xsl:text> </xsl:text> </xsl:message> </xsl:matching-substring> <xsl:non-matching-substring> </xsl:non-matching-substring> </xsl:analyze-string> </xsl:if> <xsl:apply-templates select="*"/> </xsl:template>


The regex-group(0) isn't reporting the variable name? Surrounding with () hasn't helped, to use -group(1) either.





regards

--
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk

Current Thread