[Ocaml-pxp-users] Forcing xmlns declarations to be written out

Gerd Stolpmann info at gerd-stolpmann.de
Mon May 23 14:11:45 PDT 2005


Am Montag, den 23.05.2005, 17:42 +0100 schrieb Richard Jones:
> Is there a way to force PXP to write xmlns declarations, even ones
> which are "apparently" useless?
> 
> I have the following SOAP document:
> 
> 	<?xml version="1.0" encoding="UTF-8"?>
> 	<soap:Envelope
> 	xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> 	><soap:Body
> 	><fn:echo_bool
> 	xmlns:fn="http://localhost:50881"
> 	><fn:c-gensym1
> 	xsi:type="xsd:boolean"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 	>true</fn:c-gensym1
> 	></fn:echo_bool
> 	></soap:Body
> 	></soap:Envelope
> 	>
> 
> The problem is the attribute xsi:type="xsd:boolean".  In SOAP the xsd:
> prefix in the attribute's _value_ is supposed to refer to a namespace,
> and that's supposed to have been declared earlier, ie. something like
> <soap:Envelope ... xmlns:xsd="...">
> 
> However since the xsd: prefix isn't declared, the SOAP server can't
> parse the above request, complaining that:
> 
> 	Application failed during request deserialization: Unresolved
> 	prefix 'xsd' for attribute value 'xsd:boolean'
> 
> Also for aesthetic reasons I'd like my xsi and xsd namespaces to be
> declared as attributes in the Envelope.
> 
> Any tips on how to do this?

You need to customize the namespace_scope object tree for this. This
tree represents the structure of the namespace declarations in the XML
tree.

On the envelope node env_node, do

let scope = Pxp_dtd.create_namespace_scope 
              ~decl:["xsd", "<URI>"; ... ] mng in
  (* where mng is the namespace_manager *)
env_node # set_namespace_scope scope

The display method respects the scope tree (and magically invents
missing scope objects, so you generally do not need scopes).

Well, I see, an update of the PXP manual is overdue.

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