XSD to XML

XSD to XML

Postby Marc Vanzegbroeck » Mon Mar 30, 2009 1:59 pm

Hi,

Does anyone already create this for (x)Harbour?
I found some tools that create source-code for JAVA ,C++, or C based on a XSD-scheme, but not for (x)Harbour :(

Regards,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: XSD to XML

Postby Zupan Miran » Wed Apr 01, 2009 5:23 pm

Hello, first sory for my english..
Slovenian tax office also wants all reports in XML files - definition is in XSD file. So, I try some XML editors like XML Notepad, ALTOVA XML editor, but we have "special" characters in our languige (čćžđš...), so I have several errors when I try to import our "tax xsd" into program.
Next I try something like "reverse ingeniring". I know, this is not moral ot wright thing to do, but I "did it" :evil:
I took already made XML file from one "big sowtfare firm" and make similar for my purpose... :roll:

XML file is txt file, so if you have "a model" like this
Code: Select all  Expand view

<?xml version="1.0" encoding="windows-1250"?>
<?xml-stylesheet type="text/xsl" href="http://edavki.durs.si/Documents/Transforms/DDV_O_5.3-display-sl.xslt"?>
<Envelope xmlns="http://edavki.durs.si/Documents/Schemas/DDV_O_5.xsd" xmlns:edp="http://edavki.durs.si/Documents/Schemas/EDP-Common-1.xsd">
  <edp:Header>
    <edp:taxpayer>
      <edp:taxNumber>89646525</edp:taxNumber>
      <edp:taxpayerType>PO</edp:taxpayerType>
      <edp:name>NAME OF FIRM</edp:name>
      <edp:address1>STREET</edp:address1>
      <edp:city>CITY</edp:city>
      <edp:maticnaStevilka>53434345021000</edp:maticnaStevilka>
      <edp:resident>true</edp:resident>
    </edp:taxpayer>
    <edp:domain>edavki.durs.si</edp:domain>
  </edp:Header>
  <edp:Signatures />
  <body>
    <edp:bodyContent />
    <DDV-O>
      <taxPeriodStart>2009-01-01</taxPeriodStart>
      <taxPeriodEnd>2009-01-31</taxPeriodEnd>
      <f03>false</f03>
      <f04>false</f04>
      <f11>119316.00</f11>
      <f12>4423.00</f12>
      <f13>0.00</f13>
      <f14>0.00</f14>
      <f15>0.00</f15>
      <f21>23863.00</f21>
      <f22>0.00</f22>
      <f23>3307.00</f23>
      <f24>0.00</f24>
      <f25>0.00</f25>
      <f26>0.00</f26>
      <f31>44848.00</f31>
      <f32>16534.00</f32>
      <f33>2025.00</f33>
      <f34>0.00</f34>
      <f35>0.00</f35>
      <f41>12130.00</f41>
      <f42>62.00</f42>
      <f43>0.00</f43>
      <f51>14978.00</f51>
      <f52>0.00</f52>
      <exchangeRate>239.64</exchangeRate>
    </DDV-O>
  </body>
</Envelope>
 


YOUR PRG may look somerhing like this:

Code: Select all  Expand view

STATIC FUNCTION Obrazec_XML(oDlg)
  LOCAL aGets:= oDlg:cargo
  LOCAL d1, d2
  cFile:= alltrim(aGets[1]:editbuffer())

  Zbrisi_Porocilo(cFile)
  SET DATE FORMAT TO "yyyy-mm-dd"
      d1:=dtoc(oDatum1)
      d2:=dtoc(oDatum2)
  SET DEVICE TO print
  SET PRINTER TO "&pot_xml"+cFile
      //*** Sifra, tip klienta ***
        DO CASE
           CASE x_tip_pod="P"; cTxt1:="PO"
           CASE x_tip_pod="F"; cTxt1:="SP"
           OTHERWISE         ; cTxt1:="PO"
        ENDCASE
      vrsta:=0
      @ vrsta,0 say '<?xml version="1.0" encoding="windows-1250"?>'
        vrsta++
      @ vrsta,0 say '<?xml-stylesheet type="text/xsl" href="http://edavki.durs.si/Documents/Transforms/DDV_O_5.3-display-sl.xslt"?>'
        vrsta++
      @ vrsta,0 say '<Envelope xmlns="http://edavki.durs.si/Documents/Schemas/DDV_O_5.xsd" xmlns:edp="http://edavki.durs.si/Documents/Schemas/EDP-Common-1.xsd">'
        vrsta++
        @ vrsta,0 say '<edp:Header>'
          vrsta++
          @ vrsta,0 say '<edp:taxpayer>'
            vrsta++
            //*** davcno stevilko napisi brez "SI" ***
            IF SUBSTR(XDAVCNA,1,2)="SI"
               @ vrsta,0 say '<edp:taxNumber>'+substr(XDAVCNA,3,8)+'</edp:taxNumber>'
            ELSE
               @ vrsta,0 say '<edp:taxNumber>'+alltrim(XDAVCNA)+'</edp:taxNumber>'
            ENDIF
              vrsta++
            @ vrsta,0 say '<edp:taxpayerType>'+cTxt1+'</edp:taxpayerType>'
              vrsta++
            @ vrsta,0 say '<edp:name>'+alltrim(ConvToAnsiCP(XNAZIV))+'</edp:name>'
              vrsta++
            @ vrsta,0 say '<edp:address1>'+alltrim(ConvToAnsiCP(XNASLOV))+'</edp:address1>'
              vrsta++
            @ vrsta,0 say '<edp:city>'+alltrim(ConvToAnsiCP(XKRAJ2))+'</edp:city>'
              vrsta++
            @ vrsta,0 say '<edp:maticnaStevilka>'+alltrim(XMATICNA)+'</edp:maticnaStevilka>'
              vrsta++
            @ vrsta,0 say '<edp:resident>true</edp:resident>'
              vrsta++
          @ vrsta,0 say '</edp:taxpayer>'
            vrsta++
          @ vrsta,0 say '<edp:domain>edavki.durs.si</edp:domain>'
            vrsta++
        @ vrsta,0 say '</edp:Header>'
          vrsta++
        @ vrsta,0 say '<edp:Signatures />'
          vrsta++
        @ vrsta,0 say '<body>'
          vrsta++
          @ vrsta,0 say '<edp:bodyContent />'
            vrsta++
          @ vrsta,0 say '<DDV-O>'
            vrsta++
            @ vrsta,0 say '<taxPeriodStart>'+alltrim(D1)+'</taxPeriodStart>'
              vrsta++
            @ vrsta,0 say '<taxPeriodEnd>'+alltrim(D2)+'</taxPeriodEnd>'
              vrsta++
            @ vrsta,0 say '<f03>false</f03>'
              vrsta++
            @ vrsta,0 say '<f04>false</f04>'
              vrsta++
            @ vrsta,0 say '<f11>'+alltrim(str(A11))+'.00</f11>'
              vrsta++
            @ vrsta,0 say '<f12>'+alltrim(str(A12))+'.00</f12>'
              vrsta++
            @ vrsta,0 say '<f13>'+alltrim(str(A13))+'.00</f13>'
              vrsta++
            @ vrsta,0 say '<f14>'+alltrim(str(A14))+'.00</f14>'
              vrsta++
            @ vrsta,0 say '<f15>'+alltrim(str(A15))+'.00</f15>'
              vrsta++
            @ vrsta,0 say '<f21>'+alltrim(str(A21))+'.00</f21>'
              vrsta++
            @ vrsta,0 say '<f22>'+alltrim(str(A22))+'.00</f22>'
              vrsta++
            @ vrsta,0 say '<f23>'+alltrim(str(A23))+'.00</f23>'
              vrsta++
            @ vrsta,0 say '<f24>'+alltrim(str(A24))+'.00</f24>'
              vrsta++
            @ vrsta,0 say '<f25>'+alltrim(str(A25))+'.00</f25>'
              vrsta++
            @ vrsta,0 say '<f26>'+alltrim(str(A26))+'.00</f26>'
              vrsta++
            @ vrsta,0 say '<f31>'+alltrim(str(A31))+'.00</f31>'
              vrsta++
            @ vrsta,0 say '<f32>'+alltrim(str(A32))+'.00</f32>'
              vrsta++
            @ vrsta,0 say '<f33>'+alltrim(str(A33))+'.00</f33>'
              vrsta++
            @ vrsta,0 say '<f34>'+alltrim(str(A34))+'.00</f34>'
              vrsta++
            @ vrsta,0 say '<f35>'+alltrim(str(A35))+'.00</f35>'
              vrsta++
            @ vrsta,0 say '<f41>'+alltrim(str(A41))+'.00</f41>'
              vrsta++
            @ vrsta,0 say '<f42>'+alltrim(str(A42))+'.00</f42>'
              vrsta++
            @ vrsta,0 say '<f43>'+alltrim(str(A43))+'.00</f43>'
              vrsta++
            @ vrsta,0 say '<f51>'+alltrim(str(A51))+'.00</f51>'
              vrsta++
            @ vrsta,0 say '<f52>'+alltrim(str(A52))+'.00</f52>'
              vrsta++
            @ vrsta,0 say '<exchangeRate>239.64</exchangeRate>'
              vrsta++
          @ vrsta,0 say '</DDV-O>'
            vrsta++
        @ vrsta,0 say '</body>'
          vrsta++
      @ vrsta,0 say '</Envelope>'
        vrsta++
  SET PRINTER TO
  SET DEVICE TO SCREEN
  RunShell("/C NOTEPAD "+"&pot_xml"+cFile,,.F.,.T.)

  SET DATE TO SYSTEM
RETURN nil
 

VERY important is FIRST line, where is description for encoding character map
<?xml version="1.0" encoding="windows-1250"?>
This sample have encoding="windows-1250" but other slovenian tax xml files wants encoding="utf-8"
And UTF-8 is a problem! I currenty work with xbase++ and I want to migrate to xHarbour but I dont find function
for convert ANSI / OEM TO UTF-8 ( Win1250ToUtf8(word)). In xbase++ I have this function, so my migration is "freeze"
until we dont have propriate xml/utf functions....

Best regards
Zupan Miran
Slovenia
Zupan Miran
 
Posts: 5
Joined: Mon Mar 30, 2009 9:06 pm
Location: Slovenia

Re: XSD to XML

Postby Marc Vanzegbroeck » Wed Apr 01, 2009 6:24 pm

Zupan,

Thanks for the info, but the problem is that I don't have an example XML to do the reverse engineering.
I only have the XSD-file :(

Regards,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: XSD to XML

Postby Zupan Miran » Wed Apr 01, 2009 6:33 pm

Try a free Microsoft XML NOTEPAD 2007

[url]
http://msdn.microsoft.com/en-us/library/aa905339.aspx
[/url]

Inport your XSD file -> and in XSL OUTPUT tab you see xml (txt) code ...

Zupan Miran
Zupan Miran
 
Posts: 5
Joined: Mon Mar 30, 2009 9:06 pm
Location: Slovenia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 91 guests