Hello, I'm having a problem using the xml schema API. In the line: XSModel schema = rootPSVI.getSchemaInformation(); The method getSchemaInformation() is always returning null. I send the code, I hope somebody can help me. thanks a lot!
I'm using the following code to retrieve the xml schema information: DOMParser parser = new DOMParser(); parser.setFeature("http://xml.org/sax/features/namespaces", true); parser.setFeature("http://xml.org/sax/features/validation", true); parser.setFeature("http://apache.org/xml/features/validation/schema", true); parser.setFeature("http://apache.org/xml/features/validation/schema-full-checking", true); String id = "http://apache.org/xml/properties/dom/document-class-name"; Object value = "org.apache.xerces.dom.PSVIDocumentImpl"; try { parser.setProperty(id, value); } catch (SAXException e) { System.err.println("could not set parser property"); } parser.parse("NewFile.xml"); Document document = parser.getDocument(); Element root = document.getDocumentElement(); //retrieve PSVI for the root element ElementPSVI rootPSVI = (ElementPSVI)root; //retrieve the schema used in validation of this document XSModel schema = rootPSVI.getSchemaInformation(); XSNamedMap elementDeclarations = schema.getComponents(XSConstants.ELEMENT_DECLARATION); // get schema normalized value String normalizedValue = rootPSVI.getSchemaNormalizedValue(); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } This is my xml file: <?xml version="1.0" encoding="UTF-8"?> <personas xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="NewFile.xsd" > <persona> <nombre>hgh</nombre> <apellido>eee</apellido> </persona> </personas> and NewFile.xsd is like this: <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="apellido" type="xsd:string"/> <xsd:element name="nombre" type="xsd:string"/> <xsd:element name="persona"> <xsd:complexType> <xsd:sequence> <xsd:element ref="nombre"/> <xsd:element ref="apellido"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="personas"> <xsd:complexType> <xsd:sequence> <xsd:element ref="persona"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> ___________________________________________________________ 100mb gratis, Antivirus y Antispam Correo Yahoo!, el mejor correo web del mundo http://correo.yahoo.com.ar --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]