Re: [xsl] passing the an apostrophe as a string to a param.

Subject: Re: [xsl] passing the an apostrophe as a string to a param.
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 11 Apr 2001 18:39:27 +0100
Hi Adam,

> but how do I do it for my captions?
> <xsl:call-template name="SlashChars">
>         <xsl:with-param name="content" select="@Caption" />
>         <xsl:with-param name="char" select="''''" /> <!-- thats four ' in  a
row within " -->>
> </xsl:call-template>

Well, the outer double-quotes are the quotes required by XML to
delimit the attribute value. XML can accept either single or double
quotes as attribute value delimiters, as long as there aren't any
unescaped versions of the same kind of quotes within the value.

The middle single quotes are the quotes required by XPath to delimit
the string.  XPath can accept either single or double quotes as string
value delimiters, as long as there aren't any of the same kind of
quotes within the string value.

The inner-most single quotes make up the value of the string that you
want to pass as the $char parameter (don't you want a single single
quote?).  You don't want to change them.

So that means that you *have* to delimit the XPath string with double
quotes so that the XPath processor can parse the XPath correctly.  So
the attribute value has to be:

  "''"

Now, you can use either single or double quotes for the attribute
delimiters, but you have to escape the quotes inside the attribute
value using entities.  So you could do:

  <xsl:with-param name="char" select="&quot;''&quot;" />

Or you could do:

  <xsl:with-param name="char" select='"&apos;&apos;"' />

It doesn't matter which you do.  You could even escape all the
characters in the attribute value if you want - it makes no difference
to the XPath processor.

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread