[Ocaml-pxp-users] Several questions about PXP API

Richard Jones rich at annexia.org
Sat May 14 03:52:17 PDT 2005


I'm using roughly the following PXP code to generate a SOAP document.
The output it produces (reproduced below) isn't really a good XML
document.

I tried creating a full "'a document", but kept getting the error
Fatal error: exception Failure("#write: DTD without root")

Can anyone show me how to make a simple document?

Secondly, what I really want to do is use namespaces.  I basically
altered the code below to use default_namespace_spec and
default_namespace_config.  However any attempt to use namespaces
results in this message at runtime:
Fatal error: exception Pxp_core_types.Namespace_method_not_applicable("namespace_manager")

Can someone show me some simple code which just parses a document with
namespaces and then (for example) prints it out?

Rich.

----------------------------------------------------------------------
let dtd =
  new Pxp_dtd.dtd Pxp_types.default_config.Pxp_types.warner
    Pxp_types.default_config.Pxp_types.encoding

let create_element name =
  Pxp_document.create_element_node ~valcheck:false
    Pxp_tree_parser.default_spec dtd name []
let create_data data =
  Pxp_document.create_data_node Pxp_tree_parser.default_spec dtd data

let soap_call name params =
  (* Generate the envelope. *)
  let env = create_element "Envelope" in
  let body = create_element "Body" in
  env#set_nodes [body];
  let call = create_element name in
  body#set_nodes [call];
  call#set_nodes (Array.to_list params);

  (* Generate the SOAP message. *)
  let buf = Buffer.create 1024 in
  env#write (`Out_buffer buf) `Enc_utf8;
  let data = Buffer.contents buf in

  print_endline data
----------------------------------------------------------------------

<Envelope
><Body
><show
><campaign
><dailyBudget
>10</dailyBudget
><id
>11</id
></campaign
></show
></Body
></Envelope
>


-- 
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