Hello, I am using xerces 2.9.1, for schema validation. I want to validate multiple xsds for validation. Actually if namespaces are same in xsds, it is taking only first xsd from the array, if multiple xsds are existing with same namespace in array.
I doubt on the the schema language is used here is creating problem. here is my code... any clue how I can resolve this. ??? --- Parent XSD -- OutputMessage.xsd <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:bons0="http://VisualizationServicePublicLIB/bo" targetNamespace="http://VisualizationServicePublicLIB/bo"> <xsd:element name="out" type="bons0:OutputMessage" ></xsd:element> <xsd:complexType name="OutputMessage"> <xsd:sequence> <xsd:element minOccurs="1" name="status" type="xsd:string"/> <xsd:element minOccurs="0" name="file" type="bons0:File"/> </xsd:sequence> </xsd:complexType> </xsd:schema> --- Child XSD - File.xsd <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://VisualizationServicePublicLIB/bo"> <xsd:complexType name="File"> <xsd:sequence> <xsd:element minOccurs="1" name="type" type="xsd:string"/> <xsd:element minOccurs="1" name="content" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:schema> ---xml file for validation --- xmlFile.xml <?xml version="1.0" encoding="UTF-8"?> <bons0:out xmlns:bons0="http://VisualizationServicePublicLIB/bo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <status>status</status> <file> <type>type</type> <content>content</content> </file> </bons0:out> Code for validation -- public static void { try { SchemaFactory factory = SchemaFactory .newInstance("http://www.w3.org/2001/XMLSchema"); Source[] xsdAray = new Source[2]; xsdAray[1]= new StreamSource("./File.xsd"); xsdAray[0]= new StreamSource("./OutputMessage_new.xsd"); Schema schema = factory.newSchema(xsdAray); Validator validator = schema.newValidator(); //this xml file contain valid xml source Source source = new StreamSource("./xmlFile.xml"); validator.validate(source); System.out.println(" xml is valid."); } catch (SAXException ex) { System.out.println(" xml is not valid "); System.out.println(ex.getMessage()); ex.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (Exception e1) { e1.printStackTrace(); } } If i am giving <xsd:include schemaLocation="File.xsd" /> in Output.xsd then its working fine ---Krishna binyala --------------------------------------------------------------------- To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org For additional commands, e-mail: j-users-h...@xerces.apache.org