xml-xmlbeans-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Vasilik" <eric...@bea.com>
Subject RE: v1: efficient detecting if XML can be mapped to XmlPbject ...
Date Fri, 19 Mar 2004 23:41:50 GMT
It is a bit more complicated than this.  Take a look at
org.apache.xmlbeans.impl.store.Root.autoTypedDocument for the
implementation which associates the SchemaType with an instance.

Basically, this function looks for a document type if there is a single
document element at the root.  If there is a single attribute at the
root, then an attribute document type is looked up.  If there is an
xsi:type associated with the root (the container of a document element),
then a global type is looked up.

If your document being parsed is not a fragment and is well formed, then
simply looking for a document type is sufficient:

    XmlBeans.getContextTypeLoader().findDocumentType( QName )

- Eric

-----Original Message-----
From: Aleksander Slominski [mailto:aslom@cs.indiana.edu] 
Sent: Friday, March 19, 2004 3:31 PM
To: xmlbeans-dev@xml.apache.org
Subject: v1: efficient detecting if XML can be mapped to XmlPbject ...

hi,

one way to check if XML fragment can be mapped by XmlBeans to known 
XmlObject is try to do it:

   try {

            XmlObject response = XmlObject.Factory.parse(xmlString);

        } catch (XmlException e) {
            //not supported
        }

is there some better method? (efficiency)?

if i know QName of top element (or its xsi:type if present) will

     
if(XmlBeans.getContextTypeLoader().findType(javax.xml.namespace.QName) 
!= null) { ... }

be the best way to do such check?

thanks,

alek

-- 
The best way to predict the future is to invent it - Alan Kay


- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


Mime
View raw message