Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is there a way to convert XSD to a table structure?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
XML, XSD
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01025314
Message ID:
01025519
Vues:
29
>Dawa,
>
>>I've a number of XSD (XML Schema Definition) files that I would like to convert to a set tables who fields will be created based on the Simple Type restrictions where applies.
>
>It sounds like you have the XSDs but do not have XML files with data to go with them and you want just empty tables to match them?
>
>If so, you can use XMLAdapter to read the schemas, using a "dummy.xml" file to allow it to read in, and then output to tables. First, create a file named dummy.xml:
<?xml version = "1.0" encoding="Windows-1252" standalone="yes"?>
><VFPData>
></VFPData>
>Also, create this little PRG in walktables.prg (useful for seeing what is structured in the XMLAdapter):
LPARAMETERS oXMLA
>LOCAL oTable AS XMLTable
>LOCAL oField AS XMLField
>CLEAR
>? "XMLADAPTER: " + STRCONV(oXMLA.XMLName,6)
>? "----------------------------"
>FOR EACH oTable IN oXMLA.Tables
>  ?
>  ? "TABLE: XMLName= "+STRCONV(oTable.XMLName,6)+", Alias= "+oTable.Alias
>  FOR EACH oField IN oTable.Fields
>    ? "  FIELD: XMLName= "+STRCONV(oField.XMLName,6)+", Datatype= "+;
>    oField.datatype+", MaxLength= "+TRANSFORM(oField.MaxLength)
>  ENDFOR	
>ENDFOR
>And finally, put this code into outputtables.prg:
LPARAMETERS oXMLA
>LOCAL oTable AS XMLTable
>FOR EACH oTable IN oXMLA.Tables
>	oTable.ToCursor()
>ENDFOR
>Now for each XSD schema, reference it in the XMLAdapter's XMLSchemaLocation property before using LoadXML to read in the dummy.xml:
o=CREATEOBJECT("XMLAdapter")
>o.XMLSchemaLocation="myfirstxsd.xsd"
>o.LoadXML("dummy.xml",.t.)
>At this point, if the schema could be interpreted by XMLAdapter (some are too complex), you will end up with a set of XMLTable and XMLField objects, which you can find out about like this:
walktables(o)
>Assuming that you find some table and field objects there, you can output them to empty cursors like this:
outputtables(o)
>I hope this helps point you in the right direction.

David,

Thank you for the reply and the detailed explation. Truely appreciate it!

I'll try this out.
Dawa Tsering


"Do not let any unwholesome talk come out of your mouths,
but only what is helpful for building others up according to their needs,
that it may benefit those who listen."

- Ephesians 4:29-30 NIV

Dare to Question -- Care to Answer

Time is like water in a sponge, as long as you are willing you can always squeeze some.

--Lu Xun, Father of Modern Chinese Literature

Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform