Internet Technologies:xml

Appendix Professional

Source code

#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 

Sample XML document

<?xml version="1.0"?> 

<Configuration> 

<DatabaseEngines> 
  <load>DBFDBE</load> 
  <load>NTXDBE</load> 
  <load>CDXDBE</load> 

  <build name="DBFNTX"> 
    <data>DBFDBE</data> 
    <order>NTXDBE</order> 
  </build> 

  <build name="DBFCDX"> 
    <data>DBFDBE</data> 
    <order>CDXDBE</order> 
  </build> 
</DatabaseEngines> 

</Configuration> 

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.