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

Re: http_parse_xml_string usage



Hi Rick,

> XMLData = '<OrderID>123</OrderID>';
> 
> rc = http_parse_xml_string(%addr(XMLData) : %len(XMLData)
>    : HTTP_XML_CALC : %paddr(BegTag) : %paddr(EndTag) : *null);

HTTP_XML_CALC is not supported with http_parse_xml_string().  Note the
docs for http_parse_xml_Stmf() list HTTP_XML_CALC as a valid value, but
the docs for http_parse_xml_string() do not.

Even if I did support HTTP_XML_CALC (and, again, I do not) it makes
little sense in your example.  In your example, the data is in EBCDIC,
but the processing directive <?xml encoding=xxx ?> doesn't exist, so the
parser should (per XML standards) fall back on ISO-8859-1 which is a
flavor of ASCII.  So even if I decided to support HTTP_XML_CALC, your
code would still not work.


> I receive XML parse failed at line 1, col 0: not well-formed (invalid
> token).

That's because the EBCDIC value for < is not a valid start for an XML
document.  (It has to be ASCII or Unicode).


>    Finally I am not clear on the purpose of  the last parameter to the
>    function
>                "peUsrDta = (input) user-defined data that will be passed
>    to the call-back routine"          

You can pass any pointer you like in that parm.  HTTPAPI will remember
it and will pass it back to your 'BegTag' and/or 'EndTag' routines (from
your example code) as the first parameter.

That's all it does, remember a pointer you passed, and pass it on to
your handler routines.

Why would you want to do that, you ask?   Because you may not want to
use global variables.  For example, if you want to extract the 123 from
your example and return it to the routine that called
http_parse_xml_string(), how would you do that?   You could use global
variables, of course, but many folks try to avoid those.  Plus, what if
your BegTag/EndTag routines are in a different module from the one that
runs http_parse_xml_string()??

So HTTPAPI gives you one pointer you can pass.  It can point to a
variable in your program, or a data structure, or even something like a
user space -- entirely in the control of the routine that calls
http_parse_xml_string().  Whatever address you pass will be sent on to
your BegTag/EndTag routines that can use it to store information, or
anything else you might wish to pass to them.  (Maybe you want to pass
an FD for a stream file to the handlers, and have the handlers write to
that stream file?  Or a socket descriptor?  etc, etc..)

Basically, HTTPAPI doesn't know anything about it... it's just an
address passed on to your code.  You can use it for any purpose you like.


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