Hi , I try to use the XML-Schema <appinfo> Tag with the Castor schema parser, but I get a SAX Exception:
D:\>java -cp "D:\Projekte\xerces-2_0_0\xercesImpl.jar;D:\Projekte\xerces-2_0_0\xmlParserA PIs.jar;D:\Projekte\castor-093.9\castor-0939.jar;." CastorTest java.io.IOException: org.xml.sax.SAXException: 'app:Type_info' has not been decl ared in the XML Schema namespace. line: 8 D:\> Here are the schema files: Base schema : >castor_ex_source.xsd< <?xml version="1.0" encoding="UTF-8"?> <xs:schema targetNamespace="http://www.risa.de/castor_ex_source" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.risa.de/castor_ex_source" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="Type_info"> <xs:annotation> <xs:documentation>Comment describing your root element</xs:documentation> </xs:annotation> </xs:element> </xs:schema> Child schema : >castor.xsd< <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:app="http://www.risa.de/castor_ex_source" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:import namespace="http://www.risa.de/castor_ex_source" schemaLocation="castor_ex_source.xsd"/> <xs:element name="Element_A" type="xs:string"> <xs:annotation> <xs:documentation>Comment describing your root element</xs:documentation> <xs:appinfo> <app:Type_info>4711</app:Type_info> </xs:appinfo> </xs:annotation> </xs:element> </xs:schema> and the java source >CastorTest.java< import java.io.*; import java.io.IOException; import java.util.*; import javax.xml.parsers.*; import org.xml.sax.SAXException; import org.xml.sax.InputSource; import org.xml.sax.SAXParseException; import org.exolab.castor.xml.schema.reader.*; import org.exolab.castor.xml.ValidationException; import org.exolab.castor.xml.schema.*; /** * @author RISA * @author Vico KLump * @version 1 */ public class CastorTest { private static String strSchema = "castor.xsd"; public void testCastor(){ InputSource source = new InputSource(strSchema); try { SchemaReader schemaReader = new SchemaReader(source); Schema schema = schemaReader.read(); try { schema.validate(); } catch(ValidationException e) { System.err.println(e); } Enumeration enum = schema.getComplexTypes(); while(enum.hasMoreElements()){ ComplexType ct = (ComplexType) enum.nextElement(); System.out.println( ct.getName() ); } } catch(IOException e) { System.err.println(e); } } /** Main method */ public static void main(String[] args) { CastorTest test = new CastorTest(); test.testCastor(); } } If I use XMLspy or Xerces to validate the schema I get no error. Has anyone an idea how to integrate extra tags in <appinfo> ? Best Regards Vico. Attached: castor.xsd castor_ex_source.xsd CastorTest.java ---------------------------------------------------- Vico Klump
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:app="http://www.risa.de/castor_ex_source" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:import namespace="http://www.risa.de/castor_ex_source" schemaLocation="castor_ex_source.xsd"/> <xs:element name="Element_A" type="xs:string"> <xs:annotation> <xs:documentation>Comment describing your root element</xs:documentation> <xs:appinfo> <app:Type_info>4711</app:Type_info> </xs:appinfo> </xs:annotation> </xs:element> </xs:schema>
<?xml version="1.0" encoding="UTF-8"?> <xs:schema targetNamespace="http://www.risa.de/castor_ex_source" xmlns="http://www.risa.de/castor_ex_source" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="Type_info"> <xs:annotation> <xs:documentation>Comment describing your root element</xs:documentation> </xs:annotation> </xs:element> </xs:schema>
CastorTest.java
Description: JavaScript source
