Jump to content

xml schema validate _xmldomwrapper


Recommended Posts

Hello,

i was wondering if someone could explain how this function

_XMLSchemaValidate
works:

;===============================================================================
; Function Name: _XMLSchemaValidate
; Description: Validates a document against a dtd.
; Parameter(s): $sXMLFile The file to validate
; $ns  xml namespace
; $sXSDFile DTD file to validate against.
; Syntax: _XMLSchemaValidate($sXMLFile, $ns, $sXSDFile)
; Author(s): Stephen Podhajecki <gehossafats@netmdc.com>
; Return Value(s) 1 on success or SetError(errorcode) on failure
;===============================================================================
Func _XMLSchemaValidate($sXMLFile, $ns, $sXSDFile)
;~  If not IsObj($objDoc) then
;~  _XMLError("No object passed to function _XMLSchemaValidate")
;~  Return SetError(1,27,-1)
;~  EndIf
Local $cache, $xmldoc
$cache = ObjCreate("Msxml2.XMLSchemaCache." & $DOMVERSION & ".0")
If Not IsObj($cache) Then
MsgBox(266288, "XML Error", "Unable to instantiate the XML object" & @LF & "Please check your components.")
Return SetError(-1)
EndIf
$cache.add ($ns, $sXSDFile)
$xmldoc = ObjCreate("Msxml2.DOMdocument." & $DOMVERSION & ".0")
If Not IsObj($xmldoc) Then
MsgBox(266288, "XML Error", "Unable to instantiate the XML object" & @LF & "Please check your components.")
Return SetError(-1)
EndIf
$xmldoc.async = False
$xmldoc.schemas = $cache
$xmldoc.load ($sXMLFile)
If Not ($xmldoc.parseError.errorCode = 0) Then
_XMLError("_XMLSchemaValidate:" & @LF & "Error: " & $xmldoc.parseError.errorCode & " " & $xmldoc.parseError.reason)
Return SetError($xmldoc.parseError.errorCode)
EndIf
Return 0
EndFunc   ;==>_XMLSchemaValidate

What i am trying to do is ... i would like to know if schema version has changed in XML i am using and if it has function would trigger an error.

Now as i understand _XMLSchemaValidate takes 3 parameters:

1st XML file ... i should provide here an XML object or link to a file on my local disk?

2nd xml namespace ... in my example i have this in root node:

<?xml version="1.0" encoding="utf-8"?>
<Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:edp="http://edavki.durs.si/Documents/Schemas/EDP-Common-1.xsd" xmlns="http://edavki.durs.si/Documents/Schemas/DOD_DDPO_8.xsd">

which name space should i take as parameter?

xmlns="http://edavki.durs.si/Documents/Schemas/DOD_DDPO_8.xsd"

3rd DTD file to validate against Ok this one is cleary

xmlns="http://edavki.durs.si/Documents/Schemas/DOD_DDPO_8.xsd"

If someone could clarify this for me first then i have 2 followup questions on the matter.

PS I have searched whole help forum and topic on _xmldoomwrapper and it seems noone had any problems with this function or noone uses it?

I got a feeling i can run it everytime i will do the XML and it will alter me if schema version has changed. (hopefully)

Edited by amakrkr
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...