tag
XML data types > XML data classes
Prev:xml-chunk
Next:name


Vocabulary
xml.data

Class description
Tuple representing an XML tag, delegating to a name, containing the slots attrs (an alist of names to strings) and children (a sequence). Tags implement the sequence protocol by acting like a sequence of its chidren, and the assoc protocol by acting like its attributes.

See also
<tag>, name, contained-tag, xml

Definition
USING: sequences ;

IN: xml.data

TUPLE: tag
{ name name initial: T{ name } }
{ attrs attrs initial: T{ attrs } }
{ children sequence initial: f } ;


Methods
USING: xml.data xml.syntax.inverse ;

M: tag >xml ;


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: kernel xml.data ;

M: tag clone tag clone-slots ;


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
<tag>
] if ;


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 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 ;