[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Interesting mailing list & a rare broadside


xsd validation new activexobject

> > 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





PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.