XSDPreparser
Gruppe |
|
Funktion |
Kann eine XML-Datei mit einer XSD-Datei validieren. |
Konfiguration |
Properties-Datei oder Variable. |
Beschreibung
Dieser Preparser kann eine XML-Datei mit einer XSD-Datei validieren.
Als Ergebnis bekommt man eine XML-Datei mit einer Liste (kann leer sein) der gefundenen Fehler. Siehe Beispiel unten.
Der Preparser erwartet den Pfad zu einer Properties-Datei, die den Pfad zur XSD-Datei enthält. Alternativ kann der Pfad zur XSD-Datei auch von einem Vorgänger-Profil in der Variable XSD_PATH übergeben werden. Hinweis: Variable muss im Vorgänger-Profil genau so benannt sein, im Nachfolge-Profil aber nicht angelegt werden.
Parameterbeschreibung
Parameter |
Beschreibung |
xsdPath |
Pfad zur XSD-Datei. |
Beispiel
Pfad zu Properties-Datei: ./conf/myxsd.properties
xsdPath=./conf/my.xsd
XSD-Datei:
<
xsd
:schema
xmlns:xsd
=
"http://www.w3.org/2001/XMLSchema"
targetNamespace
=
"urn:books"
xmlns:bks
=
"urn:books"
>
<
xsd
:element
name
=
"books"
type
=
"bks:BooksForm"
/>
<
xsd
:complexType
name
=
"BooksForm"
>
<
xsd
:sequence>
<
xsd
:element
name
=
"book"
type
=
"bks:BookForm"
minOccurs
=
"0"
maxOccurs
=
"unbounded"
/>
</
xsd
:sequence>
</
xsd
:complexType>
<
xsd
:complexType
name
=
"BookForm"
>
<
xsd
:sequence>
<
xsd
:element
name
=
"author"
type
=
"xsd:string"
/>
<
xsd
:element
name
=
"title"
type
=
"xsd:string"
/>
<
xsd
:element
name
=
"genre"
type
=
"xsd:string"
/>
<
xsd
:element
name
=
"price"
type
=
"xsd:float"
/>
<
xsd
:element
name
=
"pub_date"
type
=
"xsd:date"
/>
<
xsd
:element
name
=
"review"
type
=
"xsd:string"
/>
</
xsd
:sequence>
<
xsd
:attribute
name
=
"id"
type
=
"xsd:string"
/>
</
xsd
:complexType>
</
xsd
:schema>
Eingangs-XML-Datei:
<?
xml
version
=
"1.0"
?>
<
x
:books
xmlns:x
=
"urn:books"
>
<
book
id
=
"bk001"
>
<
author
>Writer</
author
>
<
title
>The First Book</
title
>
<
genre
>Fiction</
genre
>
<
price
>44.95</
price
>
<
pub_date
>2000-10-01</
pub_date
>
<
review
>An amazing story of nothing.</
review
>
</
book
>
<
book
id
=
"bk002"
>
<
author
>Poet</
author
>
<
title
>The Poet's First Poem</
title
>
<
genre
>Poem</
genre
>
<
price
>24.95</
price
>
<
review
>Least poetic poems.</
review
>
</
book
>
</
x
:books>
Ergebnis des Preparsers:
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<
errors
>
<
error
>cvc-complex-type.2.4.a: Invalid content was found starting with element 'review'. One of '{pub_date}' is expected.</
error
>
</
errors
>