Hey Stefan Thanks for the patches! I've applied them in CVS. Once the daily build is working again it'll appear in the daily build also.
Would you like to be a committer so you can add patches to the datatype package straight into CVS if you find any other areas it can be fixed or enhanced? James ----- Original Message ----- From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, January 31, 2002 5:27 PM Subject: [dom4j-dev] Some ToDo's in the Datatype package > Hi all, > > i've started working with XML Schema support in the datatype package. > > Here are some proposals for improvement : > (I'm not a Java-Pro, so my workarounds are q & d !) > > The SchemaParser class doesn't handle includes of other schemata. > ------------------------------------ > As a workaround, i added the following lines to SchemaParser.java: > > private static final QName XSD_INCLUDE = QName.get("include", XSD_NAMESPACE); > > /** Parses the given schema document > * > * @param schemaDocument is the document of the XML Schema > */ > public void build( Document schemaDocument ) { > Element root = schemaDocument.getRootElement(); > if ( root != null ) { > > //handle schema includes > Iterator includeIter = root.elementIterator( XSD_INCLUDE); > while (includeIter.hasNext()) { > Element includeElement = (Element) includeIter.next(); > String inclSchemaInstanceURI = includeElement.attributeValue("schemaLocation"); > EntityResolver resolver = schemaDocument.getEntityResolver(); > try { > if ( resolver == null ) { > throw new InvalidSchemaException( "No EntityResolver available so could not resolve the schema URI: " + > inclSchemaInstanceURI ); > } > InputSource inputSource = resolver.resolveEntity( null, inclSchemaInstanceURI ); > if ( inputSource == null ) { > throw new InvalidSchemaException( "Could not resolve the schema URI: " + inclSchemaInstanceURI ); > } > SAXReader reader = new SAXReader(); > Document inclSchemaDocument = reader.read( inputSource ); > build( inclSchemaDocument ); > } > catch (Exception e) { > System.out.println( "Failed to load schema: " + inclSchemaInstanceURI ); > System.out.println( "Caught: " + e ); > e.printStackTrace(); > throw new InvalidSchemaException( "Failed to load schema: " + inclSchemaInstanceURI ); > } > } > > //handle elements > .... > > Missing support of element types, derived from simpleType: > -------------------------------------------------------------------------- ------- > > // Implementation methods > //------------------------------------------------------------------------- > > /** processes an XML Schema <element> tag > */ > protected void onDatatypeElement( Element xsdElement , DocumentFactory parentFactory ) { > String name = xsdElement.attributeValue( "name" ); > String type = xsdElement.attributeValue( "type" ); > QName qname = getQName( name ); > > DatatypeElementFactory elementFactory = getDatatypeElementFactory( qname ); > > if ( type != null ) { > // register type with this element name > XSDatatype dataType = getTypeByName(type); > if (dataType!=null) { > elementFactory.setChildElementXSDatatype( qname, dataType ); > } > else { > QName typeQName=getQName(type); > namedTypeResolver.registerTypedElement(xsdElement,typeQName,parentFactory); > } > return; > } > > // handle element types derrived from simpleTypes > Element xsdSimpleType = xsdElement.element( XSD_SIMPLETYPE ); > if ( xsdSimpleType != null ) { > System.out.println("Agfa-sg: handle element types derrived from simpleTypes for element: " + name); > XSDatatype dataType = loadXSDatatypeFromSimpleType( xsdSimpleType ); > if (dataType != null) { > System.out.println("dataType (from loadXSDatatypeFromSimpleType) = " + dataType); > elementFactory.setChildElementXSDatatype( qname, dataType ); > } > } > > > Element schemaComplexType = xsdElement.element( XSD_COMPLEXTYPE ); > ..... > > > Greetings > Stefan Graeber > > > _______________________________________________ > dom4j-dev mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/dom4j-dev _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com _______________________________________________ dom4j-dev mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-dev