xsl-list
[Top] [All Lists]

Re: [xsl] xslt 2.0 regex

2012-03-17 11:14:38
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>