RE: Getting the datatype from XSD

With MSXML 4.0, you can use the "SOM" (Schema Object Model) to do this.  Look in the MSXML 4 help under "SOM Developer's Guide" and "SOM Reference".  I actually wish you could ask the node to give back schema type information, but they do it a slightly different way (which I've found doesn't always work).

Here's a little snippet to give you an idea of what's involved:


Set oSchemaCache = CreateObject("Msxml2.XMLSchemaCache.4.0")
oSchemaCache.add "urn:a", "a.xsd"

Set oDoc = CreateObject("Msxml2.DOMDocument.4.0")
oDoc.async = false
oDoc.validateOnParse = true
Set oDoc.schemas = oSchemaCache
oDoc.load "a.xml"

...

Set oNode = oDoc.selectSingleNode("/*/*")
Set oSchemaItem = oDoc.namespaces.getDeclaration(oNode)

-Daniel

-----Original Message-----
From: Mikael Joukakelian [mailto:mikaelj@CAE.COM]
Sent: Tuesday, August 13, 2002 8:08 AM
To: 'xmlschema-dev@w3.org'
Subject: Getting the datatype from XSD



Hi,

I have an XSD Schema and an instance of it which I am reading using MSXML. I
would like to get the dataype (int, max value, ...) of each
element\attribute that I read. This information is found in the Schema and
there should be a way to retrieve it however the only help I got from MSXML
told me that I cannot get property information from Schemas (see below).. 


dataType Property []
Specifies the data type for this node. This property applies to document
type definitions (DTDs) only, not to XML-Data Reduced (XDR) schemas or XML
Schema definition language (XSD) schemas.

Received on Tuesday, 13 August 2002 13:44:09 UTC