FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour TO ANTONIO : XML CLASS
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
TO ANTONIO : XML CLASS
Posted: Sat Nov 28, 2009 10:38 AM

Dear Antonio,
the community need a xlm class.
I can create it but I not Know How make it
I saw on http://www.reportdesigner.info Timm made a class to read xlm class
Perhaps can be usefull a class to converte dbf to xlm file as the txls class

Best Regards, Saludos



Falconi Silvio
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: TO ANTONIO : XLM CLASS
Posted: Sat Nov 28, 2009 11:04 AM

Did you mean XML Class ?

Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: TO ANTONIO : XLM CLASS
Posted: Sat Nov 28, 2009 12:33 PM

yes

Best Regards, Saludos



Falconi Silvio
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: TO ANTONIO : XLM CLASS
Posted: Sat Nov 28, 2009 03:54 PM
There is a DBF to XML program on my website.

http://www.gointellitech.com/program.htm

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: TO ANTONIO : XLM CLASS
Posted: Sun Nov 29, 2009 03:11 PM

thanks james... and xmltodbf have you an idea ?

Best Regards, Saludos



Falconi Silvio
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: TO ANTONIO : XLM CLASS
Posted: Sun Nov 29, 2009 03:56 PM
xmltodbf have you an idea ?


No, I don't. That can be a lot more complex since there can be many XML formats and there is the additional issue that there may be data types in the XML file that are not supported in DBF files.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: TO ANTONIO : XML CLASS
Posted: Wed Dec 02, 2009 08:52 AM

James,
made a XML class from your file

there's also a n error but we can use this class now :

this is the generated file :


<?xml version="1.0" encoding="ISO-8859-1"?>
<CUSTOMER xmlns:dt="urn:schemas-microsoft-com:datatypes" Database = "CUSTOMER" >
<Record Numero = " 1" >
<FIRST>Homer </FIRST>
<LAST>Simpson </LAST>
<STREET>32179 Maiden Lane </STREET>
<CITY>Springfield </CITY>
<STATE>IL</STATE>
<ZIP>20503-8202</ZIP>
<HIREDATE dt:dt= "date">19920918</HIREDATE>
<MARRIED></MARRIED>
<AGE></AGE>
<SALARY></SALARY>
<NOTES>This is a test for record 1 </NOTES>
</Record>
<Record Numero = " 2" >
<FIRST>Ceci </FIRST>
<LAST>Gibbard </LAST>
<STREET>9540 Raynes Park Road </STREET>
<CITY>Miami </CITY>
<STATE>MA</STATE>
<ZIP>55774-2304</ZIP>
<HIREDATE dt:dt= "date">19841017</HIREDATE>
<MARRIED></MARRIED>
<AGE></AGE>
<SALARY></SALARY>
<NOTES>This is a test for record 2 </NOTES>
</Record>
<Record Numero = " 3" >
<FIRST>Reg </FIRST>
<LAST>Kaczocha </LAST>
<STREET>30522 Park Ten Place </STREET>
<CITY>Scottsdale </CITY>
<STATE>WY</STATE>
<ZIP>09226-1483</ZIP>
<HIREDATE dt:dt= "date">19890523</HIREDATE>
<MARRIED></MARRIED>
<AGE></AGE>
<SALARY></SALARY>

....


i HOPE I MADE A XMAS REGLA FOR ALL !!!

Best Regards, Saludos



Falconi Silvio
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: TO ANTONIO : XML CLASS
Posted: Wed Dec 02, 2009 09:28 AM

Silvio,

As far as I know, both Harbour and xHarbour provide a Class to manage XML

Could you please elaborate your class differences ? thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: TO ANTONIO : XML CLASS
Posted: Wed Dec 02, 2009 09:31 AM

Antonio I not Found it on contributions can you send me these files ?

Best Regards, Saludos



Falconi Silvio
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: TO ANTONIO : XML CLASS
Posted: Wed Dec 02, 2009 09:33 AM

Silvio,

Please check xHarbour CVS and Harbour SVN, both in SourceForge, thanks :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: TO ANTONIO : XML CLASS
Posted: Wed Dec 02, 2009 10:32 AM

Antonio,

I saw there is Txmldocument class but not is for fwh and I not time to try it

