Jump to content

bulk transfer/copy data from SQL dB to XML using XSD validation


svibuk

Recommended Posts

bulk transfer/copy data from SQL dB to XML using XSD validation ., when the data is written frm SQL to XML i need it to get validated using a given XSD file currently i am just able to write frm SQL to XML with no validation but i need to use the given XSD filei tried one of the methods but its giving me errorC:\>cscript c:\test\ValidateAndBulkload.vbsMicrosoft ® Windows Script Host Version 5.7Copyright © Microsoft Corporation. All rights reserved.c:\test\ValidateAndBulkload.vbs(28, 4) msxml6.dll: The system cannot locate theobject specified. msxml6.dll is avlaible in system32 & also i hve registered it still i get the errormsxml6.dll: The filename, directory name, or volume label syntax is incorrect.msxml6.dll: The filename, directory name, or volume label syntax is incorrect.when i use the validation given in the script'Validate the data file prior to bulkloadDim sOutputsOutput = ValidateFile("c:\test\SampleXMLData.xml", "", "c:\test\SampleSchema.xml")WScript.Echo sOutput'If FileValid Then' Check constraints and initiate transaction (if needed)' objBL.CheckConstraints = True' objBL.Transaction=True'Execute XML bulkload using file.objBL.Execute "c:\test\SampleSchema.xml", "c:\test\SampleXMLData.xml"set objBL=Nothing'End IfFunction ValidateFile(strXmlFile,strUrn,strXsdFile)' Create a schema cache and add SampleSchema.xml to it.Dim xs, fso, sAppPathSet fso = CreateObject("Scripting.FileSystemObject") Set xs = CreateObject("MSXML2.XMLSchemaCache.6.0")sAppPath = fso.GetFolder(".") xs.Add strUrn, sAppPath & "\" & strXsdFile' Create an XML DOMDocument object.Dim :) Set :) = CreateObject("MSXML2.DOMDocument.6.0")' Assign the schema cache to the DOM document.' schemas collection.Set :).schemas = xs' Load XML document as DOM document.:(.async = False<_<.Load sAppPath & "\" & strXmlFile' Return validation results in message to the user.If :).parseError.errorCode <> 0 ThenValidateFile = "Validation failed on " & _strXmlFile & vbCrLf & _"=====================" & vbCrLf & _"Reason: " & :).parseError.reason & _vbCrLf & "Source: " & _:crazy:.parseError.srcText & _vbCrLf & "Line: " & _:P.parseError.Line & vbCrLfFileValid = FalseElseValidateFile = "Validation succeeded for " & _strXmlFile & vbCrLf & _"======================" & _vbCrLf & "Contents to be bulkloaded" & vbCrLfFileValid = TrueEnd IfEnd Functioni get the above error , morover i need to transfer data from SQL to XML with the tag elements specified in the schema file ie XSD file

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...