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

Re: MSXML4: how to validate an XML against an XSD just using IE?

  • From: Martin Gudgin <marting@d...>
  • To: Rene de Vries <RdVries@P...>, xml-dev@l...
  • Date: Mon, 07 May 2001 11:58:05 +0100

schemasource
Here is some jscript I use outside of IE. Maybe it will give you enough info
to get it working inside an HTML page;


if (WScript.Arguments.length < 2)
{
   WScript.echo("MSXML XML Schema Validation Utility\n");
   WScript.echo("usage: xsdms inputFile schemaFile");
   WScript.Quit(1);
}

var source = WScript.Arguments.Item(0);
var schema = WScript.Arguments.Item(1);
var schemaSource = new ActiveXObject ( "MSXML2.DOMDocument.4.0" );

// load the source document
if (schemaSource.load(schema))
{
  // extract the targetNamespace attribute from the schema using XPath
  schemaSource.setProperty ( "SelectionLanguage", "XPath" );
  schemaSource.setProperty ( "SelectionNamespaces",
"xmlns:a='http://www.w3.org/2001/XMLSchema'" );
  var tnsattr = schemaSource.selectSingleNode (
"/a:schema/@targetNamespace" );
  var nsuri = tnsattr.nodeValue;

  // add the schema to the cache
  var schemaCache = new ActiveXObject("MSXML2.XMLSchemaCache.4.0");
  schemaCache.add ( nsuri, schemaSource );

  // attach the schema cache to a DOM
  var xmlSource = new ActiveXObject("MSXML2.DOMDocument.4.0");
  xmlSource.schemas = schemaCache;
  xmlSource.async = false;

  // load the xml document document
  if (xmlSource.load(source))
  {
    WScript.echo("success: document conforms to DTD/Schema");
  }
  else
  {
    WScript.echo("### error: " + xmlSource.parseError.reason);
    WScript.echo("### source: " + xmlSource.parseError.srcText);
    WScript.echo("### line: " + xmlSource.parseError.line);
  }
}
else
{
  WScript.echo("### error: " + schemaSource.parseError.reason);
  WScript.echo("### source: " + schemaSource.parseError.srcText);
  WScript.echo("### line: " + schemaSource.parseError.line);
}


Regards

Martin Gudgin
DevelopMentor

----- Original Message -----
From: "Rene de Vries" <RdVries@P...>
To: <xml-dev@l...>
Sent: Monday, May 07, 2001 8:48 AM
Subject: MSXML4: how to validate an XML against an XSD just using IE?


> Hi XSD-ers,
>
> Is there a way to validate an XML against an XSD just using IE with MSXML4
> installed?
> If there is, can you send me a sample HTML-code doing this?
>
> Greetings Rene
>    { @   @ }
>         ^
>       \__/
>
> "You don't need eyes to see, you need vision!"
>
>
>
> To unsubscribe from this group, send an email to:
> XSDSchema-unsubscribe@y...
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
> ------------------------------------------------------------------
> The xml-dev list is sponsored by XML.org, an initiative of OASIS
> <http://www.oasis-open.org>
>
> The list archives are at http://lists.xml.org/archives/xml-dev/
>
> To unsubscribe from this elist send a message with the single word
> "unsubscribe" in the body to: xml-dev-request@l...


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.