Hi dear geeks and nerds (I hope that has no bad connotation!),
here some code to load an XML document into a DOMDocument and a Schema into a SchemaCache.
//Create the DOM document assign the cache to its schemas property.
//Create Main DOM document
var testXMLDoc = new ActiveXObject(“MSXML2.DOMDocument.4.0”);
testXMLDoc.async = “false”;
//Create DOM document for Schema and load Schema file into the document
var xsdDoc = new ActiveXObject(“MSXML2.DOMDocument.4.0”);
xsdDoc.async = “false”;
xsdDoc.load(“LilithSchema.xsd”);
//Create Schema Cache and add and validate Schema from Schema DOM document
var SchemaCache = new ActiveXObject(“Msxml2.XMLSchemaCache.4.0”);
SchemaCache.validateOnLoad = false;
SchemaCache.add(“http://www.inubit.com/FormServlet”, xsdDoc);
SchemaCache.validate();
//Insert Schema Cache into the Main DOM document
testXMLDoc.schemas = SchemaCache;
//Load and Validate Main DOM document
testXMLDoc.load(“LilithOrg.xml”);
testXMLDoc.validate();
if (testXMLDoc.load(“LilithOrg.xml”)){
alert(testXMLDoc.nodeFromID(“a0010”));
}
//alert(xsdDoc.xml + “n~~~~~~~~~~~n” + testXMLDoc.xml);
Attached the XML file and the Schema file in a common file.
Now my Question:
I try to validate the XML file against the Schema, so I can select nodes from the tree by the methode “nodeFromID”. Therefore I have to define an attribute ID at the Schema at the conventions of w3c.
So everything works but the call testXMLDoc.nodeFromID(“a0010”). It returns null and no object.
Anyone with an idea why not or where I can search to solve the problem?
Thanks a lot, Lili ?
[upl-file uuid=ee11ac22-bb19-4f9d-9265-c4b314efec96 size=924B]lilithorg.txt