<!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>Thanks again, Mark, for your help.<br>
<br>
Mark Overmeer wrote:</tt>
<blockquote cite="mid:20100414220414.GC17602@moon.overmeer.net"
 type="cite">
  <pre wrap=""><tt>* John Hayden (<a class="moz-txt-link-abbreviated" href="mailto:john.hayden@analog.com">john.hayden@analog.com</a>) [100414 18:57]:
</tt></pre>
  <blockquote type="cite">
    <pre wrap=""><tt>I don't think I should have to declare elements or attributes as "prohibited";
</tt></pre>
  </blockquote>
  <pre wrap=""><!----><tt>
Well, actually don't try to think: your brain will hurt when you try to
understand the designers of schemas. </tt></pre>
</blockquote>
<tt>I'm starting to see that already. :)<br>
</tt>
<blockquote cite="mid:20100414220414.GC17602@moon.overmeer.net"
 type="cite">
  <pre wrap=""><tt> Elements and attributes are quite
different. Elements are only allowed when you specify them explicitly
(or "any"). Attributes are always permitted, but only understood when
you specify them. It's designed that way.
</tt></pre>
</blockquote>
<tt>Okay. In my world, however, (in which not all hair has yet been
torn out),<br>
I want to strictly constrain the contents of an XML file that contains
important<br>
specifications for a machine. I want to protect against user mistakes.
Cases:<br>
<br>
1) user misspells an attribute name. Here I think we're covered, if the
<br>
attribute with the correct name is defined as "required", because it
won't be found.<br>
2) user leaves out a required attribute: same deal, we're good.<br>
3) we change the specification and an old attribute goes away, and we
want to catch<br>
cases where the old usage hasn't been removed. Here I also think<br>
we're covered, because we can leave the old attribute in and change it
to "prohibited".<br>
4) The user misunderstands the spec and adds an extra attribute that
shouldn't exist.<br>
Here, XML::Compile is silent, and the user thinks everything is okay,
but then he gets confused<br>
when his attribute doesn't seem to have the effect he expects.&nbsp; This
could be frustrating<br>
and could lead to errors in the project.<br>
<br>
Is there a way to specify an attribute name in &lt;xsd:attribute&gt;
using wildcards?<br>
This way I could have a default spec something like <br>
&nbsp;&nbsp;&nbsp; &lt;xsd:attribute name_pattern=".*" use="prohibited"/&gt;<br>
<br>
Of course it would be easier on the developer to have an option to
XML::Compile<br>
to specify whether unmatched attributes are or are not errors. <br>
Any chance that you would consider such an option?<br>
<br>
</tt>
<blockquote cite="mid:20100414220414.GC17602@moon.overmeer.net"
 type="cite">
  <blockquote type="cite">
    <pre wrap=""><tt>I think if they're not in the schema they should be prohibited by default.
But the reader in this example does not complain about badAttr or the element
&lt;bad&gt;; it simply drops it from the data it returns.
</tt></pre>
  </blockquote>
  <pre wrap=""><!----><tt>
Your example is flawed: the "bottom" is declared as string and interpreted
as string.  That means that &lt;bad&gt; is not an element but simply part
of the string.

In the implementation, XML::Compile bluntly takes the $node-&gt;textContent
when it needs the string value. However, it may be needed to check for
childs. I do not know what the spec says about it. Anyway: XML::Compile
takes the simplest take for the moment until proven wrong.
</tt></pre>
</blockquote>
<tt>Okay, I see. I can see how this would be helpful in some cases,
e.g. to suppress text style<br>
tags like &lt;B&gt; and &lt;I&gt; and &lt;EM&gt; and just return the
content.<br>
<br>
I'm not sure about the spec either.&nbsp; BTW two of the other validators
(XML::Validator <br>
and EMACS RNG/nXML-mode) both signal this as an error.<br>
<br>
Is there a different type declaration besides "xsd:string" that would
not<br>
perform the "text flattening" operation implemented here?<br>
<br>
</tt>
<blockquote cite="mid:20100414220414.GC17602@moon.overmeer.net"
 type="cite">
  <pre wrap=""></pre>
  <blockquote type="cite">
    <pre wrap=""><tt>... but when I move the attribute line above the sequence as shown here,
the schema gives an error message (when compiling the reader):

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&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;
  &lt;xsd:element name="top"&gt;
    &lt;xsd:complexType&gt;
      &lt;xsd:attribute name="goodAttr"  type="xsd:string"/&gt;
      &lt;xsd:sequence&gt;
        &lt;xsd:element name="bottom" type="xsd:string"/&gt;
      &lt;/xsd:sequence&gt;
     &lt;/xsd:complexType&gt;
  &lt;/xsd:element&gt;
&lt;/xsd:schema&gt;

=&gt; error: trailing non-attribute `sequence' at top
</tt></pre>
  </blockquote>
  <pre wrap=""><!----><tt>
Yes, it is a violation of the schema schema.  It's just designed that
way. Welcome to my world ;-)  Don't worry, you will tear more hairs
when you see the rest of it.
</tt></pre>
</blockquote>
<tt>Sounds pretty scary... I just want things to be simple.<br>
</tt><br>
</body>
</html>