Re: [xsl] Ignoring specific characters like > in the XML while doing XSLT

Subject: Re: [xsl] Ignoring specific characters like > in the XML while doing XSLT
From: Dipesh Khakhkhar <dkhakhkh@xxxxxxxxxxxxxxx>
Date: Fri, 17 Oct 2003 10:49:04 -0400
Hi Wendell,

Thanks for replying and explaining about DOE.

My output method is text and i have defined it like this.

<xsl:output method="text" encoding="UTF-8"/>

And in the input xml file i am getting value like this at one place

<myTag NAME="Identifier">HL-DT-ST CD-ROM GCR-8480Bema"&gt;</ATTRIBUTE>

and there is one end of line character after  &gt; and then question mark is 
there. I guess this file is generated by some tool and there must be some 
goofing somewhere which is producing output like this.

So do you mean with ouput method as text, i won't be able to use DOE ?

I can't change my output method from text to xml. Are there any other ways to 
escape those.

Thanks once again for replying.

Regards,
Dipesh


Date: Thu, 16 Oct 2003 15:58:48 -0400
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Subject: Re: [xsl] Ignoring specific characters like &gt; in the XML while 
doing XSLT

Dipesh,

The character sequence "& g t ;" (no spaces), by definition, is an entity 
reference in XML, and by definition it represents the character ">".

(Hey, where's Dave C or Mike B? This thing is an entity reference that happens 
to be built in, not a character reference, right?)

When you say "I am getting text output" are you trying to tell us you have

<xsl:output method="text"/>

? since if so, this method is specifically required not to escape characters 
such as "<" and ">" and "&" into their well-formed XML representations "&lt;" 
and "&gt;" and "&amp;" but to leave them as "<" and ">" and "&" -- since it's 
making plain text (not XML), and these are the plain text characters those 
references refer to.

Try outputting XML (method="xml") instead of text, and you'll find the 
serializer will escape the thing back again. (Of course you may not like the 
output for another reason.)

>How do i ignore special characters like those ? I mean i don't want XSLT to
>change it.

The XSLT processor isn't changing it; it's the parser sitting in front that is 
resolving it -- from this point of view, it isn't a change, it's only making 
it into what it "really is" (what it is always supposed to represent).

Cheers,
Wendell


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


Current Thread