Regular expression error

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Regular expression error

Toshihiko Makita
Hi List,

I'm using Saxon 9.4 bundled with oXygen 14.2.
Today I got the following error message when I wote replace function.

System ID: D:\My_Documents\proj\XSLT-TEST\20130910-reg\sample.xsl
Main validation file: D:\My_Documents\proj\XSLT-TEST\20130910-reg\sample.xsl
Engine name: Saxon-EE 9.4.0.6
Severity: fatal
Description: FORX0002: Error at character 8 in regular expression
"([0-9]+(?:\.[0-9]+)?(?:mm))(?:...": expected ())
Start location: 12:162
URL: http://www.w3.org/TR/2005/WD-xpath-functions-20050211/#ERRFORX0002


The stylesheet is as follows:

<xsl:template match="/">
<xsl:variable name="actualSize" as="xs:string" select="'3.5mm×1.4mm'"/>
<xsl:choose>
<xsl:when
test="matches($actualSize,'[0-9]+(\.[0-9]+)?(mm)(×)[0-9]+(\.[0-9]+)?(mm)')">
<xsl:variable name="mmSpec" as="xs:string"
select="replace($actualSize,'([0-9]+(?:\.[0-9]+)?(?:mm))(?:×)([0-9]+(?:\.[0-9]+)?(?:mm))','$1
$2')"/>
<xsl:message select="'$mmSpc=',$mmSpec"/>
</xsl:when>
</xsl:choose>
</xsl:template>


Doesn't Saxon support "?:" notation in a regular expression?

Please advice.

Regards,

--
/*--------------------------------------------------
 Toshihiko Makita
 Development Group. Antenna House, Inc. Ina Branch
 E-Mail [hidden email]
 8077-1 Horikita Minamiminowa Vil. Kamiina Co.
 Nagano Pref. 399-4511 Japan
 Tel +81-265-76-9300 Fax +81-265-78-1668
 Web site:
 http://www.antenna.co.jp/
 http://www.antennahouse.com/
 --------------------------------------------------*/


------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. Consolidate legacy IT systems to a single system of record for IT
2. Standardize and globalize service processes across IT
3. Implement zero-touch automation to replace manual, redundant tasks
http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Regular expression error

Michael Kay

The (?:...) notation is not permitted in XPath 2.0 regular expressions.

It is allowed in XPath 3.0, and is supported by Saxon if XPath 3.0 (+XSLT 3.0) is enabled - at least in 9.5, I would need to check the history to see if it was already supported in 9.4.

Michael Kay
Saxonica


On 10 Sep 2013, at 03:44, Toshihiko Makita wrote:

> Hi List,
>
> I'm using Saxon 9.4 bundled with oXygen 14.2.
> Today I got the following error message when I wote replace function.
>
> System ID: D:\My_Documents\proj\XSLT-TEST\20130910-reg\sample.xsl
> Main validation file: D:\My_Documents\proj\XSLT-TEST\20130910-reg\sample.xsl
> Engine name: Saxon-EE 9.4.0.6
> Severity: fatal
> Description: FORX0002: Error at character 8 in regular expression
> "([0-9]+(?:\.[0-9]+)?(?:mm))(?:...": expected ())
> Start location: 12:162
> URL: http://www.w3.org/TR/2005/WD-xpath-functions-20050211/#ERRFORX0002
>
>
> The stylesheet is as follows:
>
> <xsl:template match="/">
> <xsl:variable name="actualSize" as="xs:string" select="'3.5mm×1.4mm'"/>
> <xsl:choose>
> <xsl:when
> test="matches($actualSize,'[0-9]+(\.[0-9]+)?(mm)(×)[0-9]+(\.[0-9]+)?(mm)')">
> <xsl:variable name="mmSpec" as="xs:string"
> select="replace($actualSize,'([0-9]+(?:\.[0-9]+)?(?:mm))(?:×)([0-9]+(?:\.[0-9]+)?(?:mm))','$1
> $2')"/>
> <xsl:message select="'$mmSpc=',$mmSpec"/>
> </xsl:when>
> </xsl:choose>
> </xsl:template>
>
>
> Doesn't Saxon support "?:" notation in a regular expression?
>
> Please advice.
>
> Regards,
>
> --
> /*--------------------------------------------------
> Toshihiko Makita
> Development Group. Antenna House, Inc. Ina Branch
> E-Mail [hidden email]
> 8077-1 Horikita Minamiminowa Vil. Kamiina Co.
> Nagano Pref. 399-4511 Japan
> Tel +81-265-76-9300 Fax +81-265-78-1668
> Web site:
> http://www.antenna.co.jp/
> http://www.antennahouse.com/
> --------------------------------------------------*/
>
>
> ------------------------------------------------------------------------------
> How ServiceNow helps IT people transform IT departments:
> 1. Consolidate legacy IT systems to a single system of record for IT
> 2. Standardize and globalize service processes across IT
> 3. Implement zero-touch automation to replace manual, redundant tasks
> http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help 


------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. Consolidate legacy IT systems to a single system of record for IT
2. Standardize and globalize service processes across IT
3. Implement zero-touch automation to replace manual, redundant tasks
http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Regular expression error

