Hi Kent,
What you do to build the XMLDoc? Use a text editor?
Yep. The examples I used were cut and paste from a previous post with
some free hand editing in the mail client, so apologies if there are any
slight errors.
In my case, I build messages to send over, for example, http by using
the bindings - I don't have a doc to parse, I want to create that doc
using the code.
When creating documents via XmlBeans I use __Document.newInstance()
then add the elements via the generated API calls...
But none of the elements that I want to send in the xs:any body of my
request is a top-level globally defined element, so I cannot create
them through that idiom (doc.interface.factory) anyway.
...(or XmlCursors when I have to).
WRT to parsing - how do you know the type of the object in advance?
XmlObject.Factory.parse() will try to map to the correct type as long as
the generated types can be found on the classpath. I've never had to
deal with unknown document types in the real world, only unknown and
invalid types within those documents, so I've never actually put this
into real code, other than the early days when I always parsed via
XmlBeans (through ignorance), but I still knew the Document type.
However, after the reading the javadoc for the SchemaType interface I'd
try something like this: (comments from the javadocs)
XmlObject obj = XmlObject.Factory.parse(xmlString);
if(AddRequest.type.isAssignableFrom(obj.type) // True if the specified
type derives from this type (or if it is the same type).
{
AddRequest addRequest = (AddRequest)obj.changeType(AddRequest.type);
//Changes the schema type associated with this data and returns a new
XmlObject instance whose schemaType is the new type.
}
etc.
As I said, I've never done this, but it seems to be what the docs
suggest. I'll try to find some time to play with this over the weekend
as I'm sure I'll need it one day! Any feedback would be appreciated too.
Thanks,
Dave.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]