Project

Profile

Help

Backtick Causing Invalid Character

Added by Christopher Yocum over 1 year ago

Hi,

I need some help with a character that I need to match in an XML document, backtick (`). However, when I input code like this using Saxon 12 HE:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="3.0">

<xsl:mode on-no-match="shallow-copy"/>

<xsl:variable name="foo" select="`"/>

</xsl:stylesheet>

Thank you for you very much for your help in this. I receive the following error:

Error in {} in xsl:variable/@select on line 8 column 41 of text.xsl: XPST0003 Invalid character '' (backtick) in expression Errors were reported during stylesheet compilation

I have also tried using the double escape method (``) and I have also tried `. Is there a way to match a backtick in Saxon?


Replies (3)

Please register to reply

RE: Backtick Causing Invalid Character - Added by Christophe Marchand over 1 year ago

In one of my XSL, I have this function, and it perfectly works with Saxon 10 to 12 :

  <xsl:function name="prv:isCodeMarker" as="xs:boolean">
    <xsl:param name="s" as="xs:string"/>
    <xsl:sequence select="prv:isString($s) and $s=>normalize-space()=>starts-with('```')"/>
  </xsl:function>

I try to check if a string starts with 3 bactkticks.

Christophe

RE: Backtick Causing Invalid Character - Added by Christophe Marchand over 1 year ago

Oops, sorry.

@select expects an XPath expression. You should wrap your backtick between apos :

<xsl:variable name="foo" select="'`'"/>

Hope this helps, Christophe

RE: Backtick Causing Invalid Character - Added by Christopher Yocum over 1 year ago

HI Christophe

Thanks for your help. I was also able to get help in another part of this service (I don't know this software all that well). Basically I had to wrap the backtick in single quotes and I had forgotten this simple fact about select. Basically, I needed to have this:


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="3.0">

<xsl:mode on-no-match="shallow-copy"/>

<xsl:variable name="foo" select="'`'"/>

</xsl:stylesheet>

    (1-3/3)

    Please register to reply