Hi guys, sorry for being a pest, this is yet another post regarding XML::Rules. I'm just finishing the namespace support and would like to discuss it a bit before the public release. So that I can change the design if it doesn't sound right :-)
The way I've implemented the support is in short:
What this means is that you (as the module user) specify what alias do you expect for what namespace and the module changes or adds the aliases used in the XML so that the <Foo> tag from the http://my.namespaces.com/foo namespace always invokes the 'foo:Foo' rule no matter whether it's written as
<Foo xmlns="http://my.namespaces.com/foo">...</Foo>
or<root xmlns:f="http://my.namespaces.com/foo">... <f:Foo>...</f:Foo> </root>
<root xmlns="http://my.namespaces.com/foo">... <Foo>...</Foo> </root>
Does this sound like a sensible implementation to you?
The namespace support section of the docs follows:
=head1 Namespace support By default the module doesn't handle namespaces in any way, it doesn't + check for xmlns or xmlns:alias attributes and it doesn't strip or mangle the nam +espace aliases in tag or attribute names. This means that if you know for sure what n +amespace aliases will be used you can set up rules for tags including the alias +es and unless someone decides to use a different alias or makes use of the default n +amespace change your script will work. If you do specify any namespace to alias mapping in the constructor it + does start processing the namespace stuff. The xmlns and xmlns:alias attrib +utes are stripped from the datastructures and the aliases are transformed f +rom whatever the XML author decided to use to whatever your namespace mapp +ing specifies. Aliases are also added to all tags that belong to a default + namespace. Assuming the constructor parameters contain namespaces => { 'http://my.namespaces.com/foo' => 'foo', 'http://my.namespaces.com/bar' => 'bar', } and the XML looks like this: <root> <Foo xmlns="http://my.namespaces.com/foo"> <subFoo>Hello world</subfoo> </Foo> <other xmlns:b="http://my.namespaces.com/bar"> <b:pub> <b:name>NaRuzku</b:name> <b:address>at any crossroads</b:address> <b:desc>Fakt <b>desnej</b> pajzl.</b:desc> </b:pub> </other> </root> then the rules wil be called as if the XML looked like this: <root> <foo:Foo> <foo:subFoo>Hello world</foo:subfoo> </foo:Foo> <other> <bar:pub> <bar:name>NaRuzku</bar:name> <bar:address>at any crossroads</bar:address> <bar:desc>Fakt <b>desnej</b> pajzl.</bar:desc> </bar:pub> </other> </root> This means that the namespace handling will only normalize the aliases + used. It is possible to specify an empty alias, so eg. in case you are proce +ssing a SOAP XML and know the tags defined by SOAP do not colide with the tags in the e +nclosed XML you may simplify the parsing by removing all namespace aliases. If the XML references a namespace not present in the map you will get +a warning and the alias used for that namespace will be left intact!
Update 2007-2-12: Thanks for the lively discussion :-( The new version including this feature was just uploaded to CPAN.
|
|---|