[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: XML Writer Service program



Hi Henrik

I have tried this and got it working, I had problems with clrSrvPgm() Should
this be clearSrvPgm, when I changed it I still issues with 

nbrVars = zhbgetinput(savedquerystring:qusec); in service program, and
commented it out, what is the effect of this.

Also XML browser did not like first few lines of output. i.e.

	Content-type: text/xml

	# This is a generated xml-file   (I replaced this with  echo('<!This
is a generated xml-file of Deliverys from AWH Pty'); )

I also changed the codepage to 819 instead of 1208 as this seemed to cause
issues.

Sorry bit rusty in this area. Thaks for your help.

Nick Runnalls



-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
[mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of hr@xxxxxxxxxxxx
Sent: Wednesday, 8 July 2009 12:24 AM
To: HTTPAPI and FTPAPI Projects
Subject: Re: XML Writer Service program


Hi,

enclosed is a service program that does the trick;

Sample code
--------------------------------------------------------
clrSrvPgm();

// setGlobalTab(*off);   // compress the file
// setGlonalNL(*off);    // by omitting Tab's and CRLF

// if you wish to send it out over HTTP
setContent('text/xml');

echo('# This is a generated xml-file');
echo('');

xmlNode('xml');
  xmlNode('header':'custNumber='+%char(cust));
    xmlNode('name':'':cuname);                   // "Jon & Susan"
    xmlNode('adress':'':cuadrs);
    select;
      when country = 'dk';
        xmlNode('zip':'list=dk':%char(cuzip));
      when country = 'usa';
        xmlNode('zip':'list=us':%char(cuzip));
    endsl;
  xmlEndNode();
xmlEndNode();

select;
  when output = 'file';               // Output to File
    echoToStmf('/testxml.xml':1208);    // most XML converters likes UTF-8
  when output = 'http';               // Output to HTTP buffer
    echoFini();
endsl;

Result:
---------------------------------------------------------
Content-type: text/xml

# This is a generated xml-file 

<xml>
        <header custNumber=123456>
                <name>Jon &#38; Susan</name>
                <adress>Stampedammen</adress>
                <zip list=dk>1234</zip>
        </header>
</xml>


This code is done by a CGIDEV2 service extension program that handles not
only the single node's but also the tree, so there is no need to insert tabs
or to remember parent nodes when 
ending them with xmlEndNode() and it eliminates spelling
errors between start and end nodes.

It also automatically handles the special character incoding 
of strings in the XML.

And there is no need for CGIDEV2 templates wich does it far 
easier to include/exclude elements by just using inline tests.



Note:

The enclosed basic service program is part of a larger WEB 2.0 (ext JS)
project that will be released later this year and it 
is build on top of a modified CGIDEV2 (Scott's CCSID support 
modification for Unicode CCSID). 



Regards
Henrik







Nicolas Machado <nicolas.machado@xxxxxxxxxxxxx> 
Sent by: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
06-07-2009 16:34
Please respond to
HTTPAPI and FTPAPI Projects <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>


To
HTTPAPI and FTPAPI Projects <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
cc

Subject
XML Writer Service program






Hi,
I'm starting a project that need to write xml files.
I know that there is no mora "rocket science" that wrinting to a stream 
file in teh IFS.

But I'm wondering is someone has developed something like:

   xml =  pCreateXmlObject();
    pWriteStartElement(xml : 'Invoice') ;
    pWriteTag(xml : 'InvNro' : $InvoiceNumber ) ;
    pWriteEndElement(xml)


To for example create this xml
    <Invoice>
          <InvNr>some value</InvNr>
    </Invoice>

If anyone has something , please let me know.

-- 
.::.
Nicolas Machado
Metodo Argentina S.A.
_____________________
Tel: 02262 527431
Necochea, Buenos Aires.

-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------


-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------