[jdom-interest] In a fit of madness...

Neil Blue neil.blue at denovopharma.com
Wed Oct 24 09:34:44 PDT 2001


I am now going mad after trying to get XMLSchema validation working. 
Here is what I now have:


jdom b7
xerces 2.0 beta 2

The code:

import java.io.*;
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;

public class SAXBuilderDemo
   public static void main( String[] args )
       throws Exception
       SAXBuilder builder = new SAXBuilder( true );
       Document doc = builder.build( "contents.xml" );
       System.err.println( doc );

the xml file:

<?xml version="1.0"?>
<Book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   <title>Test string</title>

the schema file:

<?xml version="1.0"?>
<schema xmlns="http://www.w3c.org/2001/XMLSchema">
   <element name="Book" type="BookType"/>
   <complexType name="BookType">
       <element name="titlex" type="string"/>

but I still get the error when running:

Exception in thread "main" org.jdom.JDOMException: Error in building: 
Document root element "Book", must match DOCTYPE root "null".

however if I turn off validation with:

       SAXBuilder builder = new SAXBuilder(  );

there is no schema validation. Which I would expect as title is defined 
as 'titlex' in the schema and 'title' in the xml file.

Does anyone else also have this problem?


More information about the jdom-interest mailing list