<html>

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered)">
<title>RE: [jdom-interest] The default namespace behaviour </title>
<style>
<!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:blue;
        text-decoration:underline;}
p.MsoAutoSig, li.MsoAutoSig, div.MsoAutoSig
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
p
        {margin-right:0in;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman";}
span.emailstyle18
        {font-family:Arial;
        color:navy;}
span.EmailStyle20
        {font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=blue>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>I was hoping to mimic the behavior that
XML files have.&nbsp; When using the default namespace, all un-prefixed sub
elements are within that namespace.</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&lt;a xmlns=&#8221;one&#8221;&gt;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp; &lt;b/&gt;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp; &lt;c/&gt;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&lt;/a&gt;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>The b and c tags are in the
&#8220;one&#8221; namespace.</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>If I changed this to:</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&lt;a xmlns=&#8221;two&#8221;&gt;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp; &lt;b/&gt;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp; &lt;c/&gt;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&lt;/a&gt;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>The b and c tags are in the
&#8220;two&#8221; namespace.&nbsp; I made one small change to a and got a
side-effect of changing b and c; this is how it works with written XML
documents.</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>If I parsed the first example and
generated a JDOM model and called
a.setNamespace(Namespace.getNamespace(&#8220;two&#8221;)) and then spit the
file out, what I would have, essentially, is:</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&lt;a xmlns=&#8221;two&#8221;&gt;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp; &lt;b xmlns=&#8221;one&#8221;/&gt;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp; &lt;c xmlns=&#8221;one&#8221;/&gt;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&lt;/a&gt;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>This doesn&#8217;t fit the XML idea that,
if you change the parent&#8217;s namespace, un-prefixed children will
implicitly change their namespace.</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<div>

<p class=MsoAutoSig><font size=3 color=navy face="Times New Roman"><span
style='font-size:12.0pt;color:navy'>----------------</span></font></p>

<p class=MsoAutoSig><font size=3 color=navy face="Times New Roman"><span
style='font-size:12.0pt;color:navy'>Colin LeMahieu</span></font></p>

<p class=MsoAutoSig><font size=3 color=navy face="Times New Roman"><span
style='font-size:12.0pt;color:navy'>Phone: 408-499-5269</span></font></p>

<p class=MsoAutoSig><font size=3 color=navy face="Times New Roman"><span
style='font-size:12.0pt;color:navy'>Fax: </span></font><font color=black><span
style='color:black'>267-989-4575</span></font></p>

<p class=MsoAutoSig><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt;color:black'>Email: clemahieu@gmail.com</span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 color=navy face="Times New Roman"><span
style='font-size:10.0pt;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 face="Times New Roman"><span style='font-size:
10.0pt'>I strongly disagree with your sense that:</span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 face="Times New Roman"><span style='font-size:
10.0pt'>a.setNamespace(namespace.getNamespace(&quot;ReallyLongNamespace&quot;));</span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;</span></font></p>

</div>

<div>

<p class=MsoNormal><font size=2 face="Times New Roman"><span style='font-size:
10.0pt'>should set the namespace for all child elements that use the same
default namespace as a. This would be a big leap for JDOM to make. Since it's
entirely legitimate to have different default namespaces at different levels,
having JDOM guess which ones you wanted to change would invariably be incorrect
(in other words, what if I really wanted setNamespace() to just set that
element's namespace). Writing the getDescendents()-using code above or even
better, as Mr. Huffman suggested, a custom JDOMFactory would be the best way to
go about explictingly specifying what transformation you wanted to do. </span></font></p>

<div>

<p class=MsoNormal><font size=2 color=navy face="Times New Roman"><span
style='font-size:10.0pt;color:navy'>&nbsp;</span></font></p>

</div>

</div>

</div>

</body>

</html>