read about xmlbeans validation here http://xmlbeans.apache.org/docs/2.0.0/guide/conValidationWithXmlBeans.html I test using this code String testschema = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<xsd:schema\n" + " targetNamespace=\"http://www.colis-logistique.com/i-net/wsapi\"\n" + " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n" + " elementFormDefault=\"qualified\">\n" + " <xsd:element name=\"DeclareParcelsAndCustomsResponse\">\n" + " <xsd:complexType>\n" + " <xsd:sequence>\n" + " <xsd:element name=\"Version\" type=\"xsd:string\" minOccurs=\"1\" maxOccurs=\"1\"/>\n" + " <xsd:element name=\"Timestamp\" type=\"xsd:string\" minOccurs=\"1\" maxOccurs=\"1\"/>\n" + " <xsd:element name=\"AckCode\" type=\"xsd:string\" minOccurs=\"1\" maxOccurs=\"1\"/>\n" + " <xsd:element name=\"HMacBase64Code\" type=\"xsd:string\" minOccurs=\"1\" maxOccurs=\"1\"/>\n" + " </xsd:sequence>\n" + " </xsd:complexType>\n" + " </xsd:element>\n" + "</xsd:schema> "; String testxml = "<wsap:DeclareParcelsAndCustomsResponse xmlns:wsap=\"http://www.colis-logistique.com/i-net/wsapi\">\n" + " <wsap:Timestamp>2011-05-02T16:57:33.136Z</wsap:Timestamp>\n" + " <wsap:AckCode>SUCCESS</wsap:AckCode>\n" + " <wsap:HMacBase64Code>ZjY5MDdlYWI4MGQxMGQ3MjM5OTExZmVmNjQ1NjY3ZDY3NTVkYmQ5MGQ4YTViM2JlOTE1OWU3ODFjZGJlYjIxNg==</wsap:HMacBase64Code>\n" + "</wsap:DeclareParcelsAndCustomsResponse> "; SchemaTypeSystem sts1 = XmlBeans.compileXsd(new XmlObject[]{XmlObject.Factory.parse(testschema)}, XmlBeans.getBuiltinTypeSystem(),null); XmlObject x1 = sts1.parse(testxml,sts1.findDocumentType(new QName("http://www.colis-logistique.com/i-net/wsapi","DeclareParcelsAndCustomsResponse")),null); XmlOptions xo = new XmlOptions(); ArrayList<XmlValidationError> errorlist = new ArrayList<XmlValidationError>(); xo.setErrorListener(errorlist); if (!x1.validate(xo)) { for (XmlValidationError e:errorlist) { System.out.println(e.getMessage()); } } and get this output Expected element 'Version@http://www.colis-logistique.com/i-net/wsapi' instead of 'Timestamp@http://www.colis-logistique.com/i-net/wsapi' here in element DeclareParcelsAndCustomsResponse@http://www.colis-logistique.com/i-net/wsapi Expected element 'Version@http://www.colis-logistique.com/i-net/wsapi' instead of 'AckCode@http://www.colis-logistique.com/i-net/wsapi' here in element DeclareParcelsAndCustomsResponse@http://www.colis-logistique.com/i-net/wsapi Expected element 'Version@http://www.colis-logistique.com/i-net/wsapi' instead of 'HMacBase64Code@http://www.colis-logistique.com/i-net/wsapi' here in element DeclareParcelsAndCustomsResponse@http://www.colis-logistique.com/i-net/wsapi Expected element 'Version@http://www.colis-logistique.com/i-net/wsapi' before the end of the content in element DeclareParcelsAndCustomsResponse@http://www.colis-logistique.com/i-net/wsapi using your code, you can do ans.validate(<xmloption>) Jerry On 11/11/2011 11:46 AM, philippe.legay.exte...@telintrans.fr wrote:
--------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@xmlbeans.apache.org For additional commands, e-mail: user-h...@xmlbeans.apache.org |
- xmlsbeans 2.5 does not check sequence order ? philippe . legay . externe
- Re: xmlsbeans 2.5 does not check sequence ... Jacob Danner
- Re: xmlsbeans 2.5 does not check sequence ... Jerry Sy