Groups | Blog | Home
all groups > dotnet xml > july 2004 >

dotnet xml : xsltransform replaces "<" with entities


<Daniel Barisch>
7/12/2004 1:45:26 PM
Hello NG!

Within a xsl-stylesheet I have an element

<xsl:text><![CDATA[...<br>...]]></xsl:text>

If I use that stylesheet to transform some xml-data (to html) with

....
pOut = New System.IO.StringWriter
pXslt.Load(strStylesheetFile)
pXslt.Transform(pXPathNav, Nothing, pOut, Nothing)
....

then in the result-document the brackets are replaced with the
html-entities, so I get

....&lt;br&gt...

But I need the brackets, so that it is a html-tag!!!

What do I have to write into my xsl-stylesheet or is there a special option
for the xsltransform I have to set?

Thanks, D.Barisch

Martin Honnen
7/12/2004 2:02:33 PM


[quoted text, click to view]


[quoted text, click to view]

Then don't use <xsl:text> and a CDATA to create the element but a
literal result element e.g.
<br />
and it will be happily transformed to
<br>
if you chose html as the output method.

--

Martin Honnen
http://JavaScript.FAQTs.com/
<Daniel Barisch>
7/12/2004 3:55:16 PM
| Then don't use <xsl:text> and a CDATA to create the element but a
| literal result element e.g.
| <br />
| and it will be happily transformed to
| <br>

That does not work, because the "<br>" only is a part of the text of the
<xsl:text>-element. It creates a string (script-code!), that is later parsed
and executed by an other procedure of my application, before the final
html-page is viewed. So the transform-result is a kind of template, that
includes many "<br>"-tags and I don't really like to cut the text in little
pieces.

| if you chose html as the output method.

Maybe I only have to set this. I'll give it a try...

Thanks, D.Barisch

<Daniel Barisch>
7/12/2004 4:18:31 PM
Got it...

<xsl:text disable-output-escaping="yes"><![CDATA[...<br>...")}]]></xsl:text>

Martin Honnen
7/12/2004 5:08:42 PM


[quoted text, click to view]

Be warned that that doesn't work in all environments, it is an optional
feature as
http://www.w3.org/TR/xslt#disable-output-escaping
says and usually there are other ways to solve the problem, in this case
certainly to include an element directly if you want an element in the
output.

--

Martin Honnen
http://JavaScript.FAQTs.com/
AddThis Social Bookmark Button