9
Schema validation with java xml xsd 8.10.08

Schema validation with java

  • Upload
    ganit

  • View
    25

  • Download
    0

Embed Size (px)

DESCRIPTION

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 { - PowerPoint PPT Presentation

Citation preview

Page 1: Schema validation with java

Schema validationwith java

xml xsd 8.10.08

Page 2: Schema validation with java

08.10.08 2

Agenda

Umgebung

Programm

Output

Page 3: Schema validation with java

08.10.08 3

Umgebung

Eclipse 3.3.1.1

Java 1.5

Erweiterung http://jdom.org/dist/binary

java archives: jdom.jar und xerces.jar

Page 4: Schema validation with java

08.10.08 4

Program public class Xmlschema {

public static void 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() );}}}

Page 5: Schema validation with java

08.10.08 5

“Output”

Page 6: Schema validation with java

08.10.08 6

“Output”

Page 7: Schema validation with java

08.10.08 7

schema location

File: defineexample1.xml

xsi:schemaLocation="http://www.cdisc.org/ns/odm/v1.2 define1-0-0.xsd"

Page 8: Schema validation with java

08.10.08 8

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">

Page 9: Schema validation with java

08.10.08 9

Fragen

Gibt es andere Lösungen (sas) ?