Hi, I am trying to use a SAXReader with a schema loaded into a DatatypeDocumentFactory so that I can get properly typed data from the getData() method of an Element. What I have found is that this only works when a schema reference exists in an instance document. If I load the schema using the loadSchema() method or use the SchemaParser it is simply ignored.
I use the following code to parse and load the schema: DatatypeDocumentFactory factory = new DatatypeDocumentFactory(); SAXReader reader = new SAXReader(); Document doc = reader.read(argSchemaLocation.toURL()); Namespace namespace = DocumentHelper.createNamespace( "smclient", "http://www.3eti.com/infomatics/schemas/sm_client_schema"); factory.loadSchema(doc, namespace); ...... SAXReader reader = new SAXReader(factory); Document doc = reader.read(argConfigURI.toURL()); I have an element called perMessageLogging with type xsi:boolean. When I encounter an instance document like this: <SMClientConfig xmlns="http://www.3eti.com/infomatics/schemas/sm_client_schema" xmlns:smclient="http://www.3eti.com/infomatics/schemas/sm_client_schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.3eti.com/infomatics/schemas/sm_client_schema ../schemas/sm_client_schema.xsd"> <perMessageLogging>false</perMessageLogging> </SMClientConfig> Then I can use this to get the value as a Boolean Element elem = (Element) doc.selectSingleNode( "/prefix:SMClientConfig/prefix:perMessageLogging" .replaceAll("prefix", prefix)); if (null != elem) { perMessageLogging = ((Boolean) elem.getData()).booleanValue(); } However, when I remove the schemaLocation from the instance document like this then it is returned as String: <SMClientConfig xmlns="http://www.3eti.com/infomatics/schemas/sm_client_schema" xmlns:smclient="http://www.3eti.com/infomatics/schemas/sm_client_schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <perMessageLogging>false</perMessageLogging> </SMClientConfig> It makes no difference whether I load the schema or not. The only thing that matters is that the schemaLocation is set. Am I doing something wrong? What is the point of loading the schema if it is not used? Thanks, Mark ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ dom4j-user mailing list dom4j-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dom4j-user