90 likes | 238 Views
Schema validation with java. xml xsd 8.10.08. Agenda. Umgebung Programm Output. Umgebung. Eclipse 3.3.1.1 Java 1.5 Erweiterung http://jdom.org/dist/binary java archives: jdom.jar und xerces.jar. public class Xmlschema { public static void main( String[] args ) { try {
E N D
Schema validationwith java xml xsd 8.10.08
Agenda • Umgebung • Programm • Output 08.10.08
Umgebung • Eclipse 3.3.1.1 • Java 1.5 • Erweiterung http://jdom.org/dist/binary • java archives: jdom.jar und xerces.jar 08.10.08
publicclass Xmlschema { publicstaticvoid main( String[] args ) {try { File xsdFile = new File(“c:\countries.xsd"); File xmlFile = new File(“c:\countries.xml"); SAXBuilder builder = new SAXBuilder("org.apache.xerces.parsers.SAXParser", true); builder.setFeature("http://apache.org/xml/features/validation/schema", true); builder.setProperty(http://apache.org/xml/properties/schema + "/external-noNamespaceSchemaLocation", xsdFile.toURL().toString() ); org.jdom.Document doc = builder.build( xmlFile ); System.out.println( "Successfully parsed and validated" ); catch ( Exception cause ) {System.err.println( cause.toString() );}}} Program 08.10.08
“Output” 08.10.08
“Output” 08.10.08
File: defineexample1.xml xsi:schemaLocation="http://www.cdisc.org/ns/odm/v1.2 define1-0-0.xsd" schema location 08.10.08
schemata define1-0-0.xsd <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/03/xml.xsd"/> <xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd"/> <xs:include schemaLocation="http://www.cdisc.org/schema/def/v1.0/define-extension.xsd"/> define-extension.xsd <xs:import namespace="http://www.cdisc.org/ns/def/v1.0" schemaLocation="http://www.cdisc.org/schema/def/v1.0/define-ns.xsd"/> <xs:redefine schemaLocation="http://www.cdisc.org/schema/odm/v1.2.1/ODM1-2-1.xsd"> 08.10.08
Fragen • Gibt es andere Lösungen (sas) ? 08.10.08