accessing documentation elements/unhandled attributes via the som

Discussion in 'XML' started by wooks, Jan 17, 2004.

  1. wooks

    wooks Guest

    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.
     
    wooks, Jan 17, 2004
    #1
    1. Advertising

  2. wooks

    will Guest

    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

    "wooks" <> wrote in message
    news:...
    > 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.
     
    will, Jan 18, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken Philips
    Replies:
    1
    Views:
    478
    Dave Monroe
    Jul 20, 2004
  2. Odd Einar
    Replies:
    1
    Views:
    407
    Inger Helene Falch-Jacobsen
    Oct 23, 2004
  3. tgtt
    Replies:
    2
    Views:
    437
    C. M. Sperberg-McQueen
    Jan 28, 2004
  4. Ken Philips
    Replies:
    2
    Views:
    579
    Dave Monroe
    Jul 20, 2004
  5. Warren Tang
    Replies:
    1
    Views:
    884
    Warren Tang
    Sep 23, 2008
Loading...

Share This Page