in reply to XML::Twig and namespaces
A test case would be helpful indeed, but I can try guessing.
ns_prefix returns a prefix for the element and that prefix is indeed bound in the XML document
Indeed, the prefix is bound in the XML document. But the newly created element is not part of a document. It's just a single detached element as far as XML::Twig is concerned. So it can't get the namespace information from its parent elements.
I have to think about it a bit, and see what other libraries do, because possible requirements are a bit hard to all satisfy:
At the moment you could probably get the namespace information by keeping a link to the original element in the copied document (stick it in an invisible attribute), and get the namespace info from it:
$copied->set_att( '#elt', $elt); my $namespace= $copied->att( '#elt')->namespace();
In fact I might well use something like that to solve the problem.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: XML::Twig and namespaces
by DJpumps (Novice) on Jul 04, 2007 at 09:36 UTC | |
|
Re^2: XML::Twig and namespaces
by DJpumps (Novice) on Jul 04, 2007 at 09:13 UTC |