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

David McMath mcdave at stanford.edu
Mon Aug 6 21:12:24 GMT 2012


Mark,

Thanks for your comments and your work on these packages.  I have some 
followup questions below.

On 08/03/2012 05:55 PM, Mark Overmeer wrote:
> * David McMath (mcdave at stanford.edu) [120803 15:13]:
>> Whenever I try to put an attribute from another namespace into my
>> element, I get warnings that are variations on "tag `wsu_Id' not
>> used", as in the following:
>
> For XML::Compile, it is important to know beforehand (compile-time)
> what to expect on a certain node.  With 'any' and 'anyAttribute',
> the schema explicitly hints on unspecified extensions (gladly we
> now have substitutionGroups).  However: any element is allowed to
> have any number of attributes... wildly checking for that on every
> element would be very expensive.
>
> With some tricks using hooks, it is possible to get this to
> work.  Probably I should create a generic hook for this, because
>         $schema->addHook(...)
> is certainly not easy enough.  Adding/parsing an attribute in a hook
> can be simple... however the generic implementation (understanding
> fixed/default/validation/etc) is a bit more work.

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.

That said, here's what I understand the advice to be:  A bad way to do 
it would be to just call setAttributeNS on my Username element after 
it's written.  A better way would be to add an "after" hook to the 
schema itself so that elements of type

 
{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}UsernameToken

get something like

   $token->setAttributeNS( 
'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd', 
'Id', $theRightID ) ;

That's somewhat gibberish but on the right track, maybe?

>
>> PS.  My code.  For purposed of my experiment, I stuck the method in
>> XML::Compile::SOAP::WSS because I started out thinking I'd just
>> override wsseBasicAuth but that didn't end up making sense.
>
> It seems that everyone needs something else :(  At least what I
> read in the many specs, there are many separate groups which
> invented their own extensions.  If some extensions are used more
> regularly, I can include a standard implementation for that.


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

Again, thanks for your feedback and your work,

dave



More information about the Xml-compile mailing list