im using Microsoft XML Core Services (MSXML) to parse and create XML-documents with Paradox 11.0.0.676.
when i call certain methods of the oleAuto-objects, Paradox crashes when reaching the endMethod statement (the code is in the pushButton event of a button). That brought me to the conclusion, that the problem could be the "releasing" of oleAuto-variables. so i´ve put the variable-declarations to the form. if i debug the code, the GPF doesn´t appear at the endMethod of the Button anymore, but still occurs when exiting the program. So i might be right that the problem is where it comes to release variables. Explicit close() orders of the OLE-objects do not solve the problem. Anyone got an idea? I really need that MSXML to work :-( Other MSXML-Methods work very well, like searching XML-files via XPath for specific elements etc. .
here comes the code and the xml-files. the code validates a node of a xml-file against the xml-schema. (code and xml-files are from the microsoft msxml reference, slightly changed and applied to objectpal of course):
ValidateNode.xml
<?xml version="1.0"?>
<x:books xmlns:x="urn:books">
<book id="bk001">
<author>Hightower, Kim</author>
<title>The First Book</title>
<genre>Fiction</genre>
<price>44.95</price>
<pub_date>2000-10-01</pub_date>
<review>An amazing story of nothing.</review>
</book>
<book id="bk003">
<author>Nagata, Suanne</author>
<title>Becoming Somebody</title>
<genre>Biography</genre>
<review>A masterpiece of the fine art of gossiping.</review>
</book>
</x:books>
ValidateNode.xsd
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:books"
xmlns:bks="urn:books">
<xsd:element name="books" type="bks:BooksForm"/>
<xsd:complexType name="BooksForm">
<xsd:sequence>
<xsd:element name="book"
type="bks:BookForm"
minOccurs="0"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="BookForm">
<xsd:sequence>
<xsd:element name="author" type="xsd:string"/>
<xsd:element name="title" type="xsd:string"/>
<xsd:element name="genre" type="xsd:string"/>
<xsd:element name="price" type="xsd:float" />
<xsd:element name="pub_date" type="xsd:date" />
<xsd:element name="review" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string"/>
</xsd:complexType>
</xsd:schema>
ObjectPal-Code: Paradox-Form with just a button on it, this is the code from the pushButton Event (quick & dirty code :-)). The code works like it should: the element is shown in a messagebox which tells details about why the element isn´t valid. If i debug the code, Paradox crashes when reaching the endMethod statement. OS is Windows 7 64 Bit, Paradox is Version 11.0.0.676.
method pushButton(var eventInfo Event)
var
xd, xs, er, nlist, node oleAuto
err oleAuto
endVar
if NOT xd.open("Msxml2.DOMDocument.6.0") then
msgStop("Error", "Error")
return
endIf
if NOT xs.open("Msxml2.XMLSchemaCache.6.0") then
msgStop("Error", "Error")
return
endIf
xs.add("urn:books", "C:\\LZE\\MSXML\\validateNode.xsd")
try
xd^schemas = xs
xd^async = false
xd^validateOnParse = false
xd^load("C:\\LZE\\MSXML\\validateNode.xml")
err = xd^validate()
nList = xd^selectNodes("//book")
node = nList^item(1)
msgInfo("", node.xml)
err = xd^validateNode(node)
msgInfo("", err.reason)
onFail
msgStop("!!!", "!!!")
endTry
try
if xd.isAssigned() then
xd.close()
endIf
if xs.isAssigned() then
xs.close()
endIf
if nList.isAssigned() then
nList.close()
endIf
if err.isAssigned() then
err.close()
endIf
onFail
msgStop("!!!", "!!!")
endTry