Hello,
Not so long ago someone asked a question about parsing xml fragment.
I am also running into some issues with parsing XML fragments and
would like to get some clarifications from you experts.
The xmlBeans I am working with is structured like this:
AResponseDocument --> AResponseType --> BDataType --> (choice of
either) CType[0..*] (or) DType[0..*]
In other words (if my illustrations above wasn't clear enough), I am
getting a response document back from some web service call, and the
response contains a BDataType object, which in turn contains an array
of CType objects or an array of DType objects.
Currently, only CType is used.
The problem I ran into is that sometimes, I have to parse an input
stream of characters into a BDataType, and a typical stream looks like
the following:
<typ1:bData xmlns:typ1="...">
<typ1:c>
... some stuff here ...
</typ1:c>
</typ1:bData>
However, when I tried to do this
BDataType bdt = BDataType.Factory.parse(inputStream);
it did not parse correctly, because
System.out.println(bdt.getCList().size());
gives me 0, and I was expecting 1 since there is always a "c" element
present in the data stream
Is this because the data stream I am getting is missing the
<xml-fragment> tags??
I printed bdt.xmlText() from an actual BDataType object, and noticed
the xmlText is surrounded by <xml-fragment> tags. When I tried to
parse that xml text, it actually worked.
One obvious solution for me right now, would be to grab the
inputStream and store it into a string, surround it by the
<xml-fragment> tags, and then call BDataType.Factory.parse(string)...
but I would prefer to avoid converting the input stream to a string.
A place online suggests that one should always parse from "one level
up", but when I tried this:
AResponseType art = AResponseType.Factory.parse(inputStream)
I get a null pointer exception when I say
art.getBDataType();
So is there any other way??? Thanks!
-- Jim
--
--------------------------------------
Standing Bear Has Spoken
--------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]