[Ocaml-pxp-users] Sending NUL chars in documents with PXP
Gerd Stolpmann
info at gerd-stolpmann.de
Mon May 23 14:15:04 PDT 2005
Am Montag, den 23.05.2005, 20:33 +0100 schrieb Richard Jones:
> How do I send an XML document containing an ASCII NUL ('\000') char?
Easy answer: This is not possible. XML documents must not contain
control characters other than CR, LF, and TAB.
I don't remember the details, but there is definitely a way of encoding
binary SOAP data (part of the SOAP protocol, not part of XML).
Gerd
>
> 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
>
>
--
------------------------------------------------------------
Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany
gerd at gerd-stolpmann.de http://www.gerd-stolpmann.de
------------------------------------------------------------
More information about the Ocaml-pxp-users
mailing list