deprecated/buildtools/buildsystemtools/lib/XML/DOM/DocumentFragment.pod
author lorewang
Thu, 11 Nov 2010 11:26:32 +0800
changeset 677 44e49837144a
parent 655 3f65fd25dfd4
permissions -rw-r--r--
update release info
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
655
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     1
=head1 NAME
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     2
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     3
XML::DOM::DocumentFragment - Facilitates cut & paste in XML::DOM documents
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     5
=head1 DESCRIPTION
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     6
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     7
XML::DOM::DocumentFragment extends L<XML::DOM::Node>
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     8
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     9
DocumentFragment is a "lightweight" or "minimal" Document object. It is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    10
very common to want to be able to extract a portion of a document's
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    11
tree or to create a new fragment of a document. Imagine implementing a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    12
user command like cut or rearranging a document by moving fragments
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    13
around. It is desirable to have an object which can hold such fragments
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    14
and it is quite natural to use a Node for this purpose. While it is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    15
true that a Document object could fulfil this role, a Document object
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    16
can potentially be a heavyweight object, depending on the underlying
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    17
implementation. What is really needed for this is a very lightweight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    18
object. DocumentFragment is such an object.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    19
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    20
Furthermore, various operations -- such as inserting nodes as children
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    21
of another Node -- may take DocumentFragment objects as arguments; this
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    22
results in all the child nodes of the DocumentFragment being moved to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    23
the child list of this node.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    24
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    25
The children of a DocumentFragment node are zero or more nodes
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    26
representing the tops of any sub-trees defining the structure of the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    27
document. DocumentFragment nodes do not need to be well-formed XML
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    28
documents (although they do need to follow the rules imposed upon
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    29
well-formed XML parsed entities, which can have multiple top nodes).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    30
For example, a DocumentFragment might have only one child and that
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    31
child node could be a Text node. Such a structure model represents
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    32
neither an HTML document nor a well-formed XML document.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    33
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    34
When a DocumentFragment is inserted into a Document (or indeed any
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    35
other Node that may take children) the children of the DocumentFragment
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    36
and not the DocumentFragment itself are inserted into the Node. This
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    37
makes the DocumentFragment very useful when the user wishes to create
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    38
nodes that are siblings; the DocumentFragment acts as the parent of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    39
these nodes so that the user can use the standard methods from the Node
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    40
interface, such as insertBefore() and appendChild().