Hi
 
I have a Query.xml (XML file) and Query.xsd (Schema file).
 
The Query.xsd has a global attribute named "gid". I have referenced gid in 2 elements in the Query.xml.
 
When I validate the Query.xml against the Query.xsd. I get the following errors.
 
[Error] Query.xml:7:24: Attribute "gid" must be declared for element type "participator".
[Error] Query.xml:10:20: Attribute "gid" must be declared for element type "criteria".
 
 
When I remove the gid attribute from the participator and criteria the validation is successful.But I need to have the gid in the Query.xml file.
 
Please point out the mistake in my files if any or any other suggestions in this regards is welcome.
 
The file contents are below.
------------------------------------------------------------------------------------------------------------------------------------------------------
Query.xsd:
<?xml version="1.0" encoding="utf-8" ?><xsd:schema xmlns:xsd="https://www.w3.org/2000/10/XMLSchema" targetNamespace="http://www.querybuilder.org" xmlns="http://www.querybuilder.org" elementFormDefault="qualified" attributeFormDefault="qualified">
<!-- define field --><xsd:element name="field" type="xsd:string"/>
<!-- define the Constant element --><xsd:element name="constant" type="xsd:string"/>
<!-- define Dependant element --><xsd:element name="dependant" type="xsd:string"/>
<!-- define independent element --><xsd:element name="independent" type="xsd:string"/>
<!-- define the attributes --><xsd:attribute name="gid" type="xsd:string"/>
<!--define the Participators --><xsd:element name="participator"> <xsd:complexType> <xsd:sequence> <xsd:element ref="field" minOccurs="1" maxOccurs="unbounded"/> <xsd:element ref="independent" minOccurs="0" maxOccurs="unbounded"/> <xsd:element ref="dependant" minOccurs="0" maxOccurs="unbounded"/> <xsd:element ref="constant" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> <xsd:attribute ref="gid"/> </xsd:complexType></xsd:element>
<!-- define Criteria --><xsd:element name="criteria"> <xsd:complexType> <xsd:sequence> <xsd:element ref="field" minOccurs="1" maxOccurs="unbounded" /> <xsd:element ref="independent" minOccurs="1" maxOccurs="unbounded"/> <xsd:element ref="dependant" minOccurs="0" maxOccurs="unbounded" /> <xsd:element ref="constant" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> <xsd:attribute ref="gid"/> </xsd:complexType></xsd:element>
<!-- define query --><xsd:element name="Query"> <xsd:complexType> <xsd:sequence> <xsd:element name="participator" minOccurs="1" maxOccurs="unbounded"/> <xsd:element name="criteria" minOccurs="1" maxOccurs="unbounded" /> </xsd:sequence> </xsd:complexType></xsd:element></xsd:schema>
------------------------------------------------------------------------------
Query.xml:
<?xml version="1.0"?><Query xmlns="http://www.querybuilder.org" xmlns:xsi="https://www.w3.org/2000/10/XMLSchema-instance" xsi:schemaLocation= "http://www.querybuilder.org Query.xsd"><participator gid="p1"> <field>CUSTOMER.CUSTOMER_NAME</field> </participator><criteria gid="c1"> <field>CUSTOMER.CUSTOMER_NAME</field> <independent>=</independent> <constant>40</constant> </criteria></Query>
------------------------------------------------------------------------------
Regards
Deepa Nadig