You are viewing a plain text version of this content. The canonical link for it is here.
Posted to p-dev@xerces.apache.org by Abhinav Modi <ab...@gmail.com> on 2004/08/16 20:38:50 UTC
Xerces (Perl) : Validate subset of schema and ignore other tags ?
Hi,
I have an xml which contains the following
<a>
<aaa>
</aaa>
<!-- aa Is what I am interested in -->
<aa>
</aa>
<bb></bb>
<cc></cc>
</a>
Here, my application requires that <a> (The root element) *must* contain
<aa> tag.
However, tags such as <aaa>, <bb>, <cc>, or anything else might exist -
they are
optional, and I do not know which of them (if at all) will be present.
How do I write the schema for it ?
Using all requires that I know which tags might appear ..
Using any doesnt allow me to check the presence of the specific tag <aa>
Also, this does not work :
<?xml version="1.0" encoding="windows-1252"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.example.org"
targetNamespace="http://www.example.org"
elementFormDefault="qualified" >
<xsd:element name="a" type="aa-type">
<xsd:annotation>
<xsd:documentation>A sample element</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:complexType name="aa-type">
<xsd:sequence>
<xsd:any minOccurs="0" maxOccurs="unbounded"
namespace="http://www.example.org" processContents="skip"/>
<xsd:element name="aa"/>
<xsd:any minOccurs="0" maxOccurs="unbounded"
namespace="http://www.example.org" processContents="skip"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
It fails with :
MESSAGE: Not enough elements to match content model : '((,aa),)'
Any pointers on how to achieve this ?
TIA
--
--
-------------
http://www.abhinavmodi.tk
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org