[SoapRMI] Re: [SoapRMI] About-XmlPullParserFactory

nodep@libero.it nodep_at_libero.it
Tue, 17 Dec 2002 21:27:07 +0100


Hi,
yes I'm having parsing errors with JSX's parser (the other tool I'm using) 
because it find this: 
valueOf='<work alias-ID="0" s="23.6"> </work>',
instead of:
valueOf='<work alias-ID="0" s="23.6"> </work>'. 
in the output of method writeNode.

The error is: 
JSX.ParserXML$ExceptionXML: Line 1: Expected matching ''', but got '"' 
...

As I understand, it's looking for apostrophe and it find quotation mark.

I found the workaround: in the line (*) of previous message, if I replace quotation mark(") 
with apostrophe(') inside the value of valueOf attribute, all go OK.
(i.e. I always serialize:  String state="<work alias-ID='0' s='23.6'> </work>"
and not:  String state="<work alias-ID=\"0\" s=\"23.6\"> </work>" )
For now I use this workaround until I'm not sure if it's a XSOAP-problem or JSX-problem.

Thanks!

Stefano Pedon



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
  
>
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