Toshihiko Makita
Dr Kay,

Thank you for your reply.

> The (?:...) notation is not permitted in XPath 2.0 regular expressions.

It is regrettable!
This notation is very much convenient for stylesheet programmers.
I will inform it to my user because they still use Saxon 9.2 for their
production environment.

Regards,


(2013/09/10 17:49), Michael Kay wrote:

> The (?:...) notation is not permitted in XPath 2.0 regular expressions.
>
> It is allowed in XPath 3.0, and is supported by Saxon if XPath 3.0 (+XSLT 3.0) is enabled - at least in 9.5, I would need to check the history to see if it was already supported in 9.4.
>
> Michael Kay
> Saxonica
>
>
> On 10 Sep 2013, at 03:44, Toshihiko Makita wrote:
>
>> Hi List,
>>
>> I'm using Saxon 9.4 bundled with oXygen 14.2.
>> Today I got the following error message when I wote replace function.
>>
>> System ID: D:\My_Documents\proj\XSLT-TEST\20130910-reg\sample.xsl
>> Main validation file: D:\My_Documents\proj\XSLT-TEST\20130910-reg\sample.xsl
>> Engine name: Saxon-EE 9.4.0.6
>> Severity: fatal
>> Description: FORX0002: Error at character 8 in regular expression
>> "([0-9]+(?:\.[0-9]+)?(?:mm))(?:...": expected ())
>> Start location: 12:162
>> URL: http://www.w3.org/TR/2005/WD-xpath-functions-20050211/#ERRFORX0002
>>
>>
>> The stylesheet is as follows:
>>
>> <xsl:template match="/">
>> <xsl:variable name="actualSize" as="xs:string" select="'3.5mm×1.4mm'"/>
>> <xsl:choose>
>> <xsl:when
>> test="matches($actualSize,'[0-9]+(\.[0-9]+)?(mm)(×)[0-9]+(\.[0-9]+)?(mm)')">
>> <xsl:variable name="mmSpec" as="xs:string"
>> select="replace($actualSize,'([0-9]+(?:\.[0-9]+)?(?:mm))(?:×)([0-9]+(?:\.[0-9]+)?(?:mm))','$1
>> $2')"/>
>> <xsl:message select="'$mmSpc=',$mmSpec"/>
>> </xsl:when>
>> </xsl:choose>
>> </xsl:template>
>>
>>
>> Doesn't Saxon support "?:" notation in a regular expression?
>>
>> Please advice.
>>
>> Regards,
>>
>> --
>> /*--------------------------------------------------
>> Toshihiko Makita
>> Development Group. Antenna House, Inc. Ina Branch
>> E-Mail [hidden email]
>> 8077-1 Horikita Minamiminowa Vil. Kamiina Co.
>> Nagano Pref. 399-4511 Japan
>> Tel +81-265-76-9300 Fax +81-265-78-1668
>> Web site:
>> http://www.antenna.co.jp/
>> http://www.antennahouse.com/
>> --------------------------------------------------*/
>>
>>
>> ------------------------------------------------------------------------------
>> How ServiceNow helps IT people transform IT departments:
>> 1. Consolidate legacy IT systems to a single system of record for IT
>> 2. Standardize and globalize service processes across IT
>> 3. Implement zero-touch automation to replace manual, redundant tasks
>> http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk
>> _______________________________________________
>> saxon-help mailing list archived at http://saxon.markmail.org/
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help 
>
> ------------------------------------------------------------------------------
> How ServiceNow helps IT people transform IT departments:
> 1. Consolidate legacy IT systems to a single system of record for IT
> 2. Standardize and globalize service processes across IT
> 3. Implement zero-touch automation to replace manual, redundant tasks
> http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help 
>

--
/*--------------------------------------------------
 Toshihiko Makita
 Development Group. Antenna House, Inc. Ina Branch
 E-Mail [hidden email]
 8077-1 Horikita Minamiminowa Vil. Kamiina Co.
 Nagano Pref. 399-4511 Japan
 Tel +81-265-76-9300 Fax +81-265-78-1668
 Web site:
 http://www.antenna.co.jp/
 http://www.antennahouse.com/
 --------------------------------------------------*/


------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. Consolidate legacy IT systems to a single system of record for IT
2. Standardize and globalize service processes across IT
3. Implement zero-touch automation to replace manual, redundant tasks
http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Regular expression error

Michael Kay

On 10 Sep 2013, at 10:45, Toshihiko Makita wrote:

> Dr Kay,
>
> Thank you for your reply.
>
>> The (?:...) notation is not permitted in XPath 2.0 regular expressions.
>
> It is regrettable!

Indeed. That's why it was added to XPath 3.0.

It's very tempting sometimes to allow things that the spec doesn't allow in the interests of usability, but I always put standards conformance first.

Michael Kay
Saxonica


------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. Consolidate legacy IT systems to a single system of record for IT
2. Standardize and globalize service processes across IT
3. Implement zero-touch automation to replace manual, redundant tasks
http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help