RAQL Extensions to <variable> for File Data Sources
The datafile attribute is available in the <variable> statement in EMML for use solely in RAQL queries. This attribute allows a mashup to directly populate the variable with the contents of the specified file, without registering the file as a MashZone NextGen mashable.
Files used as data sources must:
Contain data in a format supported by
MashZone NextGen Analytics. Currently this includes CSV (comma-separated-values) JSON, or XML. See
Supported Data Formats for
RAQL for details.
Note: Because the document in a variable populated from a file is not necessarily XML and may not have a DOM, these variables can generally only be used in <raql> statements. Other EMML statements cannot work with this data.
Be located in the classpath for the
MashZone NextGen Server. You can place data source files in
web-apps-home/mashzone/WEB-INF/classes or any folder outside of
MashZone NextGen that you choose to add to the classpath.
You specify the file name in
datafile as a literal or dynamic value. For an example of datasets loaded directly from a file using a literal name, see
A Basic
RAQL
Query.
You can also supply file names dynamically from input parameters or other variables. For example:
<mashup name="FileAsInput"
xmlns="http://www.openmashup.org/schemas/v1.0/EMML"
xmlns:macro="http://www.openmashup.org/schemas/v1.0/EMMLMacro"
xmlns:presto="http://www.jackbe.com/v1.0/EMMLPrestoExtensions"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openmashup.org/schemas/v1.0/EMML/../schemas/EMMLPrestoSpec.xsd">
<output name="result" type="document"/>
<input name="srcFile" type="string"/>
<variable datafile="$srcFile" name="srcData" stream="true"
type="document"/>
<raql outputvariable="result">
select * from srcData limit 25
</raql>
</mashup>