 |
 |
 |
Trotsky wrote:
> Thanks Martin, I know this. I guess my next question is then how does someone validated their xml against a schema I create?
> If I have a definition of say a name and it has to be 10 characters or less how with the person ahdering to the schema "know" about this?
So it seems your question is more how do I relate an XML source file to
a schema so that it is validated against that schema.
There are ususally two ways to do that, you can use the
xsi:schemaLocation attribute in the source XML file to list the
namespaces and schemas that are relevant to the XML file and then a
parser should be able to load the schemas and perform the validation.
The other way doesn't require editing the XML source file and sticking
attributes in there to list the schemas but simply use a parser
dependant API to tell the parser which schemas to load for which
namespace before you ask the parser to perform validation.
MSXML 4 has an API to do that, you usually load the schemas into a
schema cache and associate the cache with the XML document object before
you call the load method:
var schemaCache = new ActiveXObject('Msxml2.XMLSchemaCache.4.0');
schemaCache.add('http://example.com/2004/05/gods', 'test20040501Xsd.xml');
var xmlDocument = new ActiveXObject('Msxml2.DOMDocument.4.0');
xmlDocument.async = false;
xmlDocument.validateOnParse = true;
xmlDocument.schemas = schemaCache;
var valid = xmlDocument.load('test20040501.xml');
if (valid) {
alert('Document is valid.');
}
else {
alert(xmlDocument.parseError.reason);
}
--
Martin Honnen
http://JavaScript.FAQTs.com/
|
 | 

|  |
These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.
|  |
| |
 |
 |
 |