[Mono-list] RE: Xml Schema
A Rafael D Teixeira
Tue, 26 Mar 2002 15:39:23 -0300
>From: "Dwivedi , Ajay Kumar" <AjayKumar.Dwivedi@dresdner-bank.com>
>To: "'Mono Hackers List (E-mail)'" <email@example.com>
>Subject: [Mono-list] RE: Xml Schema
>Date: Tue, 26 Mar 2002 05:55:19 -0000
> Also, there are a few questions in my mind. If someone can answer
>them, I would be very grateful. (I know they are too basic, but i am an
> 1. What is XML Schema compliation (XmlSchema.Compile())? It looks
>like some validation, but why is this compilation done only on schema's and
>not all xml's.
First Compilation does occur for XSLT Templates, too. To compile a Schema is
to dispose all the rules it embodies in a manner that should be very
efficient to validate some document with it. For instance you can construct
a SAX-like parser that rejects any XML input not of the proper form, more
typical is to have a generic parser with a "database" of rules, or a
table-driven state machine.
> 2. What do we do if we find some invalid members. Say someone
>programatically adds an invalid element . Do we remove these elements from
>the schema during compilation/validation?
During compilation you´ll have to throw exceptions for elements of the
schema that does not follow de Schema´s schema (you can think of running the
a validator on the schema using Schema.XSD, but probably implemented in
Validation is done in truth by another class XMLValidatingReader if my
memory doesn´t fail me.
> 3. What is the role of datatypes? I did not find any need for them
>yet. None of them are public, so I am assuming they are used internally
>during validation etc.
Yes they are usefull during validation. Schema datatypes is strong-typing
Let´s say you have this definition for a attribute of a element "message":
<xs:attribute name="priority" type="xs:positiveInteger">
When you have to parse xml snippets of the form:
<message priority="-1" />
<message priority="A" />
<message priority="1.23" />
you´ll have to throw some exception or fire some error event, IN THE
VALIDATING PARSER, not in the schema class proper.
Happy Hackings, to you too
Chat with friends online, try MSN Messenger: http://messenger.msn.com