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

Re: Escaping data in XML attributes

Subject: Re: Escaping data in XML attributes
From: "Anthony B. Coates (XSL-List)" <abcoatesecure-xsllist@xxxxxxxxxxx>
Date: Sun, 10 Feb 2008 12:10:20 -0000
Re:  Escaping data in XML attributes
At the risk of giving you an answer that you don't want to hear, the most
efficient solution is probably to change your XML format so that you put
this kind of content into elements, not attributes.  In the long run, that
will make life a whole lot easier for you; of course, it will require some
changes in the short term, and whether you can do that depends on impacts,
schedules, etc.

In general, it's always going to be most efficient if you work with the
technology, not against it, and that means going with the technology's
strengths where you can, not its weaknesses.

Cheers, Tony.

On Sat, 09 Feb 2008 14:50:49 -0000, Robert La Ferla
<robertlaferla@xxxxxxxxxxx> wrote:

I have an issue that I need assistance with:

Let's say that my database returns this XML unfriendly name that I need
to insert into an XML document.

"Bob's Black & Tan "Boston Branch <1>"

As you can see, the value returned has double quotes, single quotes,
angle brackets and an ampersand.

I could put the value in a child element of my company element like this:

<company>
<name><![CDATA["Bob's Black & Tan "Boston Branch <1>"]]></name>
</company>

but that would require a massive rewrite of my XSLTs and XML because I
currently use attributes for values like name, etc...:

<company name="Bobs Black and Tan"></company>

and I have many elements similar to this like <account>, <employee>,
etc...

Is there a way I can still use attributes yet escape these unsavory
characters?  What's the most efficient way of solving this?

-- Anthony B. Coates Director and CTO Londata Ltd UK: +44 (20) 8816 7700, US: +1 (239) 344 7700 Mobile/Cell: +44 (79) 0543 9026 Data standards participant: genericode, ISO 20022 (ISO 15022 XML), UN/CEFACT, MDDL, FpML, UBL. http://www.londata.com/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.