Creates a shallow copy of self.
d = Document.new "<a><b/><b/><c><d/></c></a>" new_a = d.root.clone puts new_a # => "<a/>"
Evaluates to the URI
for a prefix, or the empty string if no such namespace is declared for this element. Evaluates recursively for ancestors. Returns the default namespace, if there is one.
the prefix to search for. If not supplied, returns the default namespace if one exists
the namespace URI
as a String
, or nil if no such namespace exists. If the namespace is undefined, returns an empty string
doc = Document.new("<a xmlns='1' xmlns:y='2'><b/><c xmlns:z='3'/></a>") b = doc.elements['//b'] b.namespace # -> '1' b.namespace("y") # -> '2'
Writes out this element, and recursively, all children.
output an object which supports ‘<< string’; this is where the
document will be written.
An integer. If -1, no indenting will be used; otherwise, the indentation will be this number of spaces, and children will be indented an additional amount. Defaults to -1
If transitive is true and indent is >= 0, then the output will be pretty-printed in such a way that the added whitespace does not affect the parse tree of the document
This hack inserts a space before the /> on empty tags to address a limitation of Internet Explorer. Defaults to false
out = '' doc.write( out ) #-> doc is written to the string 'out' doc.write( $stdout ) #-> doc written to the console
Private helper class. Removes quotes from quoted strings
Write out a fully formed, correct entity definition (assuming the Entity
object itself is valid.)
An object implementing <<
to which the entity will be output
DEPRECATED and ignored
FIXME This probably won’t work properly
Ignored. There must be no whitespace before an XML
declaration
Ignored
Ignored
Reorders an array of nodes so that they are in document order It tries to do this efficiently.
FIXME: I need to get rid of this, but the issue is that most of the XPath
interpreter functions as a filter, which means that we lose context going in and out of function calls. If I knew what the index of the nodes was, I wouldn’t have to do this. Maybe add a document IDX for each node? Problems with mutable documents. Or, rewrite everything.