[
Lists Home |
Date Index |
Thread Index
]
MSXML SOM API, has a IsValid() function that allows validation
of XML content against a specifically retrieved type (element, attribute
or type definition). Great ! However, somehow, (surprisingly), SOM
does not validate against complex content, not so great.
illustrated here,
http://www.mobileworkspace.com/SampleCodes/XSDValidate.html
If IsValid() could be made to support validation of complex content,
IMO it should and I don't see why not, then we can retrieve a
specific definition (a "root" element definition, say) to validate against
the XML content rather than use validate() against a set of global
definitions/declarations and leave it to appropriate substitution
which of course increases the likelihood of accepting un-expected
valid content. This is potentially mind-boggling for any complex
deeply linked schemas even without the obscure surprises;
having many versions of a schema, each explicitly "enforcing" its
own root element to validate for an expected XML input, makes
schema maintenance quite un-manageable too; IMO equally
undesirable.
IsValid() is a good feature and it should strictly validate <only>
against the type specified.
IMO, this greater grain of control could fix some of the ambiguities
raised, albeit from an API angle.
I find both XSD and RNG usable and each has their strength
and weaknesses. I support the call for MSXML to support both
XSD and RNG with a common base object model/API,
so that we can switch between the two via some parameter
twitching and not re-writing complete codes.
----- Original Message -----
From: "Dare Obasanjo" <dareo@microsoft.com>
To: "Thomas B. Passin" <tpassin@comcast.net>; <xml-dev@lists.xml.org>
Sent: Thursday, June 06, 2002 0:03 AM
Subject: RE: [xml-dev] Interesting mailing list & a rare broadside
> OK, I just talked to the dev about this and the bottom line is that
> using the validateOnParse property turns on lax validation while using
> the validate() method call utilizes strict validation. The primary
> rationale for this is rooted in what James Clark pointed out in that
> there is no way to specify what the root element should be in W3C XML
> Schema.
>
> I'll have to investigate if this is pointed out in our docs and if not
> make sure they are updated.
>
> --
> PITHY WORDS OF WISDOM
> Never eat yellow snow.
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
>
>
> > -----Original Message-----
> > From: Thomas B. Passin [mailto:tpassin@comcast.net]
> > Sent: Wednesday, June 05, 2002 6:33 AM
> > To: xml-dev@lists.xml.org
> > Subject: Re: [xml-dev] Interesting mailing list & a rare broadside
> >
> >
> > Now this is really frightening! How could anyone possibly
> > outguess the system to know what the result would be???
> >
> > BTW, I tried the example on the W3C Schema Validator, and it
> > reported that it passed, but using lax validation because
> > there was no declaration for element "bar".
> >
> > Tom P
> >
> > [Dare Obasanjo]
> >
> > Changing the code to
> >
> > var schemas = new ActiveXObject("MSXML2.XMLSchemaCache.4.0");
> > schemas.add("http://www.example.org", "cyclic.xsd");
> >
> > var x = new ActiveXObject("MSXML2.DOMDocument.4.0");
> > x.async = false;
> > x.schemas = schemas;
> > x.validateOnParse = false; /* don't validate on parse */
> > x.load("example.xml");
> >
> > var vError = x.validate(); /* validate, grabbing error
> > object (if any) */
> >
> > /* print error message */
> > if(vError.reason != "")
> > WScript.Echo("invalid: " + vError.reason);
> > else
> > WScript.Echo("valid");
> >
> > Leads to "invalid: Validate failed because the root element
> > had no associated DTD/schema" being displayed. Changing the
> > instance to
> >
> > <foo xmlns="http://www.example.com"/>
> >
> > results in successful validation.
> >
> > --
> > PITHY WORDS OF WISDOM
> > Never eat yellow snow.
> >
> > This posting is provided "AS IS" with no warranties, and
> > confers no rights.
> >
> >
> >
> > > -----Original Message-----
> > > From: James Clark [mailto:jjc@jclark.com]
> > > Sent: Tuesday, June 04, 2002 9:31 PM
> > > To: Dare Obasanjo; Simon St.Laurent; xml-dev@lists.xml.org
> > > Subject: Re: [xml-dev] Interesting mailing list & a rare broadside
> > >
> > >
> > >
> > > > > I'm not sure how many people read those messages
> > > directly, but I'd
> > > > > certainly be unhappy if <bar /> got past the validator
> > when I was
> > > > > expecting <foo /> as in Clark's point 7.
> > > >
> > > > Both the XmlValidatingReader in the .NET framework and MSXML will
> > > > throw errors because no type definition exists for the <bar />
> > > > element.
> > >
> > > One of the parsers I tried it with was the latest version of MSXML
> > > (which I generally find to be excellent, BTW).
> > >
> > > Here's example.xml:
> > >
> > > <bar/>
> > >
> > > Here's example.xsd:
> > >
> > > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > > elementFormDefault="qualified"
> > > xmlns="http://www.example.com"
> > > targetNamespace="http://www.example.com">
> > >
> > > <xs:element name="foo">
> > > <xs:complexType/>
> > > </xs:element>
> > >
> > > </xs:schema>
> > >
> > > Here's the example.js I used to perform the validation:
> > >
> > > var schemas = new ActiveXObject("MSXML2.XMLSchemaCache.4.0");
> > > schemas.add("http://www.example.com", "example.xsd");
> > >
> > > var x = new ActiveXObject("MSXML2.DOMDocument.4.0");
> > > x.async = false;
> > > x.schemas = schemas;
> > > x.validateOnParse = true;
> > > x.load("example.xml");
> > > if (x.parseError.errorCode != 0)
> > > WScript.Echo("invalid: " + x.parseError.reason);
> > > else
> > > WScript.Echo("valid");
> > >
> > > When I run example.js, it says "valid". Note that if you add
> > > xmlns="http://www.example.com" to <bar/>, then it does report it as
> > > invalid.
> > >
> > > Is there something else I should have done to make it report the
> > > example as invalid?
> > >
> > > James
> > >
> > >
> > >
> > >
> > >
> >
> > -----------------------------------------------------------------
> > The xml-dev list is sponsored by XML.org
> > <http://www.xml.org>, an initiative of OASIS
> <http://www.oasis-open.org>
>
> The list archives are at http://lists.xml.org/archives/xml-dev/
>
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://lists.xml.org/ob/adm.pl>
>
>
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
>
> The list archives are at http://lists.xml.org/archives/xml-dev/
>
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://lists.xml.org/ob/adm.pl>
>
>
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
>
> The list archives are at http://lists.xml.org/archives/xml-dev/
>
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://lists.xml.org/ob/adm.pl>
>
>
|