core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
dom :: XMLEntity :: defaultinit
core :: Object :: defaultinit
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).dom :: XMLAttribute
Attributes are contained in tags, they provide meta-information on a tagdom :: XMLProcessingInstructionTag
Processing instructions start with <? and are to be read by a third-party application
# 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
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