Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to work with XML and n-tiers
Message
From
01/11/2005 16:34:50
 
 
To
01/11/2005 15:36:44
General information
Forum:
Visual FoxPro
Category:
XML, XSD
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01064133
Message ID:
01064223
Views:
22
Hi Craig.

>You should have one data layer compenent for each data source

I'm agree with you, I was talking about how to create my own parser to send to multiple backends (to use multiple behaviors also), finally I did it using the iXMLDOMElement propierty.

In my data layer I was trying to get the elements of the Diffgram to create the proper SQL sentence (UPDATE, DELETE, INSERT), these Diffgram/Updategram will be send it by my Business Object:
** DataAccess::UpdateData
PARAMTERS lcDiffGram

** oXA is my XMLAdapterObject

This.oXA.LoadXML(lcDiffgram)
oChild = This.oXA.iXMLDomElement.ChildNodes
FOR EACH oNodes IN o oChild.Item(0).ChildNodes
  ** Testing
  ?oNodes.oNodeName
  oElement = oNodes.GetElementByTagName(oNodes.FirstChild.NodeName)
  FOR EACH oValues IN oElemenet.Item(0).ChildNodes
     ?oValues.NodeName, oValues.Text
    *** Here is where I will work with The Elements of the Diffgram
    *** Now I can handle with different behaviors
    *** Each oValues has the elements with changes
    *** I can create the INSERT,UPDATE or DELETE statements
  ENDFOR
ENDFOR
a Complete sample for testing:
CLEAR
CREATE CURSOR ctest (iid int AUTOINC , clave c(5), fecha d)
SET MULTILOCKS ON
FOR lnCounter=1 TO 5
  INSERT INTO ctest (clave,fecha) VALUES (TRANSFORM(RAND()*1000,"@L 99999"),DATE()-(RAND()*50))
endfor
CURSORSETPROP("Buffering",5)
CURSORSETPROP("keyfieldlist",'iID')
* Lets change some values
UPDATE cTest SET clave = '00001' WHERE iID = 1
UPDATE cTest SET fecha = DATE(2005,11,02) WHERE iID = 3
UPDATE cTest SET clave = '00099', fecha = DATE(2005,11,01) WHERE iID = 5
** Create the XMLAdapter
oXA = CREATEOBJECT("XMLAdapter")
** Load the XMLupdategram
oXA.LoadXML(XMLUPDATEGRAM("ctest"))
oChild = oXA.IXMLDOMElement.childNodes
FOR EACH oNodes IN oChild.item(0).childNodes 
  ?oNodes.NodeName
  oEle = oNodes.GetElementsByTagName(oNodes.firstChild.nodeName)
  FOR EACH oValues IN oEle.Item(0).ChildNodes
    ?CHR(7),CHR(7),oValues.NodeName,"-->", oValues.Text
  ENDFOR
ENDFOR
Any comments?

>If you need to connect to multiple backends, the business objects should talk to a Data Facade object. It will then pass the data to a data layer component. You should have one data layer compenent for each data source (Visual FoxPro, SQL, Oracle, etc).


>I've using XML to transport Visual FoxPro data between tiers in a COM+ DLL, it's pretty straigfull when you are using it to read the data.
>
>The new problem I've found is about how to send the update from the business tier to the data tier, with Visual FoxPro I can produce an XML Diffgram (trough XMLUpdategram() function or CursorAdapter class), but I'm finding problems to send this kind of XML when I prettend to not use MS SQLServer.
>
>It will be cool if I could create a .NET Adapter (SQLAdapter, OLEDBAdapter, etc) we could update any kind of datasource, obviously the mayor work will be in How to move between the Diffgram elements (the before/after elements).
>
>My question is: How can I move between Items in a XMLDiffgram?
Apoya a Visual FoxPro usandolo legalmente
--
¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º
Espartaco Palma Martínez
SysOp PortalFox
http://www.portalfox.com
esparta@portalfox.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform