tag - Factor Documentation (original) (raw)
Class description
Tuple representing an XML tag, delegating to a name, containing the following slots:
attrs | an alist of names to strings |
---|---|
children | a sequence |
Tags implement the Sequence protocol by acting like a sequence of its chidren, and the Associative mapping protocol for getting and setting their attributes.
See also
, contained-tag, , open-tag
Definition
TUPLE: tag
{ name name initial: T{ name } }
{ attrs attrs initial: T{ attrs } }
{ children sequence initial: f } ;
Methods
USING: accessors assocs kernel xml.data ;
M: tag >alist [ attrs>> ] call \ >alist execute ;
USING: xml.data xml.syntax.inverse ;
USING: accessors combinators inverse kernel xml.data
xml.syntax.inverse ;
M: tag [undo-xml]
{
[
name>> main>> [ [ name>> main>> ] ] dip
[ =/fail ] curry compose
]
[ attrs>> undo-attrs ]
[ children>> [undo-xml] [ [ children>> ] ] dip compose ]
} cleave [ tri ] 3curry ;
USING: accessors assocs kernel xml.data ;
M: tag assoc-clone-like
[ attrs>> ] call \ assoc-clone-like execute ;
USING: accessors assocs kernel xml.data ;
M: tag assoc-like [ attrs>> ] call \ assoc-like execute ;
USING: accessors assocs kernel xml.data ;
M: tag assoc-size [ attrs>> ] call \ assoc-size execute ;
USING: accessors assocs kernel xml.data ;
M: tag at* [ attrs>> ] call \ at* execute ;
USING: accessors assocs kernel xml.data ;
M: tag clear-assoc [ attrs>> ] call \ clear-assoc execute ;
M: tag clone tag clone-slots ;
USING: accessors assocs kernel xml.data ;
M: tag delete-at [ attrs>> ] call \ delete-at execute ;
USING: xml.data xml.syntax.private ;
M: tag interpolate-item interpolate-tag ;
USING: accessors kernel sequences xml.data ;
M: tag length [ children>> ] call \ length execute ;
USING: accessors kernel sequences xml.data ;
M: tag lengthen [ children>> ] call \ lengthen execute ;
USING: accessors kernel sequences xml.data ;
M: tag like
over tag?
[ drop ]
[ [ name>> ] keep attrs>> rot dup [ V{ } like ] when ]
if ;
USING: accessors assocs kernel xml.data ;
M: tag new-assoc [ attrs>> ] call \ new-assoc execute ;
USING: accessors kernel sequences xml.data ;
M: tag new-resizable
[ children>> ] call \ new-resizable execute ;
USING: accessors kernel sequences xml.data ;
M: tag new-sequence [ children>> ] call \ new-sequence execute ;
USING: accessors kernel sequences xml.data ;
M: tag nth [ children>> ] call \ nth execute ;
USING: accessors kernel sequences.private xml.data ;
M: tag nth-unsafe [ children>> ] call \ nth-unsafe execute ;
USING: accessors assocs kernel xml.data ;
M: tag set-at [ attrs>> ] call \ set-at execute ;
USING: accessors kernel sequences xml.data ;
M: tag set-length [ children>> ] call \ set-length execute ;
USING: accessors kernel sequences xml.data ;
M: tag set-nth [ children>> ] call \ set-nth execute ;
USING: accessors kernel sequences.private xml.data ;
M: tag set-nth-unsafe
[ children>> ] call \ set-nth-unsafe execute ;