|
Class: Element (in XML)
Object
|
+--XML::Node
|
+--XML::Element
- Package:
- stx:goodies/xml/vw
- Category:
- XML-VW-Nodes
- Version:
- rev:
1.78
date: 2023/10/18 17:03:54
- user: stefan
- file: Element.st directory: goodies/xml/vw
- module: stx stc-classLibrary: vw
XML document element boundaries are either delimited by start-tags and end-tags, or, for empty elements, by an empty-element tag. Each element has a type, identified by name, sometimes called its "generic identifier" (GI), and may have a set of attribute specifications. Each attribute specification has a name and a value.
Instance Variables:
tag <String | NodeTag> the identifier for the element
attributes <Collection> the element's attributes
namespaces <Dictionary> a mapping of tag qualifiers to namespace URIs
elements <SequenceableCollection> child text, comments, PIs and elements
userData <Object> extra space for a client program to add annotations
definition <XML.Pattern> defines the type constraints for the content
instance creation
-
new
-
(comment from inherited method)
return an instance of myself without indexed variables
-
tag: tag
-
Modified (format): / 18-07-2018 / 11:53:15 / Claus Gittinger
-
tag: tag attributes: attributes
-
-
tag: tag attributes: attributes elements: elements
-
Modified (format): / 18-07-2018 / 11:53:10 / Claus Gittinger
-
tag: tag elements: elements
-
Modified (format): / 18-07-2018 / 11:53:02 / Claus Gittinger
accessing
-
anyElementNamed: elementName
-
Answer the one and only element named elementName.
Raise an error, if there is not exactly one element.
This will return the receiver if its name matches the requirement.
-
anyElementsNamed: elementName
-
Traverse the tree and return all the elements named elementName
-
attributes
-
Modified (format): / 21-04-2021 / 12:40:38 / cg
-
characterData
-
return all concatenated character data
-
characterDataDo: aBlock
-
recursively apply aBlock for every characterdata piece
-
characterDataOnto: str
-
-
childNodes
-
##add -umejava
-
definition
-
-
definition: aPattern
-
-
description
-
-
elementNamed: elementName
-
-
elementNamed: elementName ifAbsent: exceptionValue
-
-
elements
-
(comment from inherited method)
Visualworks uses the method #children to do essentially the same as this. Does not do much though
-
elementsNamed: elementName
-
-
elementsWithTextDo: aBlock
-
return all text elements
-
elementsWithTexts
-
return all text elements
-
elementsWithoutTexts
-
return a collection of all non-text elements
-
elementsWithoutTextsDo: aBlock
-
evaluate a block for all non-text elements
-
expandedName
-
-
hasElementNamed: elementName
-
-
hasElementsWithoutText
-
answer true, if there is a subelement, which is not text
-
indexOf: aChild
-
-
localName
-
for compatibility with YAXO nodes
-
namespaces: aDictionary
-
-
selectNodes: aBlock
-
-
tag
-
-
tagName
-
-
valueOfAttribute: attributeName ifAbsent: aBlock
-
accessing - xpath like
-
/ anElementName
-
XPath like processing - answer all the elements named anElementName
(direct children; corresponds to ./anElementName in XPath)
Usage example(s):
Modified (comment): / 08-12-2020 / 12:45:58 / cg
|
-
// anElementName
-
XPath like processing - traverse the tree and answer all the elements named anElementName
(recursive; corresponds to .//anElementName in XPath)
-
/@ anAttributeName
-
XPath like processing - answer a nodeSet with attributes named anAttributeName
-
@ anAttributeName
-
XPath like processing - answer the attribute named anAttributeName
-
addAllAttributesNamed: attributeName to: aCollection
-
Recursively (depth-first) traverse the element tree and add any
sub-elements atributes named attributeName to aCollection
-
addAllElementsNamed: elementName to: aCollection
-
Recursively (depth-first) traverse the element tree and add any
sub-element named elementName to aCollection
-
addAttributesNamed: anAttributeName to: aCollection
-
XPath like processing - add attributes named anAttributeName to aCollection
-
addElementsNamed: elementName to: aCollection
-
Traverse the tree and add the direct child elements named elementName to aCollection
-
allAttributesNamed: attributeName do: aBlock
-
Recursively (depth-first) traverse the element tree and evaluate aBlock for each
-
allElementsNamed: elementName do: aBlock
-
Recursively (depth-first) traverse the element tree and evaluates aBlock for each
-
attributesNamed: anAttributeName do: aBlock
-
XPath like processing - evaluate aBlock for all attributes named anAttributeName
comparing
-
= anXmlElement
-
(comment from inherited method)
return true if the receiver and the arg have the same structure.
Notice:
This method is partially open coded (inlined) by the compiler(s)
identical objects are always considered equal.
redefining it may not work as expected.
-
hash
-
(comment from inherited method)
return an Integer useful as a hash key for the receiver.
This hash should return same values for objects with same
contents (i.e. use this to hash on structure)
copying
-
cloneTree
-
answer a copy of the tree, so that removal of child elements
from the copy does not affect the original node.
enumerating
-
childElementsDo: aBlock
-
enumerate my direct child-elements and
evaluate aBlock for each.
-
elementsDo: aBlock
-
recursively (depth-first) descend into my child-elements and
evaluate aBlock for each sub-element.
Bad naming: should be called allElementsDo:
-
nodesDo: aBlock
-
Evaluate aBlock for myself and recursively (depth-first) descend into my child-nodes and
evaluate aBlock for each sub-node.
Enumerates both attributes and elements
-
nodesReverseDo: aBlock
-
-
saxDo: aDriver forBodyDo: aBlock
-
a variation on #saxDo: that lets the client
control how the body of the element is to be
printed.
initialization
-
initialize
-
modifying
-
addNode: aNode
-
the following might look ugly, but saves a lot of memory,
-
removeAllNodes
-
##add -umejava
-
removeNode: aNode
-
remove a child node; raises an error if the given argument is
not a child of the receiver
namespaces
-
namespaceAt: qualifier
-
-
qualifierAtNamespace: ns
-
printing
-
prettyPrintColorizedOn: aStream depth: indent
-
(comment from inherited method)
depth should be named indent
-
prettyPrintOn: aStream depth: indent
-
(comment from inherited method)
self subclassResponsibility
-
printAsOneLineOn: aStream
-
-
printCanonicalOn: aStream
-
reject: [:str | str isBlankText]
-
printHTMLOn: aStream
-
reject: [:str | str isBlankText]
-
printNoIndentOn: aStream endSpacing: endSpacingBlock spacing: spacingBlock
-
(comment from inherited method)
Print myself on the stream with line breaks between adjacent
elements, but no indentation.
-
simpleDescription
-
private
-
attributes: attrColl
-
-
condenseList
-
condense the elements list;
if it is empty, make it nil;
otherwise, make it an array
-
condenseText
-
concatenate text elements into the smallest number of elements.
Return the receiver
-
elements: e
-
-
setAttributes: aCollection
-
private entries to set the attributes without reparenting
-
setElements: aCollection
-
private entries to set the elements without condensing
-
setTag: t attributes: a elements: e
-
private helpers
-
treePositionOf: aNode
-
return a collection containing the position of aNode in the document
in the form #(i1 i2 ... iN} where each iI is the index within the siblings
testing
-
hasSubNodes
-
-
isContent
-
-
isElement
-
-
isEmpty
-
-
isHTMLBlock
-
-
isLike: aNode
-
-
notEmpty
-
-
verifyContents
-
visiting
-
acceptVisitor: aVisitor
-
Double dispatch back to the visitor, passing my type encoded in
the selector (visitor pattern)
|