[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Keeping "&" in xml data when parsed

Subject: Re: Keeping "&" in xml data when parsed
From: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx>
Date: Fri, 25 Jan 2002 10:38:21 -0500
translate ampersand xml
[James Knight]
> My database is pulling out a company name, "A & B", and writing it into an
> xml file.
> When I try to parse the xml through a stylesheet, I get a complaint that
> the entity name must follow the ampersand immediately, i.e. the parser
> thinks it's a mis-typed entity.
> Bearing in mind that I don't have access to the database, is there any way
> to  warn the stylesheet not to attempt to translate the ampersand?
You have to escape the ampersand with &amp;  or the string (or ampersand)
has to be in a CDATA section.  Otherwise it's not well-formed xml and won't
get past the parser.  The CDATA section is one way to tell the parser that
you mean the character literally (there's no way to "warn the stylesheet",
since the character has been dealt with before the xslt processor ever sees

You can alter the query.  For example, the query could read something like

select '<![CDATA[' + name + ']]>' as escaped_name from company

Without a way to change the query, you have to preprocess the results,
replacing each "&" with "&amp;".


Tom P

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

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.