[Ocaml-pxp-users] Sending NUL chars in documents with PXP
Richard Jones
rich at annexia.org
Mon May 23 12:33:29 PDT 2005
How do I send an XML document containing an ASCII NUL ('\000') char?
I have the test program (attached below), which creates a document
which looks like this:
$ ./nullchar | hexdump -c
0000000 < t e s t \n > \0 < / t e s t \n >
However when the remote SOAP server receives documents like this, it
gives me the following error, where the error position is the position
of the NUL char.
Application failed during request deserialization: not well-formed
(invalid token) at line 10, column 1, byte 338 at
/usr/lib/perl5/XML/Parser.pm line 187
This leads me to believe that PXP ought to be escaping the NUL char in
some manner, but my knowledge of XML isn't good enough to know how to
do this. The upshot is that I can't send these sorts of strings or
characters to a SOAP server.
Rich.
----------------------------------------------------------------------
(* Compile: ocamlc -I +pcre -I +netstring -I +pxp-lex-iso88591 -I +pxp-engine unix.cma pcre.cma netstring.cma pxp_engine.cma pxp_lex_iso88591.cma pxp_lex_link_iso88591.cmo nullchar.ml -o nullchar *)
let dtd =
let collect_warnings = Pxp_types.default_config.Pxp_types.warner in
let rep_encoding = Pxp_types.default_config.Pxp_types.encoding in
let dtd = new Pxp_dtd.dtd collect_warnings rep_encoding in
dtd#allow_arbitrary;
dtd
let spec =
let default_element_exemplar = new Pxp_document.element_impl
Pxp_tree_parser.default_extension in
let data_exemplar = new Pxp_document.data_impl
Pxp_tree_parser.default_extension in
Pxp_document.make_spec_from_alist ~data_exemplar
~default_element_exemplar ~element_alist:[] ()
let () =
let node = Pxp_document.create_element_node spec dtd "test" [] in
let data = Pxp_document.create_data_node spec dtd "\000" in
node#set_nodes [data];
node#write (`Out_channel stdout) `Enc_utf8
--
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Team Notepad - intranets and extranets for business - http://team-notepad.com
More information about the Ocaml-pxp-users
mailing list