|
From: Dan K. <da...@ku...> - 2002-01-28 14:08:21
|
I downloaded and am using the tcldom-2.0
theta release for building xml documents.
I have a question about some of the logic.
In tcldom-2.0theta/dom.tcl on around line 2756
I see:
switch [info exists node(node:namespaceURI)],[info exists
node(node:prefix)] {
I have a question about this logic. Even though I never
define a namespace URI or prefix, the 1,1 case is getting
tripped and I get XML that looks like this:
set doc [::dom::DOMImplementation create]
set root [::dom::document createElement $doc File]
foreach number [list 1 2 3] {
set record [::dom::document createElement $root Record]
::dom::element setAttribute $record number $number
}
puts stderr [::dom::DOMImplementation serialize \
$doc -newline [list File Record]]
::dom::DOMImplementation destroy $doc
<:File>
<:Record number="0"/>
<:Record number="1"/>
<:Record number="2"/>
<:/File>
I changed lines 2758 - 2773 to:
1,1 {
# XML Namespace is in scope, prefix supplied
if {[string equal $node(node:prefix) ""]} {
set nsPrefix {}
} else {
set nsPrefix "$node(node:prefix):"
}
}
1,0 {
# XML Namespace is in scope, no prefix
set nsPrefix "[GetNamespacePrefix $token $node(node:namespaceURI)]:"
if {[string equal $nsPrefix {:}]} {
set nsPrefix {}
}
}
I also made a purely cosmetic change to dom::Serialize:element
to remove newlines from a couple places that are output when
the -newline option is specified.
This was to get output like:
<?xml version='1.0'?>
<!DOCTYPE File>
<File>
<Record number="1"/>
<Record number="2"/>
<Record number="3"/>
</File>
Let me know what you think...
--Dan
[please cc me on replies since I don't subscribe to
this mailing list -- thanks]
|