accessing documentation elements/unhandled attributes via the som

W

wooks

I have some information embedded in included schemas which I want to
access at run-time for the purposes of contructing a GUI (they will
support field labels and tool tips).

The options seem to be to store them as documentation/appinfo elements
within the included schema or as unhandled attributes.

Because the schemas are included it seems the items would have to be
accessed via the SOM (as opposed to retrieving the details via XPATH)
but I can't see anyway how to do this. I think unhandled attributes
means having to use SAX but I can't see how.

Can anyone help.
 
W

will

Please note a GUI can become very complicated... I ended up using a separate
xml file to store GUI info, because if you start using xsl an xsd looks more
daunting. I use the xsd for things set by vb and an xml ref file for things
set by xsl.
You can load the xsd as a DOMDocument.
After writing the code below I realised you can actually select the
attributes directly using selectSingleNode, which is what I now do for most
things. Selecting attributes directly means that instead of @name and @ref
you can just use @*="mynodename".
_________________________________________________________________________
Set m_XSDs = New MSXML2.XMLSchemaCache40
Set m_XSDDoc = New MSXML2.DOMDocument40
'sXSD is an XSD filename
m_XSDs.Add vbNullString, sXSD
Set m_XSD = m_XSDs.getSchema(vbNullString)
With m_XSDDoc
.validateOnParse = False
.async = False
.setProperty "SelectionLanguage", "XPath"
.setProperty "NewParser", True
.Load sXSD
.setProperty "SelectionNamespaces",
"xmlns:xs=""http://www.w3.org/2001/XMLSchema""
xmlns:sql=""urn:schemas-microsoft-com:mapping-schema"""
End With
_________________________________________________________________________
sxsdID = "xs:annotation/xs:appinfo/xs:mds"
Set oXMLAnnotation = oXMLAnnotationParent.selectSingleNode(sxsdID)
If oXMLAnnotation Is Nothing Then

For Each oXMLAttribute In oXMLAnnotationParent.Attributes

If oXMLAttribute.Name = "ref" Then
sxsdID = "/xs:schema/xs:element[@name=""" & oXMLAttribute.Value
& """]"
Set oXMLAnnotationParent =
m_XSDDoc.documentElement.selectSingleNode(sxsdID)
Exit For
End If

Next

sxsdID = "xs:annotation/xs:appinfo/xs:mds"
Set oXMLAnnotation = oXMLAnnotationParent.selectSingleNode(sxsdID)
End If


If Not oXMLAnnotation Is Nothing Then

For Each oXMLAttribute In oXMLAnnotation.Attributes

Select Case oXMLAttribute.Name
Case "type"

Select Case oXMLAttribute.Text
Case "hidden"
nAttribs = nAttribs Or vbHidden
Case "readonly"
nAttribs = nAttribs Or vbReadOnly
End Select
End Select

Next

End If

regards,
Will
http://fileant.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top