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]
Other format: [Raw text]

RE: & converted to &


hai jeny,

thanks for the explanation... your solution is working and it solved my
problem...

i found out there are still many many things that I need to pick up in XSL,
XSLT and XML...

This tech list is definitely a right place for me to pick up those
knowledges...

Thanks to those out there who had been putting their effort to answer the
questions posted... It really help and it's great...

Cheers and have a nice day !

best regards,
Hong Ling


-----Original Message-----
From: owner-xsl-list@lists.mulberrytech.com
[mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Jeni Tennison
Sent: Friday, June 28, 2002 8:53 PM
To: Goh Hong Ling
Cc: Xsl-List@Lists. Mulberrytech. Com
Subject: Re: [xsl] & converted to &


Hai Hong Ling,

> In my XSLT file, I want to convert a code to a description. The
> description somehow might contains &, < and > symbols. The
> description will display as a plaintext. In my XSL file, I set
>
> <xsl:when test=" code='13' ">AI &#38; </xsl:when>
> <xsl:when test=" code='14' ">&#163;</xsl:when>

When the XML parser parses the XSLT stylesheet, it creates a tree that
looks like:

  xsl:when ----- test: code='13'
    +- "AI & "
  xsl:when ----- test: code='14'
    +- "£"

As far as XSLT is concerned, there is absolutely no difference between
using '&#38;' in your stylesheet and using '&amp;' in your stylesheet
-- they are both decoded into the character '&'.

When you serialise that as XML, the & character has to be escaped
because the & is a significant character in XML (it marks the start of
an entity reference or character reference). The built-in escape for
the & character is '&amp;', so that's the one that most processors use
to serialise & characters.

If you're generating plain text rather than XML, then you should set
the output method to text using the xsl:output element:

<xsl:output method="text" />

That way the processor won't do any escaping (there are no special
characters in plain text), and you'll get the characters '&' and '£'
in your output.

If you want to generate XML, but have more control over how the result
tree is serialised, then put the result of the transforming into a DOM
and write your own processor to serialise that DOM as an XML document.

By the way, the reason that your browser is displaying '&' and '£', as
it should, is that it knows that the entity reference '&amp;' means
the character '&', so that's what it displays.

Cheers,

Jeni

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


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


 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]