import

Back
Download exampleRun example
  • import [source],[xpath],[importashtml],[cache],[cachestorage],[clearcache]
    • check ($doc,$el)
    • eachnode ($el)
    • filter ($doc,$el)
    • runfirst ($doc,$el)

Imports a local (or remote) xml (or html) resource and builds an awsXML (or awsHTML) object with it; The nodes specified by the xpath attribute will replace the import directive within the client side of the application;

To parse remote files "allow_url_fopen" needs to be set to On in php.ini

Context: anywhere in //app/client

Remarks:
- the source document has to be valid (no missing tags)
- source attribute is optional; in case it does not exists the application's document itself is used;
- xpath attribute is mandatory
- import/runfirst is the first function to be executed, and is mainly used to change the attributes of import directive (xpath, source, importashtml,cache,...). If present, the document processor will create a lambda function from first processing instruction child of the runfirst node and execute it with $el parameter as the DOMNode of parent import directive
- if import/eachnode is present, the document processor will create a lambda function from first processing instruction child of the "eachnode" node and execute it with $el parameter as the DOMNode of each new node that is to be imported; if this function returns TRUE, the current node is imported, if returns FALSE or does not return anything the node is not imported; if returns a text value, this will be used to create a documentFragment to be used instead of the current node
- if import/check is given, the document processor will create a lambda function from first processing instruction child of the check node and import the new element or not, depending on the result of the function (function needs to return a value);
- if import/filter is given, the document processor will create a lambda function from the first processing instruction child of the filter node and this function will be called with $doc parameter, awsXML (or awsHTML) instance on the local/remote file;
CACHING:

This basic cache system will store the remote resource only, for increased performance. To enable it you must set directive's cache attribute to "enable".

Other attributes to set:
- cachestorage - you must specify the name of the file (mandatory);
- clearcache number of seconds to wait before update the data source; if set to "FALSE" will store the data source content and never update it later; if set to "0" (zero) will update the data source each time directive is executed;
Setting up import parameters; source can be either local or remote file;
Filter callback
Check callback