[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] How to escape "$" in output?


Subject: Re: [xsl] How to escape "$" in output?
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 25 May 2005 15:32:48 -0400

David,

At 02:50 PM 5/25/2005, you wrote:
I have an element like the following that I need to emit from within a
template:

    <wlwBuild work="${app.dir}/${work.file}"
serverclasspath="${server.classpath}">
       <build outputdir="${output.dir}"
outputfilename="${output.file}"/>
    </wlwBuild>

I need to make sure it is emitted literally, particularly so that the
Ant expressions are not munged by XSLT.

Do I have to use manual "xsl:element" and "xsl:attribute" elements, with
attribute values using "concat" to separate the "$" from the rest of the
value?

No, you don't. Actually I don't think it will be the '$' characters that will be the problem here, but rather the curly braces, which the XSLT processor sees as attribute value templates.


In order to prevent this, you can escape the curly braces by doubling them. So your stylesheet would say

<wlwBuild work="${{app.dir}}/${{work.file}}"
          serverclasspath="${{server.classpath}}">
   <build outputdir="${{output.dir}}" outputfilename="${{output.file}}"/>
</wlwBuild>

This should produce the literal output you want.

I tried using '<xsl:text disable-output-escaping="yes">...', but that
complains about the "wlwBuild" element, saying it's not legal at that
point in the stylesheet.

That's weird, though I suppose if you posted the code we might be able to see why. On the other hand, you might not want to bother: d-o-e isn't the way you want to do this anyway.


Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================


Current Thread
Keywords