Css – Regular Expression in XSLT

cssxmlxslt

I have an XSLT function that takes a regular expression as a parameter but the XSLT parser does not like it.

Here is the code:

<xsl:value-of select='ns:RegexReplace($variable, "", "style=\"\w+\:\s\w+;\"")' disable-output-escaping='yes' />

I found this:
http://www.xml.com/pub/a/2003/06/04/tr.html <– but it is using what I am and seems to work (for them). Do I just have a rubbish parser??

Is there any way of doing this?
Or, a way of forcing an element to ignore inline style via a CSS trick?

Best Solution

You seem to be trying to include quotes in a quote-delimited XPath string literal by escaping them with a backslash. That does not work.

In XPath 1.0 (XSLT 1), there is no nice way to do this. You may need to resort to tricks like defining a variable which holds a single quote character and using the concat function to create your string:

<xsl:variable name='quot' select="'&quot;'"/>
<xsl:value-of select='concat("a string with a quote ", $quot, " character")'/>

In XPath 2.0 (XSLT 2), you can escape a quote with another quote:

<xsl:value-of select='"a string with a quote "" character"'/>