# Do we "own" XML namespace?

**URL:** <https://www.ruby-forum.com/t/do-we-own-xml-namespace/143046>\
**Category:** Ruby\
**Created:** [July 14, 2008, 7:46pm UTC](https://www.ruby-forum.com/t/do-we-own-xml-namespace/143046 "2008-07-14T19:46:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [July 14, 2008, 7:46pm UTC](https://www.ruby-forum.com/t/do-we-own-xml-namespace/143046/1 "2008-07-14T19:46:22Z")

</div>

Hi–

Little bit of debate going on with LibXML, and I’d like to get some  
general feed back.

Currently the module namespace used by libxml-ruby is “XML”, so we see  
code like:

require ‘libxml’

XML::Document.new

The question is whether that’s fair, since it sort of lays claim to  
“XML” as owned by the libxml project. It also means the libraries name  
does not correspond to the top module name. So we are considering  
instead switching to:

LibXML::Document.new

(though we would leave backward compatibility in for a while). Another  
option is:

LibXML::XML::Document.new

since one can always do

include LibXML

to get the same functionality that we have now.

What do others think? What is the best/proper approach here?

Thanks,  
T.

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [July 14, 2008, 10:40pm UTC](https://www.ruby-forum.com/t/do-we-own-xml-namespace/143046/2 "2008-07-14T22:40:51Z")

</div>

On Mon, Jul 14, 2008 at 10:40 AM, Trans [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> (though we would leave backward compatibility in for a while). Another  
> option is:
> 
> LibXML::XML::Document.new
> 
> since one can always do
> 
> include LibXML
> 
> to get the same functionality that we have now.

I like this one - it lets you use the XML namespace without  
monopolising it. It also allows someone writing a drop-in replacement  
for LibXML to use the same trick and have code switch effortlessly  
between the two.

martin

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [July 15, 2008, 2:04am UTC](https://www.ruby-forum.com/t/do-we-own-xml-namespace/143046/3 "2008-07-15T02:04:31Z")

</div>

Some thoughts…

> > LibXML::XML::Document.new
> 
> > since one can always do
> 
> > include LibXML

So I didn’t actually do that. Instead, I moved LibXML into a new  
LibXML module.

So:

LibXML::Document.new

Then for backwards compatibility in libxml.rb:

module XML  
include LibXML  
end

I prefer this approach because having to type in LibXML::XML  
constantly would be annoying (sure you could do an include, but that  
would also be annoying). Since we’re making this change, let’s make  
sure that future usage of the API is a pleasant as possible.

> I like this one - it lets you use the XML namespace without  
> monopolising it. It also allows someone writing a drop-in replacement  
> for LibXML to use the same trick and have code switch effortlessly  
> between the two.

Right - and that should still work exactly the same. You’d have to  
either uncomment out the libxml require code (true for both  
approaches), or remove the XML module and replace it with your own  
(also true for both approaches).

Charlie

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [July 15, 2008, 4:03am UTC](https://www.ruby-forum.com/t/do-we-own-xml-namespace/143046/4 "2008-07-15T04:03:37Z")

</div>

cfis [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> LibXML module.
> 
> So:
> 
> LibXML::Document.new

Charlie - sounds great, just yell real loud when the gem update  
implementing this change comes online… 🙂 Thx! - m.
