Validating xml against schema instead of dtd


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Validating xml against schema instead of dtd

  1. #1
    Segun Adu Guest

    Validating xml against schema instead of dtd


    Does anyone have any idea how I could validate xml against a schema using
    the MS XML DOM?

    Segun
    ~~~X~~

  2. #2
    Jaco de Villiers Guest

    Re: Validating xml against schema instead of dtd


    Use the following code as en example:

    Public Function ValidateDocument(ByVal oXML As Variant, ByVal sXSDPath As
    String) As MSXML2.IXMLDOMParseError

    On Error GoTo ValidateDocERR

    Dim oSchema As MSXML2.XMLSchemaCache40

    '/// Instantiate new objects
    Set oSchema = New MSXML2.XMLSchemaCache40

    '/// Load the selected NessiSchema
    oSchema.Add "", sXSDPath
    '/// Add the schema file to the XML Document
    Set oXML.schemas = oSchema

    '/// Validate the XML Document against the schema
    Set ValidateDocument = oXML.Validate()

    ValidateDocERR:
    If Not Err.Number = 0 Then
    Err.Raise Err.Number, "ScreenGenerator.ValidateDocument()", Err.Source
    & vbCrLf & Err.Description
    End If
    End Function


    "Segun Adu" <segunadu@fdsgroup.com> wrote:
    >
    >Does anyone have any idea how I could validate xml against a schema using
    >the MS XML DOM?
    >
    >Segun
    >~~~X~~



  3. #3
    Segun Adu Guest

    Re: Validating xml against schema instead of dtd


    Jaco:

    What standards of Schemas does this code support?

    Does it support Microsoft specific standards, or does it support W3C standards
    for Schemas?

    Segun
    ~~~X~~


    "Jaco de Villiers" <jacodv_32@hotmail.com> wrote:
    >
    >Use the following code as en example:
    >
    >Public Function ValidateDocument(ByVal oXML As Variant, ByVal sXSDPath As
    >String) As MSXML2.IXMLDOMParseError
    >
    > On Error GoTo ValidateDocERR
    >
    > Dim oSchema As MSXML2.XMLSchemaCache40
    >
    > '/// Instantiate new objects
    > Set oSchema = New MSXML2.XMLSchemaCache40
    >
    > '/// Load the selected NessiSchema
    > oSchema.Add "", sXSDPath
    > '/// Add the schema file to the XML Document
    > Set oXML.schemas = oSchema
    >
    > '/// Validate the XML Document against the schema
    > Set ValidateDocument = oXML.Validate()
    >
    >ValidateDocERR:
    > If Not Err.Number = 0 Then
    > Err.Raise Err.Number, "ScreenGenerator.ValidateDocument()", Err.Source
    >& vbCrLf & Err.Description
    > End If
    >End Function
    >
    >
    >"Segun Adu" <segunadu@fdsgroup.com> wrote:
    >>
    >>Does anyone have any idea how I could validate xml against a schema using
    >>the MS XML DOM?
    >>
    >>Segun
    >>~~~X~~

    >



  4. #4
    Jaco de Villiers Guest

    Re: Validating xml against schema instead of dtd


    It support the latest W3C schema... think this is the latest

    http://www.w3.org/2001/XMLSchema

    Regards


  5. #5
    Daraius Guest

    Re: Validating xml against schema instead of dtd


    This is how you set the validation on or off. In my case I set it to off.

    CComPtr<IXMLDOMDocument> m_pXMLDOMDoc;
    VARIANT_BOOL bValidate = VARIANT_FALSE;
    m_pXMLDOMDoc->put_validateOnParse(bValidate);



    "Jaco de Villiers" <jacodv_32@hotmail.com> wrote:
    >
    >Use the following code as en example:
    >
    >Public Function ValidateDocument(ByVal oXML As Variant, ByVal sXSDPath As
    >String) As MSXML2.IXMLDOMParseError
    >
    > On Error GoTo ValidateDocERR
    >
    > Dim oSchema As MSXML2.XMLSchemaCache40
    >
    > '/// Instantiate new objects
    > Set oSchema = New MSXML2.XMLSchemaCache40
    >
    > '/// Load the selected NessiSchema
    > oSchema.Add "", sXSDPath
    > '/// Add the schema file to the XML Document
    > Set oXML.schemas = oSchema
    >
    > '/// Validate the XML Document against the schema
    > Set ValidateDocument = oXML.Validate()
    >
    >ValidateDocERR:
    > If Not Err.Number = 0 Then
    > Err.Raise Err.Number, "ScreenGenerator.ValidateDocument()", Err.Source
    >& vbCrLf & Err.Description
    > End If
    >End Function
    >
    >
    >"Segun Adu" <segunadu@fdsgroup.com> wrote:
    >>
    >>Does anyone have any idea how I could validate xml against a schema using
    >>the MS XML DOM?
    >>
    >>Segun
    >>~~~X~~

    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center