[Xml-compile] Unexpected elements and attributes
Mark Overmeer
mark at overmeer.net
Wed Apr 14 18:34:34 GMT 2010
* John Hayden (john.hayden at analog.com) [100414 16:42]:
> 1) how can I get the compiled reader to flag elements that I haven't
> declared in my schema?
No: incomplete schema are not permitted, in general afaik. However,
you may be able to trick it by adding your own additional schema
filling-up the missing items. Simple.
> 2) similarly, how can I get it to flag undeclared attributes?
Undeclared makes ignored.
> 3) last, why can't I declare my element's attributes before its
> child elements?
I do not know what you mean exactly.
> <whine> It's a pain in a large schema to have to look for the
> attributes way down after all of the elements.
No, that restriction does not exist. The order of the declarations
of elements and attributes is free.
> When I read the XML,
> the attributes of course appear first within the start tag, followed
> by the child element structure. I'd like the schema to read the same
> way if possible.
Now I think that you mean something different with your question.
You say that schema's are ugly, counter intuative and far too
verbose. You're right on all accounts.
> Here's my simple example. I'd like the unexpected badAttr and <bad>
> elements to cause an error.
If your sequence does not list a certain element, then its appearance
with cause a fatal validation error.
For an attribute, you can declare one within a complexType with
use="prohibited".
> Basically, I'd like to turn on strict checking somehow.
You'll always get strict checking.
--
Regards,
MarkOv
------------------------------------------------------------------------
Mark Overmeer MSc MARKOV Solutions
Mark at Overmeer.net solutions at overmeer.net
http://Mark.Overmeer.net http://solutions.overmeer.net
More information about the Xml-compile
mailing list