Noah,
It looks like you already found a way to do this by looking at the name
of the document tag. And in fact, this is what XmlBeans is doing too
when parsing using the generic parse method.
So if you don't know beforehand what kind of document you are going to
receive, do the following:

XmlObject doc = XmlObject.Factory.parse(message);
SchemaType type = doc.schemaType(); // the type of the document, based
on the name of the root element and the xsi:type attribute if present
if (type == MyDoc1Document.type)
{
    MyDoc1Document myDoc1 = (MyDoc1Document) doc;
    // Specific processing
}
// Other possibilities

Radu

-----Original Message-----
From: Noah Yan [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 13, 2005 10:12 AM
To: user@xmlbeans.apache.org
Subject: select a document type to parse my files.


I am just starting using xmlbeans to read some xml file. I generated the
.jar for my schema, and now can use the class to read the provided xml
file. I have another problem, hope some of your could give me some
suggestions.

My schema defines several document type for user to use. In normal  use,
the users provided multiple xml docs for the different types of the
schema. My program should pick an xml file, match it to a specific xml
schema type and parse it using the cooresponding XMLBeans class.

How XMLbean can tell what schema type of an xml file is associated so
that the proper docType class can be used to parse the xml file? I know
I can do this by use a general XML parse to find the name of the root
document, and then call the cooresponding XMLBeans generated class. But
I want to check whether XMLbeans have some other ways to do this.

Thanks very much
Noah


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


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

Reply via email to