Hello all,
I am new to xerces and xml schema.
I have written a XmlSchemaValidate and error handler using an external =
schema.
The schema is fairly basic and so is the xml. However, while testing I =
have noticed that the validate doesnt seem to be picking up errors if =
elements are missing.=20
It only notices if the xml document is not well formed. Otherwise it =
tells me that the validation is successful.
I would be grateful for any ideas.
Thanks in advance,
Orla
Here is the xsd:
<?xml version=3D"1.0" encoding=3D"UTF-8"?>
<xs:schema
xmlns:xs=3D"http://www.w3.org/2001/XMLSchema">
<xs:element name=3D"sessionfacade">
<xs:complexType>
<xs:sequence>
<xs:element name=3D"output">
<xs:complexType>
<xs:sequence>
<xs:element name=3D"customer" =
maxOccurs=3D"unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name=3D"bskid" type=3D"xs:string"/>
<xs:element name=3D"name" type=3D"xs:string"/>
<xs:element name=3D"additionalname" =
type=3D"xs:string"/>
<xs:element name=3D"street" type=3D"xs:string"/>
<xs:element name=3D"housenumber" =
type=3D"xs:string"/>
<xs:element name=3D"city" type=3D"xs:string"/>
<xs:element name=3D"zip" type=3D"xs:string"/>
<xs:element name=3D"country" type=3D"xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name=3D"errors" type=3D"xs:string"/>
</xs:sequence> =20
</xs:complexType>
</xs:element>
</xs:schema>
Here is the xml
<?xml version=3D"1.0" encoding=3D"UTF-8"?>
<sessionfacade>
<output>
<customer>
<bskid>22</bskid>
<name>TestCustomer1</name>
<additionalname>TestCustomer1_add</additionalname>
<street>Bahnhofstr</street>
<housenumber>1</housenumber>
<city>Bern</city>
<zip>3000</zip>
<country>1</country>
</customer>
</output>
<errors/>
</sessionfacade>
Code Snippet:
XmlErrorHandler err =3D new XmlErrorHandler();
parser.setErrorHandler(err);
=20
try {
System.out.println("xmlSchemaValidate - Schema is " + =
pSchema);
=
parser.setProperty("http://apache.org/xml/properties/schema/external-sche=
maLocation",
pSchema);
=
parser.setProperty("http://apache.org/xml/properties/schema/external-noNa=
mespaceSchemaLocation",=20
pSchema);
parser.setFeature("http://xml.org/sax/features/validation", =
true);
parser.setFeature("http://xml.org/sax/features/namespaces", =
true);
=
parser.setFeature("http://apache.org/xml/features/dom/defer-node-expansio=
n", false);
=20
parser.parse(pInputSource);
=20
}
catch (SAXException lxException){
System.out.println("SAXException");
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]