Any kind of XML Entity

Introduced properties

fun [](tag_name: String): Array[XMLTag]

dom :: XMLEntity :: []

The XMLTag children with the tag_name
fun children: Sequence[XMLEntity]

dom :: XMLEntity :: children

The children of self
protected fun children=(children: Sequence[XMLEntity])

dom :: XMLEntity :: children=

The children of self
init defaultinit(location: nullable Location)

dom :: XMLEntity :: defaultinit

fun location: nullable Location

dom :: XMLEntity :: location

Optional location of the entity in source
protected fun location=(location: nullable Location)

dom :: XMLEntity :: location=

Optional location of the entity in source
fun parent: nullable XMLEntity

dom :: XMLEntity :: parent

Optional parent of self
fun parent=(e: XMLEntity)

dom :: XMLEntity :: parent=

Sets the parent of self to e

Redefined properties

redef type SELF: XMLEntity

dom $ XMLEntity :: SELF

Type of this instance, automatically specialized in every class

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
fun [](tag_name: String): Array[XMLTag]

dom :: XMLEntity :: []

The XMLTag children with the tag_name
fun children: Sequence[XMLEntity]

dom :: XMLEntity :: children

The children of self
protected fun children=(children: Sequence[XMLEntity])

dom :: XMLEntity :: children=

The children of self
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
init defaultinit(location: nullable Location)

dom :: XMLEntity :: defaultinit

fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
fun location: nullable Location

dom :: XMLEntity :: location

Optional location of the entity in source
protected fun location=(location: nullable Location)

dom :: XMLEntity :: location=

Optional location of the entity in source
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun parent: nullable XMLEntity

dom :: XMLEntity :: parent

Optional parent of self
fun parent=(e: XMLEntity)

dom :: XMLEntity :: parent=

Sets the parent of self to e
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
package_diagram dom::XMLEntity XMLEntity core::Object Object dom::XMLEntity->core::Object dom::XMLDocument XMLDocument dom::XMLDocument->dom::XMLEntity dom::PCDATA PCDATA dom::PCDATA->dom::XMLEntity dom::CDATA CDATA dom::CDATA->dom::XMLEntity dom::XMLTag XMLTag dom::XMLTag->dom::XMLEntity dom::XMLAttribute XMLAttribute dom::XMLAttribute->dom::XMLEntity dom::XMLError XMLError dom::XMLError->dom::XMLEntity dom::XMLAttrTag XMLAttrTag dom::XMLAttrTag->dom::XMLTag dom::XMLProcessingInstructionTag XMLProcessingInstructionTag dom::XMLProcessingInstructionTag->dom::XMLTag dom::XMLEndTag XMLEndTag dom::XMLEndTag->dom::XMLTag dom::XMLCommentTag XMLCommentTag dom::XMLCommentTag->dom::XMLTag dom::XMLDoctypeTag XMLDoctypeTag dom::XMLDoctypeTag->dom::XMLTag dom::XMLSpecialTag XMLSpecialTag dom::XMLSpecialTag->dom::XMLTag dom::XMLAttrTag... ... dom::XMLAttrTag...->dom::XMLAttrTag dom::XMLProcessingInstructionTag... ... dom::XMLProcessingInstructionTag...->dom::XMLProcessingInstructionTag dom::XMLEndTag... ... dom::XMLEndTag...->dom::XMLEndTag dom::XMLCommentTag... ... dom::XMLCommentTag...->dom::XMLCommentTag dom::XMLDoctypeTag... ... dom::XMLDoctypeTag...->dom::XMLDoctypeTag dom::XMLSpecialTag... ... dom::XMLSpecialTag...->dom::XMLSpecialTag dom::XMLStringAttr XMLStringAttr dom::XMLStringAttr->dom::XMLAttribute dom::BadXMLAttribute BadXMLAttribute dom::BadXMLAttribute->dom::XMLAttribute dom::XMLStringAttr... ... dom::XMLStringAttr...->dom::XMLStringAttr dom::BadXMLAttribute... ... dom::BadXMLAttribute...->dom::BadXMLAttribute

Parents

interface Object

core :: Object

The root of the class hierarchy.

Children

class CDATA

dom :: CDATA

CDATA are regions in which no xml entity is parsed, all is ignored
class PCDATA

dom :: PCDATA

PCDATA is any kind of non-xml formatted text
abstract class XMLAttribute

dom :: XMLAttribute

Attributes are contained in tags, they provide meta-information on a tag
class XMLDocument

dom :: XMLDocument

Top XML Document-Object Model element
class XMLError

dom :: XMLError

Any XML Error that happens when parsing
abstract class XMLTag

dom :: XMLTag

A Tag is a node in a DOM tree

Descendants

class BadXMLAttribute

dom :: BadXMLAttribute

Badly formed XML attribute
abstract class XMLAttrTag

dom :: XMLAttrTag

Any kind of XML tag with attributes
class XMLCommentTag

dom :: XMLCommentTag

An XML comment tag
class XMLDoctypeTag

dom :: XMLDoctypeTag

A DOCTYPE Tag
class XMLEndTag

dom :: XMLEndTag

An end Tag (starting with </)
class XMLOnelinerTag

dom :: XMLOnelinerTag

One-liner XML Tag (Ends with />)
class XMLProcessingInstructionTag

dom :: XMLProcessingInstructionTag

Processing instructions start with <? and are to be read by a third-party application
class XMLPrologTag

dom :: XMLPrologTag

Any prolog style-Tag (starting with <?xml)
class XMLSpecialTag

dom :: XMLSpecialTag

A Special Tag (starts with !)
class XMLStartTag

dom :: XMLStartTag

A (potentially) multi-line spanning XML Tag start
class XMLStringAttr

dom :: XMLStringAttr

An attribute with a String value

Class definitions

dom $ XMLEntity
# Any kind of XML Entity
abstract class XMLEntity
	# Optional parent of `self`
	var parent: nullable XMLEntity = null is private writable(set_parent)

	# Optional location of the entity in source
	var location: nullable Location

	# The children of `self`
	var children: Sequence[XMLEntity] = new XMLEntities(self)

	# Sets the parent of `self` to `e`
	fun parent=(e: XMLEntity) do
		var parent = self.parent
		if parent != null then
			parent.children.remove(self)
		end
		e.children.add(self)
	end
end
lib/dom/xml_entities.nit:36,1--55,3

dom :: dom $ XMLEntity
redef class XMLEntity

	# The `XMLTag` children with the `tag_name`
	#
	# ~~~
	# var code = """
	# <?xml version="1.0" encoding="us-ascii"?>
	# <animal>
	#     <cat/>
	#     <tiger>This is a white tiger!</tiger>
	#     <cat/>
	# </animal>"""
	#
	# var xml = code.to_xml
	# assert xml["animal"].length == 1
	# assert xml["animal"].first["cat"].length == 2
	# ~~~
	fun [](tag_name: String): Array[XMLTag]
	do
		var res = new Array[XMLTag]
		for child in children do
			if child isa XMLTag and child.tag_name == tag_name then
				res.add child
			end
		end
		return res
	end
end
lib/dom/dom.nit:16,1--43,3