domDoc(n) domDoc(n)
NAME
domDoc - Manipulates an instance of a DOM document object
SYNOPSIS
domDocObjCmd method ?arg arg ...?
DESCRIPTION
This command manipulates one particular instance of a document object.
method indicates a specific method of the document class. These methods
should closely conform to the W3C recommendation "Document Object Model
(Core) Level 1" (http:/www.w3.org/TR/REC-DOM-Level-1/level-one-
core.html). Look at these documents for a deeper understanding of the
functionality.
The valid methods are:
documentElement ??objVar??
Returns the top most element in the document (the root element).
getElementsByTagName name
Returns a list of all elements in the document matching (glob
style) name.
getElementsByTagNameNS uri localname
Returns a list of all elements in the subtree matching (glob
style) localname and having the given namespace uri.
createElement tagName ??objVar??
Creates (allocates) a new element node with node name tagName,
append it to the hidden fragment list in the document object and
returns the node object. If objVar is given the new node object
store in this variable.
createElementNS url tagName ??objVar??
Creates (allocates) a new element node within a namespace having
uri as the URI and node name tagName, which could include the
namespace prefix, append it to the hidden fragment list in the
document object and returns the node object. If objVar is given
the new node object store in this variable.
createTextNode text ??objVar??
Creates (allocates) a new text node with node value text,
appends it to the hidden fragment list in the document object
and returns the node object. If objVar is given, the new node
object is stored in this variable.
createComment text ??objVar??
Creates (allocates) a new comment node with value text, appends
it to the hidden fragment list in the document object and
returns the node object. If objVar is given, the new comment
node object is stored in this variable.
createCDATASection data ??objVar??
Creates (allocates) a new CDATA node with node value data,
appends it to the hidden fragment list in the document object
and returns the node object. If objVar is given, the new node
object is stored in this variable.
createProcessingInstruction target data ??objVar??
Creates a process instruction, appends it to the hidden fragment
list in the document object and returns the node object. If
objVar is given, the new node object is stored in this variable.
delete Explicitly deletes the document, including the associated Tcl
object commands (for nodes, fragment/new nodes, the document
object itself) and the underlying DOM tree.
getDefaultOutputethod
Returns the default output method of the document. This is usu-
ally a result of a XSLT transformation.
asXML ??-indent none/1..8?? ??-channel channelId?? ??-escapeNonASCI?? -doc-
typeDeclaration <>
Returns the DOM tree as an (optional indented) XML string or
sends the output directly to the given channelId. If the option
-escapeNonASCI is given, every non 7 bit ASCI character in
attribute values or element PCDATA content will be escaped as
character reference in decimal representation. The flag -doc-
typeDeclaration determines, whether there will be a DOCTYPE dec-
laration emitted before the first node of the document. The
default is, to do not. The DOCTYPE name will always be the ele-
ment name of the document element. An external entity declara-
tion of the external subset is only emitted, if the document has
a system identifier.
asHTML ??-channel channelId?? ??-escapeNonASCI?? ??-htmlEntities?? -doctype-
Declaration <>
Returns the DOM tree serialized acording to HTML rules (HTML
elements are recognized regardless of case, without end tags for
emtpy HTML elements etc.), as string or sends the output
directly to the given channelId. If the option -escapeNonASCI
is given, every non 7 bit ASCI character in attribute values or
element PCDATA content will be escaped as character reference in
decimal representation. If the option -htmlEntities is given, a
character is outputed using a HTML 4.01 character entity refer-
ence, if one is defined for it. The flag -doctypeDeclaration
determines, whether there will be a DOCTYPE declaration emitted
before the first node of the document. The default is, to do
not. The DOCTYPE name will always be the element name of the
document element without case normalization. An external entity
declaration of the external subset is only emitted, if the docu-
ment has a system identifier. The doctype declaration will be
written from the avaliable informations, without check, if this
is a known (w3c) HTML version information or if the document
confirms to the given HTML version.
asText The asText method outputs the result tree by outputting the
string-value of every text node in the result tree in document
order without any escaping. In effect, this is what the xslt
output method "text" (XSLT 1.0 recommendation, section 16.3)
does.
publicId ?publicId?
Returns the public identifier of the doctype declaration of the
document, if there is one, otherwise the empty string. If there
is a value given to the method, the public identifier of the
document is set to this value.
systemId ?systemId?
Returns the system identifier of the doctype declaration of the
document, if there is one, otherwise the empty string. If there
is a value given to the method, the system identifier of the
document is set to this value.
xslt ??-parameters parameterList?? ??-ignoreUndeclaredParameters??
??-xsltmessagecmd script?? stylesheet ?outputVar?
Applies an XSLT transformation on the whole document of the node
object using the XSLT stylesheet (given as domDoc). Returns a
document object containing the result document of the transfor-
mation and stores that document object in the optional output-
Var, if that was given.
The optional -parameters option sets top level to
string values. The parameterList has to be a tcl list consisting
of parameter name and value pairs.
If the option -ignoreUndeclaredParameters is given, then parame-
ter names in the parameterList given to the -parameters options
that are not declared as top-level parameters in the stylesheet
are silently ignored. Without this option, an error is raised,
if the user tries to set a top-level parameter, which is not
declared in the stylesheet.
The -xsltmessagecmd option sets a callback for xslt:message ele-
ments in the stylesheet. The actual command consists of the
script, given as argument to the option, appended with the XML
Fragment from instantiating the xsl:message element content as
string (as if the XPath string() function would have been
applied to the XML Fragment) and a flag, which indicates, if the
xsl:message has an attribute "terminate" with the value "yes".
toXSLTcmd ??objVar??
If the DOM tree represents a valid XSLT stylesheet, this method
transforms the DOM tree into a xslt command, otherwise it
returns error. The created xsltCmd is returnd and stored in the
objVar, if a var name was given. A successful transformation of
the DOM tree to a xsltCmd removes the domDoc cmd and all
nodeCmds of the document.
The syntax of the created xsltCmd is:
xsltCmd ??-parameters parameterList?? ??-ignoreUndeclaredParameters?? ??-xsltmessagecmd script?? docNode ?outputVar?
The options are the same as for the domDoc xslt method; see
there for a description. The docNode argument is the XML docu-
ment to transform (given as domDoc). The command returns a docu-
ment object containing the result document of the transformation
and stores it in the optional outputVar, if that was given.
normalize ?-forXPath?
Puts all Text nodes in the document into a "normal" form where
only structure (e.g., elements, comments, processing instruc-
tions and CDATA sections) separates Text nodes, i.e., there are
neither adjacent Text nodes nor empty Text nodes. If the option
-forXPath is given, all CDATA sections in the nodes are con-
verted to text nodes, as a first step before the normalization.
Otherwise, if an unknown method name is given, the command with the
same name as the given metho within the namespace ::::dom::::domDoc is
tried to be executed. This allows quick method additions on Tcl level.
Newly created nodes are appended to a hidden fragment list. If there
are not moved into the tree they are automaticaly deleted, when the
whole document gets deleted.
SEE ALSO
dom, domNode
KEYWORDS
DOM node creation, document element
Tcl domDoc(n)
|