Hi Dave,

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.

Indeed it does, I was using a generated type's Factory.parse(xmlString); but the string being parsed was a Document surrounding the type, not an xml-fragment of the type I wanted.

I cannot return the xml-fragment string (spec won't allow that); so now my client just needs to either deal with documents, or convert to the enclosed type.

Vague, I know - but you've helped me out quite a bit - thanks.

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

I think this is useful information too - thanks again Dave.

--Kent

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to