xsl-list
[Top] [All Lists]

[xsl] Escaping data in XML attributes

2008-02-09 07:51:17
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?

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>