Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Xmltocursor
Message
From
08/08/2008 06:57:37
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
07/08/2008 13:44:38
General information
Forum:
Visual FoxPro
Category:
XML, XSD
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01335748
Message ID:
01337477
Views:
22
>Thnx Cetin,
>
>meanwile i have made all my cursors complete with the right fieldproperties and values :)
>
>Only thing that stays is the header-detail problem. Its so that in the xml multiple animals can be stocked and in the details there are no field links to the header. So i think thats going to be a big problem.
>
>what i also see is when i check my xml with
>FOR EACH lcTableName IN MyXmlAdapter.tables
> lcTableName.tocursor()
>ENDFOR
>the first cursur that is made is the last detail file (animal is the header, risk and history are details)
>
>you talk to add a keyfield in the header and detail but as there is no link to the header i wonder how i can make the link.

Multiple animals but all are surrounded with < Animal > ... < /Animal > tags, no?
Local lcXMLBase, lcXML,lcXSD, lnID
TEXT TO lcXMLBase noshow
<?xml version="1.0" ?>
 <AnimalExport
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns="http://Sanitrace.EAI/SanitraceRepository/SanitraceServices/AnimalExportSchema">
<<m.Animal>>
</AnimalExport>
ENDTEXT

lcXML = Filetostr('aexport.xml')
lcXSD = 'aexport.xsd'

For lnID = 1 To Occurs('<Animal>',m.lcXML)
  animal = Strextract(m.lcXML,'<Animal>','</Animal>',m.lnID,4)
  GetAnimal(Textmerge( m.lcXMLBase ),m.lcXSD, m.lnID)
Endfor


Procedure GetAnimal(tcXML,tcXSD, tnID)
  Local xa As Xmladapter, ix
  xa = Createobject('xmladapter')
  xa.XMLSchemaLocation = m.tcXSD
  xa.LoadXML(m.tcXML,.F.)

  For ix =1 To xa.Tables.Count
    xa.Tables(m.ix).ToCursor(.F.,'tmp')
    If !Used(xa.Tables(m.ix).Alias)
      Select m.tnID As AnimalID,* From tmp Into Cursor (xa.Tables(m.ix).Alias) Readwrite
    Else
      Insert Into (xa.Tables(m.ix).Alias) Select m.tnID As AnimalID,* From tmp
    Endif
    Use In 'tmp'
  Endfor
Endproc
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform