This procedure is defined in the server but not documented via ad_proc or proc_doc and may be intended as a private interface.
The procedure is defined as:
proc dom::document {method token args} {
variable documentOptionsRO
variable documentOptionsRW
# GetHandle also checks token
GetHandle document $token node
set result {}
switch -- $method {
cget {
if {[llength $args] != 1} {
return -code error "too many arguments"
}
if {[regexp [format {^-(%s)$} $documentOptionsRO] [lindex $args 0] discard option]} {
return $node(document:$option)
} elseif {[regexp [format {^-(%s)$} $documentOptionsRW] [lindex $args 0] discard option]} {
return $node(document:$option)
} else {
return -code error "unknown option \"[lindex $args 0]\""
}
}
configure {
if {[llength $args] == 1} {
return [document cget $token [lindex $args 0]]
} elseif {[llength $args] % 2} {
return -code error "no value specified for option \"[lindex $args end]\""
} else {
foreach {option value} $args {
if {[regexp [format {^-(%s)$} $documentOptionsRW] $option discard opt]} {
set node(document:$opt) $value
} elseif {[regexp [format {^-(%s)$} $documentOptionsRO] $option discard opt]} {
return -code error "attribute \"$option\" is read-only"
} else {
return -code error "unknown option \"$option\""
}
}
}
PutHandle $token node
}
createElement {
if {[llength $args] != 1} {
return -code error "wrong number of arguments"
}
# Check that the element name is kosher
# BUG: The definition of 'Letter' here as ASCII letters
# is not sufficient. Also, CombiningChar and Extenders
# must be added.
if {![regexp {^[A-Za-z_:][-A-Za-z0-9._:]*$} [lindex $args 0]]} {
return -code error "invalid element name \"[lindex $args 0]\""
}
# Invoke internal factory function
set result [CreateElement $token [lindex $args 0] {}]
}
createDocumentFragment {
if {[llength $args]} {
return -code error "wrong number of arguments"
}
set result [CreateGeneric $token node:nodeType documentFragment]
}
createTextNode {
if {[llength $args] != 1} {
return -code error "wrong number of arguments"
}
set result [CreateTextNode $token [lindex $args 0]]
}
createComment {
if {[llength $args] != 1} {
return -code error "wrong number of arguments"
}
set result [CreateGeneric $token node:nodeType comment node:nodeValue [lindex $args 0]]
}
createCDATASection {
if {[llength $args] != 1} {
return -code error "wrong number of arguments"
}
set result [CreateGeneric $token node:nodeType CDATASection node:nodeValue [lindex $args 0]]
}
createProcessingInstruction {
if {[llength $args] != 2} {
return -code error "wrong number of arguments"
}
set result [CreateGeneric $token node:nodeType processingInstruction node:nodeName [lindex $args 0] node:nodeValue [lindex $args 1]]
}
createAttribute {
if {[llength $args] != 1} {
return -code error "wrong number of arguments"
}
set result [CreateGeneric $token node:nodeType attribute node:nodeName [lindex $args 0]]
}
createEntity {
set result [CreateGeneric $token node:nodeType entity]
}
createEntityReference {
set result [CreateGeneric $token node:nodeType entityReference]
}
createDocTypeDecl {
# This is not a standard DOM 1.0 method
if {[llength $args] < 1 || [llength $args] > 5} {
return -code error "wrong number of arguments"
}
lassign $args name extid dtd entities notations
set result [CreateDocType $token $name $extid $dtd $entities $notations]
}
getElementsByTagName {
if {[llength $args] != 1} {
return -code error "wrong number of arguments"
}
return [Element:GetByTagName $token [lindex $args 0]]
}
default {
return -code error "unknown method \"$method\""
}
}
return $result
}