<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://panoptic.com/mediawiki/aolserver/index.php?action=history&amp;feed=atom&amp;title=TDOM</id>
	<title>TDOM - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://panoptic.com/mediawiki/aolserver/index.php?action=history&amp;feed=atom&amp;title=TDOM"/>
	<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=TDOM&amp;action=history"/>
	<updated>2026-04-09T09:08:38Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=TDOM&amp;diff=5054&amp;oldid=prev</id>
		<title>Jcr at 01:45, 20 March 2007</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=TDOM&amp;diff=5054&amp;oldid=prev"/>
		<updated>2007-03-20T01:45:08Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 01:45, 20 March 2007&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l84&quot; &gt;Line 84:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 84:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;a few people the same agony.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;a few people the same agony.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;----&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;While the above code generally works, the explanation is slightly incorrect.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;It is not naming the the default namespace, is is binding a known&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;prefix to the uri of the default namespace, which it looks up.  An xml namespace&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;is not the (possibly null) prefix; is is the uri to which the prefix is bound.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;In particular, to match nodes, the prefixes need not match, but the namespace uris&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;must.  Plain xml obscures this to a certain extent, but xpath makes it painfully&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;clear.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;The right thing to do is to always know what namespace uris are being used&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;in the document, and assign known prefixes to all of them rather than to rely on&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;the context node having all the needed (and convenient) bindings.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Note too that the above code will be of no help if the null prefix is assigned&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;or changed in a child of the context node.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;----&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Modules]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Modules]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jcr</name></author>
		
	</entry>
	<entry>
		<id>https://panoptic.com/mediawiki/aolserver/index.php?title=TDOM&amp;diff=3014&amp;oldid=prev</id>
		<title>Dossy: moved from [[Tdom] page; category link fixup, formatting tweaks</title>
		<link rel="alternate" type="text/html" href="https://panoptic.com/mediawiki/aolserver/index.php?title=TDOM&amp;diff=3014&amp;oldid=prev"/>
		<updated>2005-10-09T01:37:26Z</updated>

		<summary type="html">&lt;p&gt;moved from [[Tdom] page; category link fixup, formatting tweaks&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Documentation is available at http://www.tdom.org/doc-index.html&lt;br /&gt;
&lt;br /&gt;
A very helpful tutorial is available at http://wiki.tcl.tk/8984&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[Dossy]]: [http://www.mail-archive.com/aolserver@listserv.aol.com/msg06871.html Assigning a prefix to the default namespace when using XPath in tDOM]&lt;br /&gt;
&lt;br /&gt;
I don't know how many folks are using tDOM but I'm sure more and more&lt;br /&gt;
are.  I keep stumbling into this problem of trying to access child nodes&lt;br /&gt;
which are in the default namespace but the parent is in a named&lt;br /&gt;
namespace ... and trying to write XPath expressions start to look really&lt;br /&gt;
dog-awful, like:&lt;br /&gt;
&lt;br /&gt;
    $root selectNodes {/*[local-name()='foo']/*[local-name()='bar']/...}&lt;br /&gt;
&lt;br /&gt;
So, I sat down for a few minutes and thought about the problem, and&lt;br /&gt;
after some head-scratching, it hit me: name the default namespace.  Duh.&lt;br /&gt;
So, here's some sample code:&lt;br /&gt;
&lt;br /&gt;
    ### IMPORTANT: This code lets us get at nodes with a null prefix.&lt;br /&gt;
    if {[$root hasAttribute xmlns]} {&lt;br /&gt;
        $root setAttributeNS &amp;quot;&amp;quot; xmlns:default [$root getAttribute xmlns]&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
So, now, I can rewrite that XPath expression above:&lt;br /&gt;
&lt;br /&gt;
    $root selectNodes /default:foo/default:bar/...&lt;br /&gt;
&lt;br /&gt;
Man.  Life just couldn't get any better.&lt;br /&gt;
&lt;br /&gt;
If any of you are wondering why this matters, here's a sample XML doc&lt;br /&gt;
and some sample code illustrating the beauty:&lt;br /&gt;
&lt;br /&gt;
    set xml {&lt;br /&gt;
        &amp;lt;aaa:duh xmlns=&amp;quot;booboo&amp;quot; xmlns:aaa=&amp;quot;blort&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;foo&amp;gt;&lt;br /&gt;
                &amp;lt;bar&amp;gt;some text&amp;lt;/bar&amp;gt;&lt;br /&gt;
            &amp;lt;/foo&amp;gt;&lt;br /&gt;
        &amp;lt;/aaa:duh&amp;gt;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    $doc [dom parse $xml]&lt;br /&gt;
    set root [$doc documentElement]&lt;br /&gt;
&lt;br /&gt;
Suppose you want to get the text node inside &amp;lt;bar&amp;gt; with an absolute&lt;br /&gt;
XPath expression.  You might think you could write:&lt;br /&gt;
&lt;br /&gt;
    [$root selectNodes /aaa:duh/foo/bar] text&lt;br /&gt;
&lt;br /&gt;
Ah, but XPath *SPANKS* us and tells us we're naughty, that &amp;lt;foo&amp;gt; and&lt;br /&gt;
&amp;lt;bar&amp;gt; have a null prefix and live in the unnamed namespace.  That line&lt;br /&gt;
of code returns an empty string, not &amp;quot;some text&amp;quot; as we might have&lt;br /&gt;
expected.  So, we tell XPath &amp;quot;well, how about you do me a favor and&lt;br /&gt;
pretend like any node in the unnamed namespace really has a name of my&lt;br /&gt;
choosing ...&amp;quot; by doing this:&lt;br /&gt;
&lt;br /&gt;
    $root setAttributeNS &amp;quot;&amp;quot; xmlns:default [$root getAttribute xmlns]&lt;br /&gt;
&lt;br /&gt;
We're telling the processor to name all nodes in the default namespace&lt;br /&gt;
as though they were in the namespace named &amp;quot;default&amp;quot;.  N.B.:  If your&lt;br /&gt;
XML document really *HAS* a namespace named &amp;quot;default&amp;quot;, this code will&lt;br /&gt;
likely CLOBBER it and give you really weird behavior.  Change&lt;br /&gt;
&amp;quot;xmlns:default&amp;quot; in the above line to a namespace that won't ever exist&lt;br /&gt;
in your document, then.&lt;br /&gt;
&lt;br /&gt;
Now that we've done this, lets rewrite that XPath expression and try&lt;br /&gt;
again:&lt;br /&gt;
&lt;br /&gt;
    [$root selectNodes /aaa:duh/default:foo/default:bar] text&lt;br /&gt;
&lt;br /&gt;
Ahh!  It returned the string &amp;quot;some text&amp;quot; -- exactly what we wanted.&lt;br /&gt;
Notice the injection of &amp;quot;default:&amp;quot; above before &amp;quot;foo&amp;quot; and &amp;quot;bar&amp;quot; -- since&lt;br /&gt;
we just told the processor that nodes in the unnamed namespace (i.e.,&lt;br /&gt;
&amp;lt;foo&amp;gt; and &amp;lt;bar&amp;gt;) now live in the namespace named &amp;quot;default&amp;quot;, in order to&lt;br /&gt;
specify them in an XPath expression, we need to say &amp;quot;default:foo&amp;quot; and&lt;br /&gt;
&amp;quot;default:bar&amp;quot;.  But this is a hell of a lot easier to read than&lt;br /&gt;
&amp;quot;*[local-name()='foo']&amp;quot; and &amp;quot;*[local-name()='bar']&amp;quot;, at least on my&lt;br /&gt;
eyes.&lt;br /&gt;
&lt;br /&gt;
If this is all old news, feel free to ignore this email.  I hadn't seen&lt;br /&gt;
it documented anywhere and I know I've puzzled over this for at least an&lt;br /&gt;
hour or two over the past few months, so maybe this write-up might save&lt;br /&gt;
a few people the same agony.&lt;br /&gt;
&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Dossy</name></author>
		
	</entry>
</feed>