[Xml-compile] Need help with XML::Compile::Translate::Writer and attributes with namespace

Mark Overmeer mark at overmeer.net
Mon Aug 6 22:47:43 GMT 2012


* David McMath (mcdave at stanford.edu) [120806 21:12]:
> I read through the section at
>    http://search.cpan.org/~markov/XML-Compile-1.25/lib/XML/Compile/Schema.pod#Schema_hooks
> 
> but I'm not that much wiser now on what a hook really looks like.
> It's clearly a method that gets executed either before, during, or
> after the element's creation, but I don't have any good examples to
> copy.

In this case, it is a writer.  XML::Compile::Translate::Writer/hooks
The nicest way is probably to use a "replace" hook:

   $scheme->addHook(type => 'wsse:Security', replace => \&add_wsu);

   sub add_wsu
   {    my ($doc, $values, $path, $tag, $r) = @_
        my $id   = delete $values->{wsu_id};
        my $node = $r->($values);
        $node->setAttributeNS(WSU_10, 'Id', $id);
        $node;
   }

I think above will do.  I do not know which WSS elements do carry a
wsu:Id... it is easy to add this as wrapper for all those elements,
but I just do not know.

> The way I read the username/password requirements, when one uses a
> digest, there are optional elements in addition to "password".
> They're "nonce", "created", and "expires", and, if they're present,
> they change they way the password is encoded.  I thought of trying
> to make wsseBasicAuth take those optional parameters, but the only
> sensible way I could see to do that would be to add a hashref
> argument.  That was changing the signature of the method too much
> and got scary.  It seems like a good thing to try to do, though (in
> my opinion).

The interface is probably not suffient.  It needs some extension...
No-one pays me for this module, nor do I need it myself.  So the priority
is determined by bug-reports and the most active contributors ;-b
I think you gave me an example in the first message.  Is that complete?
-- 
Regards,

               MarkOv

------------------------------------------------------------------------
       Mark Overmeer MSc                                MARKOV Solutions
       Mark at Overmeer.net                          solutions at overmeer.net
http://Mark.Overmeer.net                   http://solutions.overmeer.net




More information about the Xml-compile mailing list