#include "asxml.ch"
#pragma library("ASXML10.LIB")
/* sample main procedure
*/
PROCEDURE MAIN()
? DbeList()
processConfig("test.xml")
? DbeList()
RETURN
FUNCTION processConfig(cFileName)
LOCAL nXMLDoc,nActions
nXMLDoc := XMLDocOpenFile(cFileName)
nActions := XMLDocSetAction(nXMLDoc, "//DatabaseEngines/load",;
{|n,c,a,ch|handleLoad(n,c,a,ch)})
nActions := XMLDocSetAction(nXMLDoc, "//DatabaseEngines/build",;
{|n,c,a,ch|handleBuild(n,c,a,ch)})
IF nActions != 0
XMLDocProcess(nXMLDoc)
XMLDocResetAction(nXMLDoc)
ENDIF
XMLDocClose(nXMLDoc)
RETURN
/* Callback function to handle the DbeLoad action
*/
FUNCTION handleLoad(cTag,cContent,aMember,nH)
LOCAL aCH
XMLGetTag(nH,@aCH)
DbeLoad(aCH[XMLTAG_CONTENT],.F.)
RETURN (XML_PROCESS_CONTINUE)
/* Callback function to handle DbeBuild action
*/
FUNCTION handleBuild(cTag,cContent,aMember,nH)
LOCAL aCH :={}
LOCAL nHChild,cName,cOrder,cData
cName := XMLGetAttribute(nH,"name")
nHChild := XMLGetChild(nH,"data")
XMLGetTag(nHChild,@aCH)
cData := aCH[XMLTAG_CONTENT]
nHChild := XMLGetChild(nH,"order")
XMLGetTag(nHChild,@aCH)
cOrder:= aCH[XMLTAG_CONTENT]
DbeBuild(cName,cData,cOrder)
RETURN (XML_PROCESS_CONTINUE)
/* since we load the DBEs using external data,
* we overload DBESYS and load nothing
*/
PROCEDURE DBESYS()
RETURN