Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^4: XML::Twig Text replacement

by mirod (Canon)
on May 03, 2010 at 09:12 UTC ( [id://838046]=note: print w/replies, xml ) Need Help??


in reply to Re^3: XML::Twig Text replacement
in thread XML::Twig Text replacement

There are actually 3 ways of dealing with namespaces, 2 of which are supported by XML::Twig:

  • proper support, your second example, which is correct, but verbose as you have to associated namespace URIs to prefixes; I also suspect that it is not as robust as one would expect, I don't quite trust those URIs to not change sneakily, especially for the default namespace,
  • ignore namespace declarations is XML::Twig's default mode, there foo:ele is the element by that name, and ele is just ele, whether it is assigned a default namespace or not, you think of this as inconsistent,
  • drop all namespaces, which is your first example, there foo:ele is seen as ele; I had never thought of that option, I could add it, but I strongly suspect that it would be one favored only by users who care about namespaces, and already use map_xmlns (or XML::LibXML!),

For XML::Twig, consistency is not as important as convenience, and I the current behaviour seems to be convenient for most users. I'll look into adding an option to just drop namespaces, it should not be too difficult, but I am not sure how useful it would be.

Replies are listed 'Best First'.
Re^5: XML::Twig Text replacement
by ikegami (Patriarch) on May 03, 2010 at 15:44 UTC

    There are actually 3 ways of dealing with namespace

    "Drop" and "ignore" mean the same thing. At the very least, the difference is ambiguous. Let's clarify:

    • Standard support (verbose)
    • Ignore namespace declarations (assume everything is in the null namespace)
    • Ignore namespace declarations and make prefixes significant.

    The last is XML::Twig's default. It also supports the first.

    For XML::Twig, consistency is not as important as convenience

    That's exactly the point I was making.

    Prefixes are arbitrary strings that can and do change from document to document. The employment of a default namespace also can and does change from document to document.

    It would very convenient if it could ignore namespaces, but it doesn't have a way of doing that. Instead of just ignoring namespaces, the default is to make make the prefix significant. Not only is that a step in the wrong direction, it makes it unusable in theory and in practice.

    Being unable to use XML::Twig under common circumstances is not convenient at all.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://838046]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2024-04-25 15:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found