Re: ?Best way to escape for xml?
- From: "beanweed" <beanweed@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 25 May 2005 04:30:02 -0700
Thanks for your help. Subsequent investigation leads me to believe that,
although the original error was and is reported to have been caused by the
line containing "xmldoc.LoadXml(oraclestring)", it was the next line
containing "xmlcontrol.Document = xmldoc" and the tranformation of the xml
using an xsl document that is the fault. (Removing this line stops the
problem, changing the xsl solves it.) I will change my encode and decode
methods (in Java on the Oracle server) to comply with your suggestion and the
W3 specification. But I will remain puzzled as to why .Net just ignored
"!"(?).
"Ion Vasilian" wrote:
> Hi,
>
> You might want to take a look at http://www.w3.org/TR/REC-xml/#syntax
> first. It is unlikely that the problem is caused by the '!'; '&' is the
> culprit.
> Whatever you're getting is not well-formed xml. You'll need to change the
> source so that it applies the following character mapping on serialization:
> for character data:
> < -> <
> & -> &
> for attribute values the above plus:
> ' -> '
> " -> "
> Unless you have a very specialized scenario you cannot consistently filter
> the
> input unless you're parsing the xml at the same time. You probably don't
> want
> to do that. Another alternative is to use CDATA sections for the text.
> Again,
> that's reasonable provided that you have control of the source
> serialization.
>
> Ion
>
> "beanweed" <beanweed@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:A593F356-B964-431B-8978-7AAFEEEA1120@xxxxxxxxxxxxxxxx
> > I have an Oracle Procedure that returns xml. There was an exception thrown
> > when I tried to load an XmlDocument (using LoadXml(String)) because the
> value
> > returned from Oracle had an exclamation mark in a text node. So I wrote an
> > escape method to encode the text coming into the .Net class. But now I am
> not
> > sure how to write the unescape method to handle the text when it goes back
> to
> > the Oracle db.
> >
> > Here's what I mean:
> > - if the data in the db is "abc ! & ' " < > efg", the procedure produces
> > this element
> >
> > <data>abc ! & " ' < > xyz</data>
> >
> > - loading this into an XmlDocument using thedocument.LoadXml(oraclestring)
> > leaves
> >
> > <data>abc ! & ' " < > xyz</data>
> >
> > So do I write a method to change the "&", "<" and ">" back to "&<>" in
> > Oracle? How many other characters are changed and to what? Why was it bad
> for
> > me to give an "!" in the string when .Net then uses it unescaped
> thereafter?
> > I await enlightenment peacefully.
> >
>
>
>
.
- References:
- ?Best way to escape for xml?
- From: beanweed
- Re: ?Best way to escape for xml?
- From: Ion Vasilian
- ?Best way to escape for xml?
- Prev by Date: Re: ?Best way to escape for xml?
- Next by Date: xml schema to dataset to xml
- Previous by thread: Re: ?Best way to escape for xml?
- Next by thread: xml schema to dataset to xml
- Index(es):
Relevant Pages
|
Loading