but I made a simply class to converte a dbf to xml

you can pubblish my class and renamed as TDBF2XML

Best Regards, Saludos



Falconi Silvio
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: TO ANTONIO : XML CLASS
Posted: Wed Dec 02, 2009 10:50 AM

Silvio,

We appreciate your contribution, but we will wait to have some users positive feedback about it, before including it into FWH, thanks :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: TO ANTONIO : XML CLASS
Posted: Wed Dec 02, 2009 04:57 PM

I resolved my problems for now
Perhaps We need also a read method

Best Regards, Saludos



Falconi Silvio
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: TO ANTONIO : XML CLASS
Posted: Wed Dec 02, 2009 07:01 PM

In order to have a read class, you are going to also have to export the field type and length in the write class. Without this information, the read class could not create the DBF.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: TO ANTONIO : XML CLASS
Posted: Thu Dec 03, 2009 08:53 AM
I found this function in the xHarbour newsgroup, published by Robert Campsmith to export a dbf to xml. Maybe it´s usefull for somone.

It uses the TXml classes, that come with the xharbour contribution.

Code (fw): Select all Collapse
// Robert Campsmith


#include "hbXml.ch"
****************************************
FUNCTION DBF2XML( cDataName, cOutName )
*
* Purpose: convert an xBase file to XML
*          returns the number of records converted
*
   LOCAL aStruct, aField, nFileHandle, nK := 0
   LOCAL oXmlDoc, oXmlNode, hAttr, cData
   LOCAL OXmlDatabase, oXmlStruct, oXmlRecord, oXmlField

   USE (cDataName)
   aStruct  := DbStruct()

   *- Create empty XML document with header
   oXmlDoc  := TXmlDocument():new( '<?xml version="1.0"?>' )

   *- Create main XML node
   oXmlDatabase := TXmlNode():new( , "database", { "name" => GetFileName(cDataName) } )
   oXmlDoc:oRoot:addBelow( oXmlDatabase )

   *- copy structure information to XML
   oXmlStruct := TXmlNode():new( , "structure" )
   oXmlDataBase:addBelow( oXmlStruct )

   FOR EACH aField IN aStruct
      *- store field information in XML attributes
      hAttr := { "name" => Lower( aField[1] ), ;
                 "type" => aField[2], ;
                 "len"  => LTrim( Str(aField[3]) ), ;
                 "dec"  => LTrim( Str(aField[4]) )  }

      oXmlField := TXmlNode():new(, "field", hAttr )
      oXmlStruct:addBelow( oXmlField )
   NEXT

   *- copy all records to XML
   oXmlNode := TXmlNode():new( , "records" )
   oXmlDataBase:addBelow( oXmlNode )

   BEGIN SEQUENCE

   DO WHILE !EOF() .and. RECNO() < 101
      hAttr      := { "id" => LTrim( Str( Recno() ) ) }
      oXmlRecord := TXmlNode():new( , "record", hAttr )

      FOR EACH aField IN aStruct
         IF aField[2] == "M"
            *- Memo fields are written as CDATA
            cData     := FieldGet( Hb_EnumIndex() )
            oXmlField := TXmlNode():new( HBXML_TYPE_CDATA  , ;
                                         Lower( aField[1] ), ;
                                         NIL               , ;
                                         cData               )
         ELSE
            *- other fields are written as normal tags
            cData     := FieldGet( Hb_EnumIndex() )
            cData     := Alltrim( CStr( cData ) )
            oXmlField := TXmlNode():new( HBXML_TYPE_TAG    , ;
                                         Lower( aField[1] ), ;
                                         NIL               , ;
                                         cData               )
         ENDIF
         *- add field node to record
         oXmlRecord:addBelow( oXmlField )
      NEXT

      *- add record node to records
      oXmlNode:addBelow( oXmlRecord )
      SKIP
   ENDDO

   *- create XML file
   nFileHandle := FCreate( cOutName )

   *- write the XML tree, this takes a long time.
   oXmlDoc:write( nFileHandle, HBXML_STYLE_INDENT )

   *- close files
   FClose( nFileHandle )
   END // SEQUENCE
   CLOSE (cDataname)

RETURN( nK )
*
kind regards

Stefan