eXcavator
An XML Query Facility for XML_PullParser
version 1.0.6
Myron Turner
Appendix 3: Formatted Output Syntax

Contents         


Synopsis of Formatting Syntax
All examples use the sample XML document in Appendix 1

Direct Addressing
Syntax Example and Description
{ element } { color }
{ element___n } { city___3 }
Duplicate element names are numbered; numbering begins at 1 with the second duplicate element name and includes all subsequent elements of the same name in the current result. The number suffix consists of three underscores followed by the number of the element.
{ element;attribute } { vehicle;make }
Element Name is attached to attribute by semi-colon.
{ element___n;attribute } No example available

Indirect Addressing
{ context=>element[n] } { owner => city[1] }
Duplicate elements are indexed relative to context , which is an element that descends from the context-element. The index numbers start at 1.
{ context=>element } { owner => zip }
The index is not required for the first duplicate. owner => zip and owner => zip[1] are equivalent.
{ context=>element[n];attr } { owner => first_name[1];middle_init }
{ context=>element;attr } { owner => first_name;middle_init }
{ context___n=>element }
{ context___n=>element[n_2] }
{ name___2 => first_name }
{ name___2 => first_name[1] }
Also, with attributes:
    { name___2 => first_name[1];middle_init }
{ context[n]=>element }
{ context[n]=>element[n_2] }
{ name[3] => first_name }
{ name[3] => first_name[1] }
Also, with attributes:
    { name[3] => first_name[1];middle_init }


Template Pattern
optional-text {selector} optional-text {selector} . . .
$pattern = ' Street: { owner=>street }, City: { owner=>city[1] }, { owner=>city[2] } { owner=>zip } '


Calls to eXcavator_getFormattedText
$eXc->eXcavator_getFormattedText($n, 'owner', $pattern);
$eXc->eXcavator_getFormattedText($n, 'name[3]', $pattern);
$eXc->eXcavator_getFormattedText($n, 'name___2', $pattern);