| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Re: How do I get all the errors out of MSXML? |
From: "Paul Ranson"
Not my field but...
Surely parsing is distinct from validation against Schema?
In the latter case you could use MSXML5 and validate on a node by node
basis using IXMLDocument3::validateNode. As I said, not my field...
Alternatively does catching error events from SAX during validation solve
the problem?
Paul
"Adam" wrote in message
news:424bc068$1{at}w3.nls.net...
> Dear All,
>
> Still on with XML-XSD validation inc on Windows.
>
> Two questions for the win dev types here.
>
> A)
>
> std bit of jScript to load an XML Doc & to check it against it's schema:
>
> var xmldoc = new ActiveXObject("Msxml2.DOMDocument.4.0");
> xmldoc.async = false;
> xmldoc.load(WScript.Arguments(0));
> var resultstring = new String();
>
> if(xmldoc.parseError.errorCode != 0){
> resultstring="Result=1"+"\n"
> +"Filename="+ WScript.Arguments(0) +"\n"
> +"url="+ xmldoc.parseError.url +"\n"
> +"Error_Code="+ xmldoc.parseError.errorCode + "\n"
> +"Reason="+ xmldoc.parseError.reason
> +"File_Position="+ xmldoc.parseError.filepos + "\n"
> +"Line_Number="+ xmldoc.parseError.line + "\n"
> +"Line_Position="+ xmldoc.parseError.linepos + "\n"
> +"srcText="+ xmldoc.parseError.srcText
> ;
> }
>
>
> or with a declared schema & namespace:
>
> var cache = new ActiveXObject("Msxml2.XMLSchemaCache.4.0");
> cache.add(WScript.Arguments(2), WScript.Arguments(1));
>
> var xmldoc = new ActiveXObject("Msxml2.DOMDocument.4.0");
> xmldoc.async = false;
> xmldoc.schemas = cache;
> xmldoc.load(WScript.Arguments(0));
>
> if(xmldoc.parseError.errorCode != 0){
> resultstring="Result=1"+"\n"
> +"Filename="+ WScript.Arguments(0) +"\n"
> +"url="+ xmldoc.parseError.url +"\n"
> +"Error_Code="+ xmldoc.parseError.errorCode + "\n"
> +"Reason="+ xmldoc.parseError.reason
> +"File_Position="+ xmldoc.parseError.filepos + "\n"
> +"Line_Number="+ xmldoc.parseError.line + "\n"
> +"Line_Position="+ xmldoc.parseError.linepos + "\n"
> +"srcText="+ xmldoc.parseError.srcText
> ;
> }
>
>
> Works fine.....for one error but how do get back all errors (against a
> schema) for a given doc? i.e. imagine I have some valid xml which breaks a
> number of the schema rules. At the moment I just get back (formatted by my
> app):
>
>
> Element content is invalid according to the DTD/Schema.
> 10
> 11
> 373
>
> Which fine except that there are purposely a number of errors in that doc
> vs the schema & th MSXML is bascally running till it hts an error & then
> tells me about that error & that's it.
>
> So how do I get them all out as a result (as an array?)?
>
>
> B) How do I set how strict the checking is? e.g. in Xerces you supply:
>
>
parser.setFeature("http://apache.org/xml/features/validation/schema-full-chec
king",true);
>
> To make it strict or leave it out to make it at it's default level.
>
> TIA
>
> Adam
>
--- BBBS/NT v4.01 Flag-5
* Origin: Barktopia BBS Site http://HarborWebs.com:8081 (1:379/45)SEEN-BY: 633/267 270 5030/786 @PATH: 379/45 1 106/2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.