|
From: Dan K. <ku...@cs...> - 2002-02-08 00:29:17
|
I replaced the proc dom::Serialize:element with the following
to prevent excessive newlines from being printed in the output.
I don't know if the newlines are in there to be consistant with
the C version, but I think the output is more pleasant without
the extra newlines (only one newline per element).
Thanks!
--Dan
proc dom::Serialize:element {token args} {
array set node [set $token]
array set opts {-newline {}}
array set opts $args
set result {}
set newline {}
if {[lsearch $opts(-newline) $node(node:nodeName)] >= 0} {
set newline \n
}
append result [eval Serialize:Indent [array get opts]]
switch [info exists node(node:namespaceURI)],[info exists
node(node:prefix)] {
1,1 {
# XML Namespace is in scope, prefix supplied
if {[string length $node(node:prefix)]} {
set nsPrefix $node(node:prefix):
} else {
set nsPrefix {}
}
}
1,0 {
# XML Namespace is in scope, no prefix
set nsPrefix [GetNamespacePrefix $token
$node(node:namespaceURI)]:
if {![string compare $nsPrefix :]} {
set nsPrefix {}
}
}
0,0 -
default {
# No XML Namespace is in scope
set nsPrefix {}
}
}
append result <$nsPrefix$node(node:nodeName)
append result [Serialize:attributeList [array get
$node(element:attributeList)]]
if {![llength [set $node(node:childNodes)]]} {
append result />$newline
} else {
append result >$newline
# Do the children
if {[hasmixedcontent $token]} {
set opts(-indent) no
}
append result [eval Serialize:node [list $token] [array get opts]]
append result [eval Serialize:Indent [array get opts]]
append result "</$nsPrefix$node(node:nodeName)>$newline"
}
return $result
}
|