Text (Character Data)


Text ”or, more properly, character data ”is all the document content other than markup. (Markup is the XML codes: tags, comments, declarations, and so on.) The intent of the XML standard is that the significant content of the document is contained in the character data while the structure of the document is encoded in the markup. This intent is generally followed.

All character data is found within an XML element and forms the content of that element:

XML
 <ELEMENT>Some text.</ELEMENT> 

Elements are often found within text blocks. In this case, the outer element contains both character data and a child element:

XML
 <ELEMENT>Some text.<CHILD/>More text</ELEMENT> 

The embedded element breaks the character data into two distinct objects that applications can treat separately. When we study the Document Object Model, we will find these two blocks of text in separate nodes. There would then be three children of this element ”two text nodes and one child element.

Of course, the child element might also have its own character data, which is not directly part of the outer element:

XML
 <ELEMENT>Some text.<CHILD>Child's private text</CHILD>More text   </ELEMENT> 

Flash Context

Within ActionScript, each block of character data appears as an individual node. In the object model, these text nodes are as significant as element nodes. They are differentiated by NodeType and they must always be leaf nodes. Text that is interrupted by an element (as in the previous line of code) appears in memory as two separate text nodes plus the interrupting element (e.g., <CHILD> ). This is especially problematic when the content contains even simple HTML markup. For example, it might include the common <u>underline</u> tag.

Syntax

Character data is any sequence of characters in the document's alphabet. The only disallowed characters are the two that introduce XML markup: the left angle bracket ( < ), which initiates all XML tags, and the ampersand ( & ), which initiates an entity. These two characters are inserted into character data with escape sequences.

Rules

Character data is composed of:

  • any character (including whitespace) except the < or & .

It may also include

  • escape sequences

  • other entity references

  • CDATA blocks

Examples of Character Data
<Team>Duluth Wildcats</Team> "Duluth Wildcats" is the content.
<EQ>2*2&lt;5</EQ> Content is "2*2 <5".
<weather>El Ni&#0241;o</weather> Content is "El Ni ±o".
Bad Examples
<longdistance>AT&T</longdistance> Forbidden character
<caption>The "<IMG>" tag</caption> Forbidden even within quotes


Flash and XML[c] A Developer[ap]s Guide
Flash and XML[c] A Developer[ap]s Guide
ISBN: 201729202
EAN: N/A
Year: 2005
Pages: 160

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net