Class name | com.ebd.hub.datawizard.parser.XSDPreparser |
Description
This preparser can validate an XML file with an XSD file.
The result is an XML file with a list (can be empty) of the errors found. See example below.
The preparser expects the path to a properties file that contains the path to the XSD file. Alternatively, the path to the XSD file can also be transferred from a predecessor profile in the variable "XSD_PATH".
Note: The variable must be named exactly like this in the predecessor profile, but must not be created in the successor profile.
Parameters
Parameter | Description |
|---|---|
xsdPath | Path to XSD file. |
Example
Path to properties file:
xsdPath=./conf/my.xsdXSD file:
<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>Input XML file:
<?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>Result of the preparser:
<?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>