469,913 Members | 1,976 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,913 developers. It's quick & easy.

Using schema validation for update

2
I have a valid xml and schema.
I put them together in javascript and generate html.
Like this:
Expand|Select|Wrap|Line Numbers
  1. function initAdmin() {
  2.   var xslDoc
  3.   strFile="Simple.Config.xml"
  4.   strSchema="SimpleSchemaConfig.xsd";
  5.  
  6.   if (ValidateShema(strFile,strSchema)==true){
  7.       xmlDoc = new ActiveXObject('MSXML2.DOMDocument.4.0');
  8.       xmlDoc.async = false;
  9.  
  10.       xslDoc = new ActiveXObject('MSXML2.DOMDocument.4.0');
  11.       xslDoc.async = false;
  12.  
  13.       AppPath = xmlDoc.url;
  14.       xmlDoc.loadXML(xmlDoc.documentElement.transformNode(xslDoc));
  15.       xslDoc.load("FileTree.xsl");
  16.       folderTree.innerHTML = xmlDoc.documentElement.transformNode(xslDoc);  
  17. }
  18. }
  19.  
  20. function ValidateShema(strFile,strSchema){ 
  21.  
  22. try
  23. {
  24.        xmlDoc              = new ActiveXObject("MSXML2.DOMDocument.4.0");
  25.        schemaCache         = new ActiveXObject("MSXML2.XMLSchemaCache.4.0");
  26.  
  27.        xmlDoc.async            = false;
  28.        xmlDoc.resolveExternals = false;
  29.        xmlDoc.validateOnParse  = false;
  30.  
  31.        schemaCache.add("",strSchema);
  32.  
  33.        xmlDoc.schemas = schemaCache;
  34.        xmlDoc.validateOnParse = true;
  35.        if (xmlDoc.load(strFile)) {       
  36.          displayError("xml is valid.");
  37.          return true;
  38.        }
  39.        else {
  40.          if (xmlDoc.parseError.errorCode != 0) {
  41.            displayError("Validation failed on " + strFile + 
  42.                 "\nReason: " + xmlDoc.parseError.reason + 
  43.                 "\nSource: " + xmlDoc.parseError.srcText + 
  44.                 "\nLine: " + xmlDoc.parseError.line + "\n");
  45.                 isValid=0;
  46.                 return false;
  47.          }
  48.        }
  49. }
  50. catch(ex)
  51. {
  52.      alert("Error: " + ex.message)
  53. }
  54. }
Everything works just fine.

User has ability to update XML data.
But when they save invalid data it will be saved.
Validation doesn’t work.
How I can validate entry every time when they try to update with the schema?
Is that actually possible? Or I have to use javascript validation.
Oct 12 '05 #1
0 2324

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Iain A. Mcleod | last post: by
1 post views Thread by billa1972 | last post: by
reply views Thread by Mark Parter | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.