Subject: RE: [xsl] & converted to & From: hlgoh@xxxxxxxxxxxxx (Goh Hong Ling) Date: Mon, 1 Jul 2002 11:41:17 +0800 |
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@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]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 & </xsl:when> > <xsl:when test=" code='14' ">£</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 '&' in your stylesheet and using '&' 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 '&', 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 '&' 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Processor outputs once and th, jdgarrett | Thread | Re: Sablotron's DOM2 support [was: , Petr Cimprich |
[xsl] XSLT/SVG variables question, Harry J. Foxwell | Date | |
Month |