This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Special characters in xsl



> My problem is the next. I have a xml file like:

But why is it like that?

  <nom_div><![CDATA[altres2]]></nom_div>

is exactly the same input as

  <nom_div>altres2</nom_div>

   <content><![CDATA[<form method="post" action=""><font ....

is exactly the same input as

   <content>&lt;form method="post" action=""&gt;&lt;font ....

You say:
> When I execute the instruction: <xsl:value-of select="content"> in my
> xsl file, which is a variable field, the character < is substituted by
> &lt;

but that doesn't really describe the situation: You quoted the input
with CDATA and that is completely equivalent to quoting each individual
< as &lt;. So your xsl:value-of is just showing you the input.

> What can I do?
If the HTML fragments in your input are well formed (which seems to be
the case in your example) then remove all the CDATA markup and use
<xsl:copy-of select="content"/>  instead of value-of.

If the HTML fragments are not well formed then you are in a much worse
situation, you could try adding disable-output-encoding="yes" to your
xsl:value of, but searching the archives of this list will show why that
does not always work and is always a very fragile hack.

David


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]