[jdom-interest] Parsing AND validating a schema

Paul Cooper paul_cooper_premis at hotmail.com
Mon Jan 24 14:30:29 PST 2005

I've searched and searched, and tried all sorts of combinations of features 
and properties, and I cannot figure out how to validate a schema. Yes, 
that's right, a schema. I'm trying to treat the schema as if it were an 
actual XML file, and parsing is no problem. But validation is, so I'm hoping 
someone can provide insight. I'm pointing the schema for my schema to the 
correct location, BTW.

Here's my code:
private static void init(InputStream is) throws IOException, JDOMException {
    BufferedReader br = new BufferedReader(new InputStreamReader(is, 
    SAXBuilder builder = new 
SAXBuilder("org.apache.xerces.parsers.SAXParser", true);
    builder.setFeature("http://xml.org/sax/features/namespaces", true);
    _document = builder.build(br);

I won't post the whole schema here, but it dies on the first line:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
elementFormDefault="qualified" attributeFormDefault="unqualified">
  <xs:simpleType name="AbdomenLeftUpperAssessment">
      <xs:documentation>The assessment of the patients left upper 

The exception I get:
org.jdom.input.JDOMParseException: Error on line 3: cvc-elt.1: Cannot find 
the declaration of element 'xs:schema'.
	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:468)
	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:851)
	at org.premis.xml.PreMISDocument.init(PreMISDocument.java:50)
	at org.premis.xml.PreMISDocument.create(PreMISDocument.java:66)
	at org.premis.nemsis.Reader.doIt(Reader.java:29)
	at org.premis.nemsis.Reader.main(Reader.java:54)

Clearly this is a namespace issue, but for the life of me I cannot figure 
out what the parser wants. Can anyone shed some light into this dilemma???


Paul Cooper

On the road to retirement? Check out MSN Life Events for advice on how to 
get there! http://lifeevents.msn.com/category.aspx?cid=Retirement

More information about the jdom-interest mailing list