/    Sign up×
Community /Pin to ProfileBookmark

Schemas, MSXML 4.0 and unique ID’s

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[/upl-file]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @Lilith spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...