[jdom-interest] Validation strategy

Michael Kay mike at saxonica.com
Wed May 10 05:19:57 PDT 2006


 > First of all this has to do with JDOM because that's the parser i want to
use.  
 
 But JDOM isn't a parser. It's a document tree model.  You invoke a parser
to build the document model. You can insert other things into the pipeline
between parsing and tree construction, for example schema validation.

Each of the 44 message types has a <MessageType>TypeA</MessageType> tag.

 Thanks - we got there in the end.
 
Also the message type is indirectly described in the root element by a
xsi:noNamespaceSchemaLocation="TypeA.xsd" attribute 
 
In that case the simplest thing to do is to use Xerces mechanisms to pick up
the appropriate schema, given this schema location. At this point this
certainly has nothing to do with JDOM, and I bow out because it's not my
area.
 
Michael Kay
http://www.saxonica.com/ 

my code is the following

SAXBuilder builder = new SAXBuilder(" org.apache.xerces.parsers.SAXParser",
true);
        
builder.setFeature("http://apache.org/xml/features/validation/schema",
true);
builder.setProperty (
 
"http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation"
,  
                " TypeA.xsd");

//Load the xml
        Document document;
        document = builder.build("incoming.xml");

Because I am not using namespaces, it's not possible to add more than one
xsd file in the setProperty method... if i used namespaces, i could add as
many as i wanted to, and then the problem would be solved. 




2006/5/10, Michael Kay <mike at saxonica.com>: 


 > What do you meen by tell the rules for choosing a schema? 
 
You said you have 44 message types. Given a message, how do you know what
type of message it's supposed to be?
 
Either you distinguish them by the "channel" they arrived on (e.g. the email
address they were sent to or from, or the incoming FTP directory used), or
you distinguish them by content. If you can't do either, then you're stuck.
 
I'm wondering what all of this has to do with JDOM?

 
Michael Kay
http://www.saxonica.com/ 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.jdom.org/pipermail/jdom-interest/attachments/20060510/0ca403ae/attachment.htm


More information about the jdom-interest mailing list