[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: MSXML4: how to validate an XML against an XSD just using IE?
- From: Martin Gudgin <marting@develop.com>
- To: Rene de Vries <RdVries@PCL-HaGe.nl>, xml-dev@lists.xml.org
- Date: Mon, 07 May 2001 11:58:05 +0100
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@PCL-HaGe.nl>
To: <xml-dev@lists.xml.org>
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@yahoogroups.com
>
>
>
> 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@lists.xml.org