[Xml-compile] Unexpected elements and attributes

Mark Overmeer mark at overmeer.net
Thu Apr 15 07:33:29 GMT 2010


* John Hayden (john.hayden at analog.com) [100414 22:49]:
> 4) The user misunderstands the spec and adds an extra attribute
>    that shouldn't exist.
> Here, XML::Compile is silent, and the user thinks everything is
> okay, but then he gets confused when his attribute doesn't seem
> to have the effect he expects.  This could be frustrating
> and could lead to errors in the project.

Schema's tell what is correct, not what is wrong.

> Is there a way to specify an attribute name in <xsd:attribute> using
> wildcards? This way I could have a default spec something like
>     <xsd:attribute name_pattern=".*" use="prohibited"/>

No, not that way.  However, with anyAttribute you can restrict understanding
to certain namespaces. On the other hand, most people do not use namespaces
on attributes in the first place.

> Of course it would be easier on the developer to have an option
> to XML::Compile to specify whether unmatched attributes are or
> are not errors. Any chance that you would consider such an option?

My wish is to stay close to the standard. Additional attributes may get
added by, for instance, an XML database; which would mean that documents
once stored in there, will not be accepted by your app anymore.

> Okay, I see. I can see how this would be helpful in some cases, e.g. to
> suppress text style tags like <B> and <I> and <EM> and just return
> the content.

Officially, those must be encoded &lt;B&gt; or in CDATA[[...]]

> Is there a different type declaration besides "xsd:string" that would not
> perform the "text flattening" operation implemented here?

> Sounds pretty scary... I just want things to be simple.

Schema's are not simple, and certainly far too verbose. Relax-NG
demonstrates how simple it could be. On the other hand, at least it is
a commonly spread formalism which provides means to describe interfaces
in sufficient detail.
-- 
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