Lilith
11-06-2003, 04:17 AM
Hello :confused: ,
here some code to load a Schema into a SchemaCache, to load a XML file into a DOMDocument and to assing the SchemaCache to the DOMDocument.
//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.add("http://www.test.com/testServlet", xsdDoc);
//Insert Schema Cache into the Main DOM document
testXMLDoc.schemas = SchemaCache;
//Load and Validate Main DOM document
if (testXMLDoc.load("LilithCatalogOrg.xml")){
alert(testXMLDoc.nodeFromID("a0010"));
}
Attached the XML structure and the Schema in a common file.
Now the problem:
I try to select a single node from the given XML structure by using the function "nodeFromID(ID)". Therefore I have to validate the structure against a schema which defines ID as attribute with type xsd:ID. You can save the Schema in this SchemaCache. So everything works pretty fine, but the last call: testXMLDoc.nodeFromID("a0010"). It returns null but the node object.
Has anybody an idea, why the ID definition in the Schema doesn't work? Or is the Schema not correct? (It's handmade! :)
Thanks a lot for help, Lili ;)
here some code to load a Schema into a SchemaCache, to load a XML file into a DOMDocument and to assing the SchemaCache to the DOMDocument.
//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.add("http://www.test.com/testServlet", xsdDoc);
//Insert Schema Cache into the Main DOM document
testXMLDoc.schemas = SchemaCache;
//Load and Validate Main DOM document
if (testXMLDoc.load("LilithCatalogOrg.xml")){
alert(testXMLDoc.nodeFromID("a0010"));
}
Attached the XML structure and the Schema in a common file.
Now the problem:
I try to select a single node from the given XML structure by using the function "nodeFromID(ID)". Therefore I have to validate the structure against a schema which defines ID as attribute with type xsd:ID. You can save the Schema in this SchemaCache. So everything works pretty fine, but the last call: testXMLDoc.nodeFromID("a0010"). It returns null but the node object.
Has anybody an idea, why the ID definition in the Schema doesn't work? Or is the Schema not correct? (It's handmade! :)
Thanks a lot for help, Lili ;)