This article describes how to tranform flatfiles to XML with the ServingXML pipeline language.
This article discusses processing of XML content in a ServingXML
pipeline.
The ServingXML framework allows streaming of a large volume
of XML content to be combined with non-streamed processing of parts of
that content.
The example below shows how to compare two XML documents for equality with
the XPATH fn:deep-equal function.
<sx:resources xmlns:sx="http://www.servingxml.com/core"
xmlns:fn="http://www.w3.org/2005/xpath-functions">
<sx:service id="test">
<sx:transform ref="test-documents-are-equal"/>
</sx:service>
<sx:document id="odd-element-document">
<document>
<title>Title</title>
<para>First paragraph.</para>
</document>
</sx:document>
<sx:document id="another-odd-element-document">
<document>
<title>Title</title>
<para>First paragraph.</para>
</document>
</sx:document>
<sx:transform id="test-documents-are-equal">
<sx:choose>
<sx:when test="fn:deep-equal(fn:document('odd-element-document'),
fn:document('another-odd-element-document'))">
<sx:document>
<result>equal</result>
</sx:document>
</sx:when>
<sx:otherwise>
<sx:document>
<result>unequal</result>
</sx:document>
</sx:otherwise>
</sx:choose>
<sx:assert test="text()='equal'"> Expected documents are equal.
</sx:assert>
</sx:transform>
</resources>
The documents are equal, so the script produces the result <result>equal</result>