xml-xalan-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Welch" <awe...@piper-group.com>
Subject RE: How to handle & in XML with Xalan XSLT?
Date Thu, 10 Oct 2002 13:52:43 GMT

& and &amp; are the same thing!

You might think you really need to convert & to &amp; but its highly
unlikely. 

If you have & in your source xml, then it must be represented as it's
entity reference &amp; as & is a special character in xml reserved to
indicate the beginning of character/entity references such as &apos;
&quot; etc If you have '&' on its own then you are not dealing with xml,
so you need to look at whats producing this made-up syntax and fix it.

Much like < is reserved to indicate the start of an element name <foo> -
if you need to use < say in a comparision 'a < b' then you must use its
entity reference &lt; 'a &lt; b' to ensure the processor doesn't think
you are trying create a new element <b !

When the references go through the parser (before they get to the
processor) they get escaped to their actual values, so &amp; becomes &
and &lt; would become <.

When trying to output wml, which is in itself xml (therefore the xml
output method would be used) the serializer knows '&' isn't allowed in
xml so it must output it as the reference '&amp;'.

Which I think is what you are after... fix the input and all should be
well.

(the only time I can think of when you would really need to turn & into
&amp; is to double-escape, to get something like &amp;apos; - is that
what you are really after?)

cheers
andrew





> -----Original Message-----
> From: Vincent Seet [mailto:slhvince@singnet.com]
> Sent: 10 October 2002 13:53
> To: xalan-j-users@xml.apache.org
> Subject: Re: How to handle & in XML with Xalan XSLT?
> 
> 
> Thanks! What if I really need to convert & to &amp; during 
> the translation,
> how can I go about do it?
> 
> Regards
> ----- Original Message -----
> From: "Andrew Welch" <awelch@piper-group.com>
> To: "Vincent Seet" <slhvince@singnet.com.sg>; 
> <xalan-j-users@xml.apache.org>
> Sent: Thursday, October 10, 2002 8:24 PM
> Subject: RE: How to handle & in XML with Xalan XSLT?
> 
> 
> >
> > Xml documents can never contain '&' on its own, rather 
> &amp; the entity
> > reference - whatever is producing the & isn't producing 
> xml, so I would
> > look there first.
> >
> > cheers
> > andrew
> >
> > -----Original Message-----
> > From: Vincent Seet [mailto:slhvince@singnet.com]
> > Sent: 10 October 2002 13:08
> > To: xalan-j-users@xml.apache.org
> > Subject: How to handle & in XML with Xalan XSLT?
> >
> >
> >
> >
> > Hi Gurus,
> >
> > I have XML documents which may contain the character "&", 
> how do I make
> > the translator perform escaping to "&amp;" for display on WML?
> >
> > Regards
> > Vincent
> >
> >
> > ---
> > Incoming mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.394 / Virus Database: 224 - Release Date: 03/10/2002
> >
> > ---
> > Outgoing mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.394 / Virus Database: 224 - Release Date: 03/10/2002
> >
> >
> 
> 
> 
> 
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.394 / Virus Database: 224 - Release Date: 03/10/2002
>  
> 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.394 / Virus Database: 224 - Release Date: 03/10/2002
 

Mime
View raw message