Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Accessing XSD definition (including metadata) when walking through an XML instance

From: "Yo/\\ek" <opessin@-----.--->
To: NULL
Date: 4/8/2009 4:05:00 AM
Dear all,

I am trying to manage with some xml metadata in server side javascript
(old school .asp pages).
The metadata will be located in the XSD's annotation/appinfo elements.
This schema validates the XML instance.

Now, as I walk through my XML instance (using XMLDOM's selectSingleNode
() for instance), I'd like to access to the metadata related to the
current node.

Apparently, the ".definition" property allows this but I can't make
this work with an XSD schema.
It does work with an XDR schema but that is not the format I'm
supposed to use...

The following sample works great but the same with an XSD instead of
XDR fails...
	Error code: -1072897791
	Error reason: Error opening input file: 'Product.xsd'.
	Incorrect definition for the root element in schema.
	Error srcText: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">

Is it just not possible to do it with a XSD ?
Is there another way to access to the xsd definition of a given node ?
Maybe the "x-schema:" prefix only applies for XDR but I found only
very little information about this syntax...
Is there a way to tell the XMLDOM that the schema is in XSD and not
XDR ?
Note that I tried with the ".schemas" property (which is actually good
for validating with XSD) but in that case, the ".definition" property
of the nodes remains null... unless I did a mistake...

Thanks in advance for any clue.

Regards,
Olivier

----------------------------------------------------------------
Product-xdr.xml :------
<?xml version="1.0" encoding="utf-8" ?>
<Product ProductID="123" xmlns="x-schema:Product.xdr">
   <ProductName>Rugby jersey</ProductName>
</Product>

Product.xdr :------
<?xml version="1.0" encoding="UTF-8"?>
<Schema name="ProductSchema"
		xmlns="urn:schemas-microsoft-com:xml-data"
		xmlns:dt="urn:schemas-microsoft-com:datatypes">
	<AttributeType name="ProductID" dt:type="int"/>
	<ElementType name="ProductName" dt:type="string"/>
	<ElementType name="Product" content="eltOnly">
		<attribute type="ProductID" required="yes"/>
		<element type="ProductName"/>
	</ElementType>
</Schema>

test.js : ------ (I'm using WScript to mock-up before actually putting
it on .asp)
xml_doc = new ActiveXObject("Microsoft.XMLDOM");
xml_doc.async = false;
xml_doc.load("Product-xdr.xml");
if (xml_doc.parseError.errorCode!=0) {
	s = [];
	s.push("Error code: " + xml_doc.parseError.errorCode);
	s.push("Error url: " + xml_doc.parseError.url);
	s.push("Error reason: " + xml_doc.parseError.reason);
	s.push("Error srcText: " + xml_doc.parseError.srcText);
	s.push("Error line: " + xml_doc.parseError.line);
	WScript.echo(s.join('\n'));
	WScript.Quit();
}
var node = xml_doc.documentElement;
WScript.echo(node.definition.xml);


transparent
Print
Mail
Like It
Disclaimer
.

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.

.
.

transparent

transparent