[SoapRMI] About-XmlPullParserFactory
Aleksander Slominski
aslom_at_cs.indiana.edu
Tue, 17 Dec 2002 06:40:11 +0100
nodep_at_libero.it wrote:
>I'm trying (again...) to write a (de)serializer and
>in readObject() method I use this piece of code:
>
>public Object readObject(
> DeserializeContext dctx,
> EncodingStyle enc,
> Class expectedClass,
> XmlJavaTypeMap map,
> XmlPullParser pp,
> XmlStartTag stag)
> throws DeserializeException, XmlPullParserException, IOException
> {
> byte b=pp.next();
> XmlPullParserFactory ppf=XmlPullParserFactory.newInstance();
> XmlNode nodeTree=null;
> try {
> nodeTree = ppf.newNode(pp);
> } catch(Exception ex) {
> throw new DeserializeException(
> "can't deserialize input into XML node tree"
> +pp.getPosDesc(), ex);
> }
> StringWriter sw=new StringWriter();
> ppf.writeNode(nodeTree, sw, true);
>...
>
hi,
this code looks OK.
> (*)<java.lang.String alias-ID="2" obj-name="state" valueOf="<work alias-ID="0" s="23.6">
>
>but the output of "ppf.writeNode(nodeTree, sw, true)" is:
>
>(*)<java.lang.String alias-ID='2' obj-name='state' valueOf='<work alias-ID="0" s="23.6"> </work>'/>
>
>
they are equivalent as from XML point of view whetehr attribute has
apostrophe (') or quotation mark (") used for enclosing of attribute
value is irrelevant. inside attribute value only <,>,& and " must be
escaped if attrubute value is enclosed in apostrophes (see
http://www.w3.org/TR/REC-xml#NT-AttValue and look that |AttValue
requires escaping only of ||[^<&"] or ||[^<&'])|
>The problem is that "writeNode" has translated the value of attribute
>"valueOf", in the row (*), in a legible form, but it souldn't... I think.
>
this is required to escape attribute value ot make into valid XML -
translatin back is done automatically by parser and when you read
String vcalue of attribute "valueOf" it will be back the same as you
have put it.
>What's wrong?
>
as far as i can tell by looking on XML outout all shoul dbe just fine
and XSOAP/XPP combo does good job if generaating corect and as small as
possible XML serialization of XmlNode escaping only _required_
characters. do you get any parsing error?
thanks,
alek
--
The ancestor of every action is a thought. - Ralph Waldo Emerson