The Tag concept is related to the HTMLPage concept, but not only. The
necesity for this concept appeared because of the lack of the Element
concept to represent incomplete elements. Wrapping the content of a HTML
page as elements would automaticaly create a DOM (Document Object
Model) structure, which is not always desirable because of the
computational overhead brought by this model.
example of how to create a Tag
$tag TYPEOF Tag
$tag@name = "a"
$tag.setAttributes("href=http://www.nolimits.ro,title=Our homepage".getTokens(","))
PRINT $tag.toXML<a href="http://www.nolimits.ro" title="Our homepage">
example of how to parse HTML content.
$html = "<a href=...>Our Homepage</a><br>"
$val = Tag.extractTagsWithText( $html )
EACH $elem IN $val DO [
IF $elem.getConceptType == "Tag" THEN [
PRINT "TAG: " + $elem@name] ELSE [
PRINT $elem.getConceptType + ": " + $elem]]
Tag : a
String : Our homepage
Tag : a
Tag - br
Methods inherited from: Concept
cloneConcept, extendsConcept, fromXML, getAllInheritedConcepts, getConceptAttribute, getConceptAttributeField, getConceptAttributeFields, getConceptAttributes, getConceptConstructors, getConceptElement, getConceptElementField, getConceptElementFields, getConceptElements, getConceptLabel, getConceptMethod, getConceptMethods, getConceptOperators, getConceptType, getErrorHandler, getInheritedConcepts, getResourceURI, hasConceptAttribute, hasConceptElement, hasConceptMethod, hasPath, isHidden, loadContent, setConceptLabel, setErrorHandler, setHidden, setShowEmpty, showEmpty, toTXT, toXML, setResourceURI |
|
Label: | isClosing |
Type: | Logical |
Is Static: | false |
Is Hidden: | false |
Show Empty: | true |
Can be TRUE or FALSE (default is TRUE) depending if the tag is close tag
or not. As example a <a href="..."> tag would have the isClosing
attribute showing FALSE and the </a> tag would have the isClosing
attribute as TRUE. This influence the default XML rendering of the tag.
Also if a tag is a closing tag it's attributes (if it has any) will be
discarded at rendering.
Label: | name |
Type: | String |
Is Static: | false |
Is Hidden: | false |
Show Empty: | true |
Contains a String representing the name of the Tag. For instance the<a href="..."> tag would render a name element of value "a". The
HTML comments will produce a name of "!--".
Constructs an empty Tag concept.
Parameters: |
$extractFrom : | A String concept from which the tags will be extracted. |
|
Method which will produce a Series of tags resulted from the parsing of
the parameter string or stream. In case there is text data in the stream
it will be rendered as String concepts in the resulted Series.
$xml = "<person>" +\
"<name>" +\
"<firstname>Csaba</firstname>" +\
"<lastname>Szabo</lastname>" +\
"</name>" +\
"</person>"
$tags = Tag.extractTags( $xml )
EACH $tag IN $tags DO [
print $tag
]
-- the result is --
<person>
<name>
<firstname>
</firstname>
<lastname>
</lastname>
</name>
</person>
Parameters: |
$extractFrom : | A String concept from which the tags will be extracted. |
|
Method which will produce a Series of tags with text resulted from the
parsing of the parameter string or stream. In case there is text data in
the stream it will be rendered as String concepts in the resulted
Series.
$xml = "<person>" +\
"<name>" +\
"<firstname>Csaba</firstname>" +\
"<lastname>Szabo</lastname>" +\
"</name>" +\
"</person>"
$tags = Tag.extractTagsWithText( $xml )
EACH $tag IN $tags DO [
print $tag
]
-- the result is --
<person>
<name>
<firstname>
Csaba
</firstname>
<lastname>
Szabo
</lastname>
</name>
</person>
Returns a Series of Attributes related to this tag.
$xml = "<person><name first='Csaba' last='Szabo' /></person>"
$tags = Tag.extractTags( $xml )
print $tags/2.getAttributes
-- the result is --
first: Csaba last: Szabo
Parameters: |
$extractFrom : | A String concept from which the tags will be extracted. |
$withLinks : | If true returns the links value. |
|
Returns a plain text rendering, without html tags, of the String given
as parameter.
$xml = "<person>" +\
"<name first='Csaba' last='Szabo' />" +\
"<address>Satu Mare</address>" +\
"</person>"
print Tag.getStrippedText( $xml, false )
-- the result is --
Satu Mare
Parameters: |
$attributes : | The attributes to be set. |
|
This method allows the addition of attributes to a Tag concept. The
attributes can be specified as a Map having the name of the attributes
as keys or as a Series containing Attribute concepts. The name and value
of the attributes must be of String type.
$tag TYPEOF Tag
$tag@name = "a"
$tag.setAttributes("href=http://www.nolimits.ro,title=Our homepage".getTokens(","))
PRINT $tag.toXML
-- the result is --
<a href="http://www.nolimits.ro" title="Our homepage">
Returns a stream representing the simple text rendering of this concept.
$tag TYPEOF Tag
$tag@name = "a"
$tag.setAttributes("href=http://www.nolimits.ro,title=Our homepage".getTokens(","))
PRINT $tag.toTXT
-- the result is --
<a href="http://www.nolimits.ro" title="Our homepage">
Returns a stream representing the XML rendering of this concept.
$tag TYPEOF Tag
$tag@name = "a"
$tag.setAttributes("href=http://www.nolimits.ro,title=Our homepage".getTokens(","))
PRINT $tag.toTXT
-- the result is --
<a href="http://www.nolimits.ro" title="Our homepage">