SEM Labs

Handcrafted Pixels, Code & Title Tags

Data Document

XFL

Arrays passed to the XFL parser are transformed into a XML documents called a data document.

The conversion turns array keys (with the exception of integers) into XML elements names. For example, the key 'name' will become <name />. All integer keys are transformed into {}xfl-item elements and the numeric key is created as a key attribute, e.g. <xfl-item key="1" />.

d

xfl-item elements allow values in arrays to be iterated with more ease. XML elements are also required to start with a letter or one of a number of punctuation characters to be well-formed.

Array values are created as CDATA sections, which means that their content is ignored by the parser. A converted node would look like:

The value of the above element is 'Tony', not ''.

Dimensions are preserved in arrays by nesting.

The purpose of the data document is to provide a way in which the HTML form can be manipulated using XPath queries. It provides much more powerful capabilities than using arrays.

Single Dimension Example

Source Array:

[name] = 'Tony'
[age] = 20
[location] = 'Winnersh'
[award] = 'Blind Man's Bluff Word Champion 2008'

Multi-dimensional Example

Source Array:

[name] = 'Tony'
[skills][0] = 'Juggling'
[skills][1] = 'Dancing'
[skills][2] = 'Chasing Tornadoes'

Source Array: