Rel2xml
Converts relational data to its XML equivalent.
Usage
rel2xml (indata, attr : outdata)
Details
A relation indata is converted to an XML document and this
document is joined back to the input to form outdata (i.e.,
a dependent join). The attr specifies the "grouping attribute"
by which all attributes that follow (in the order of the attribute
list) are represented at an equal level beneath the grouping attribute.
Multiple grouping attributes can be specified by using a comma
delimited expression (see example).
Notes
- An OBJECT element wraps the entire XML document that results.
- A ROW element wraps the last grouping attribute.
Known Bugs
Example
Using the input:
RELATION books: title char, author char, pub_date date, pages number
Title1|Author1|09-01-1991|34
Title2|Author2|12-23-1954|479
Title3|Author2|05-09-2002|733
Title4|Author3|01-01-1968|32
Title5|Author2|07-03-2001|1152
when executing the plan:
PLAN test
{
INPUT: stream books
OUTPUT: stream result
BODY
{
rel2xml (books, "author, title", "xmldoc" : result)
}
}
generates the following output:
----------------------------------------------
RELATION: urel2xml1_result
attrs: xmldoc
----------------------------------------------
<OBJECT>
<author>Author1
<title>Title1
<ROW>
<pub_date>09-01-1991</pub_date>
<pages>34</pages>
</ROW>
</title>
</author>
<author>Author3
<title>Title4
<ROW>
<pub_date>01-01-1968</pub_date>
<pages>32</pages>
</ROW>
</title>
</author>
<author>Author2
<title>Title5
<ROW>
<pub_date>07-03-2001</pub_date>
<pages>1152</pages>
</ROW>
</title>
<title>Title3
<ROW>
<pub_date>05-09-2002</pub_date>
<pages>733</pages>
</ROW>
</title>
<title>Title2
<ROW>
<pub_date>12-23-1954</pub_date>
<pages>479</pages>
</ROW>
</title>
</author>
</OBJECT>
----------------------------------------------