I am trying to validate an XML document against an XML Schema .
The Error i get is Unknown Element ‘jobinfo’ which exists at the root of
the hierarchy. The element ‘jobinfo’ is there in the XML Schema . I am a newbie to this area. Can anyone help pls ?
Here is my XML
<?xml version="1.0" encoding="utf-8"?>
<saw:jobInfo xmlns:saw="com.analytics.web/report/v1.1">
<saw:jobStats>...........</saw:jobStats>
<saw:detailedInfo> .....</saw:detailedInfo>
<saw:fileInfo>..........</saw:fileInfo>
</saw:jobInfo>
Here is my XSD
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace="com.analytics.web/report/v1.1"
xmlns="com.analytics.web/report/v1.1" xmlns:saw="com.analytics.web/report/v1.1"
xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="jobInfo" type="jobInfo"/>
<xs:complexType name="jobInfo">
<xs:sequence>
<xs:element name="jobStats" type="jobStats" minOccurs="1" maxOccurs="1"/>
<xs:element name="detailedInfo" type="detailedInfo" minOccurs="0" maxOccurs="1"/>
<xs:element name="fileInfo" type="fileInfo" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
< other elements>
The problem with your element type
jobStats,detailedInfoandfileInfo.Since these types are not defined.
I have modified XSD to this way:-
OUTPUT Sample XML Format will be as follows:
You should specify
xsi:schemaLocationon XML, while validate with XSD.