In XSLT 2.0 the rule is:
* the delimiter of the XML attribute can be escaped as & quot; or & apos;
respectively
* the delimiter of the string literal can be escaped by doubling it.
However, a simpler approach is often to put the regex in a variable:
<xsl:variable name="regex" as="xs:string">['"](.*?)["']</xsl:variable>
<xsl:value-of select="matches(, $regex)"/>
This way, neither quotes nor apostrophes need to be escaped.
Regards,
Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay
-----Original Message-----
From: Alex Muir [mailto:alex(_dot_)g(_dot_)muir(_at_)gmail(_dot_)com]
Sent: 08 October 2009 12:45
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Anyway to avoid a syntax error when matching
with a regex containing both '" for example ['"](.*?)["']
Hi,
Is there any way to avoid a syntax error with a regex
containing both '" for example ['"](.*?)["'] in the
following select.
<xsl:value-of select="matches(.,
'['"](.*?)["']')"/>
Working with Oxygen 10.3, F [Saxon-B 9.1.0.7] I'll get an
XPath syntax error at char 14 on line 44 in {matches(.,
'['"](.*?)["']'}:
expected ")", found "<string-literal>"
I'm sure this is an easy question but I wasn't able to find
the right Google search to answer it.
Thanks
--
Alex
https://sites.google.com/a/utg.edu.gm/alex
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--