<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<tt>Mark Overmeer wrote:<br>
<br>
Mark,<br>
Thanks so much for writing back so quickly. I'm really impressed with
the XML::Compile package.<br>
<br>
</tt>
<blockquote cite="mid:20100414183434.GA17602@moon.overmeer.net"
 type="cite">
  <pre wrap="">* John Hayden (<a class="moz-txt-link-abbreviated" href="mailto:john.hayden@analog.com">john.hayden@analog.com</a>) [100414 16:42]:
  </pre>
  <blockquote type="cite">
    <pre wrap="">1) how can I get the compiled reader to flag elements that I haven't
   declared in my schema?
    </pre>
  </blockquote>
  <pre wrap=""><!---->
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.
  </pre>
</blockquote>
<tt>I agree, I'd expect schema to have to be complete, so that any
element<br>
or attribute found in the XML that does not match a declaration in the
schema<br>
should be an error. <br>
<br>
I don't think I should have to declare elements or attributes as
"prohibited";<br>
I think if they're not in the schema they should be prohibited by
default.<br>
But the reader in this example does not complain about badAttr or the
element &lt;bad&gt;;<br>
it simply drops it from the data it returns.<br>
<br>
In contrast XML::Validator does detect an error for XML containing
these undeclared items.<br>
</tt>
<blockquote cite="mid:20100414183434.GA17602@moon.overmeer.net"
 type="cite">
  <pre wrap=""></pre>
  <blockquote type="cite">
    <pre wrap="">2) similarly, how can I get it to flag undeclared attributes?
    </pre>
  </blockquote>
  <pre wrap=""><!---->
Undeclared makes ignored.
  </pre>
  <blockquote type="cite">
    <pre wrap="">3) last, why can't I declare my element's attributes before its
child elements?... It's a pain in a large schema to have to look for the
attributes way down after all of the elements.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
No, that restriction does not exist. The order of the declarations
of elements and attributes is free.
  </pre>
</blockquote>
<tt>In fact, though, I get an error. Consider this schema, which works
properly:<br>
<br>
&lt;?xml version="1.0" encoding="utf-8"?&gt;<br>
&lt;xsd:schema xmlns:xsd=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a>&gt;<br>
&nbsp; &lt;xsd:element name="top"&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;xsd:complexType&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:sequence&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:element name="bottom" type="xsd:string"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xsd:sequence&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:attribute name="goodAttr"&nbsp; type="xsd:string"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xsd:complexType&gt;<br>
&nbsp; &lt;/xsd:element&gt;<br>
&lt;/xsd:schema&gt;<br>
<br>
... but when I move the attribute line above the sequence as shown here,<br>
the schema gives an error message (when compiling the reader):<br>
<br>
&lt;?xml version="1.0" encoding="utf-8"?&gt;<br>
&lt;xsd:schema xmlns:xsd=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a>&gt;<br>
&nbsp; &lt;xsd:element name="top"&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;xsd:complexType&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:attribute name="goodAttr"&nbsp; type="xsd:string"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:sequence&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:element name="bottom" type="xsd:string"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xsd:sequence&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xsd:complexType&gt;<br>
&nbsp; &lt;/xsd:element&gt;<br>
&lt;/xsd:schema&gt;<br>
<br>
=&gt; error: trailing non-attribute `sequence' at top<br>
<br>
</tt>
<blockquote cite="mid:20100414183434.GA17602@moon.overmeer.net"
 type="cite">...<br>
  <blockquote type="cite">
    <pre wrap="">Here's my simple example. I'd like the unexpected badAttr and &lt;bad&gt;
elements to cause an error.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
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".

  </pre>
  <blockquote type="cite">
    <pre wrap="">Basically, I'd like to turn on strict checking somehow.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
You'll always get strict checking.
  </pre>
</blockquote>
<tt>Good - that's what I want too. But some items are getting through
the checks.<br>
<br>
</tt>
</body>
</html>