<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-5304121007865177116</id><updated>2008-05-13T05:05:54.245-04:00</updated><title type='text'>XML Connections</title><link rel='alternate' type='text/html' href='http://www.xml-connection.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default?start-index=26&amp;max-results=25'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.xml-connection.com/atom.xml'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default'/><author><name>marc</name><uri>http://www.blogger.com/profile/05398140192633313588</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>49</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5304121007865177116.post-189886729357884806</id><published>2008-05-13T05:03:00.001-04:00</published><updated>2008-05-13T05:05:32.285-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='XQuery'/><title type='text'>XQuery Update Facility versus XSLT?</title><content type='html'>Last month we discussed &lt;a href="http://www.xml-connection.com/2008/04/transforming-xml-using-xquery-updates.html"&gt;Transforming XML using XQuery updates&lt;/a&gt;. With XQuery 1.0 update and transform operations are rather challenging to implement. Or you can use some library to get there, like we explained in &lt;a href="http://www.xml-connection.com/2007/11/updating-xml-with-xquery-10.html"&gt;Updating XML with XQuery 1.0&lt;/a&gt;. In any case, we have to admit, compared to XSLT this is a shortcoming.&lt;p/&gt;With the &lt;a href="http://www.w3.org/TR/2008/CR-xquery-update-10-20080314/"&gt;XQuery Update Facility&lt;/a&gt;, things will change drastically. Let's have a closer look at a concrete usage scenario from a &lt;a href="http://www.stylusstudio.com/ssdn/default.asp?action=9&amp;read=7645&amp;fid=48#24054"&gt;recent question&lt;/a&gt; on &lt;a href="http://www.stylusstudio.com/ssdn/default.asp"&gt;SSDN&lt;/a&gt;.&lt;p/&gt;&lt;i&gt;&lt;pre&gt;If preceding-sibling type="zMADDRESS", type="zZip" value&lt;br /&gt;should be left unchanged. Else if, preceding-sibling&lt;br /&gt;type="zADDRESS", type="zZip" items should be removed.&lt;br /&gt;And the comma and space which always seem to precede&lt;br /&gt;the zZip in ZAddress or zNeighb must also be removed--&lt;br /&gt;if that is all within a zADDRESS.&lt;br /&gt;For examples:&lt;br /&gt;1. Before:&lt;br /&gt;&amp;lt;tps:c type="zStreet"&gt;20 West Row&amp;lt;/tps:c&gt;&lt;br /&gt;&amp;lt;tps:c type="zAddress"&gt;,&amp;lt;/tps:c&gt;&lt;br /&gt;&amp;lt;tps:c type="zNeighb"&gt;Canberra City,&amp;lt;/tps:c&gt;&lt;br /&gt;&amp;lt;tps:c type="zZip"&gt;2600&amp;lt;/tps:c&gt;&lt;br /&gt;1. After:&lt;br /&gt;&amp;lt;tps:c type="zStreet"&gt;20 West Row&amp;lt;/tps:c&gt;&lt;br /&gt;&amp;lt;tps:c type="zAddress"&gt;,&amp;lt;/tps:c&gt;&lt;br /&gt;&amp;lt;tps:c type="zNeighb"&gt;Canberra City&amp;lt;/tps:c&gt;&lt;br /&gt;2. Before:&lt;br /&gt;&amp;lt;tps:c type="zStreet"&gt;82 Northbourne Ave.&amp;lt;/tps:c&gt;&lt;br /&gt;&amp;lt;tps:c type="zAddress"&gt;,&amp;lt;/tps:c&gt;&lt;br /&gt;&amp;lt;tps:c type="zNeighb"&gt;Braddon&amp;lt;/tps:c&gt;&lt;br /&gt;&amp;lt;tps:c type="zAddress"&gt;,&amp;lt;/tps:c&gt;&lt;br /&gt;&amp;lt;tps:c type="zZip"&gt;2601&amp;lt;/tps:c&gt;&lt;br /&gt;2. After:&lt;br /&gt;&amp;lt;tps:c type="zStreet"&gt;82 Northbourne Ave.&amp;lt;/tps:c&gt;&lt;br /&gt;&amp;lt;tps:c type="zAddress"&gt;,&amp;lt;/tps:c&gt;&lt;br /&gt;&amp;lt;tps:c type="zNeighb"&gt;Braddon&amp;lt;/tps:c&gt;&lt;br /&gt;3. Beofre:&lt;br /&gt;&amp;lt;tps:c type="zMaddress"&gt;Box 544, Burra Creek,&amp;lt;/tps:c&gt;&lt;br /&gt;&amp;lt;tps:c type="zCity"&gt;Queanbeyan,&amp;lt;/tps:c&gt;&lt;br /&gt;&amp;lt;tps:c type="zZip"&gt;2620&amp;lt;/tps:c&gt; &lt;br /&gt;3. After, no change because one its preceding-siblings is "zMaddress".&lt;/pre&gt;&lt;/i&gt;&lt;p/&gt;The proposed XSLT solution is as follows,&lt;p/&gt;&lt;i&gt;&lt;pre&gt;&amp;lt;?xml version='1.0'?&gt;&lt;br /&gt;&amp;lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&lt;br /&gt;xmlns:tps="http://www.typefi.com/ContentXML"&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;xsl:template match="/"&gt;&lt;br /&gt;&amp;lt;xsl:apply-templates/&gt;&lt;br /&gt;&amp;lt;/xsl:template&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;xsl:template match="*"&gt;&lt;br /&gt;&amp;lt;xsl:element name="{name()}"&gt;&lt;br /&gt;&amp;lt;xsl:for-each select="@*"&gt;&lt;br /&gt;&amp;lt;xsl:attribute name="{name()}"&gt;&amp;lt;xsl:value-of select="."/&gt;&amp;lt;/xsl:attribute&gt;&lt;br /&gt;&amp;lt;/xsl:for-each&gt;&lt;br /&gt;&amp;lt;xsl:apply-templates select="*|text()"/&gt;&lt;br /&gt;&amp;lt;/xsl:element&gt;&lt;br /&gt;&amp;lt;/xsl:template&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;xsl:template match="tps:c[@type='zZip']"&gt;&lt;br /&gt;&amp;lt;xsl:choose&gt;&lt;br /&gt;&amp;lt;xsl:when test="preceding-sibling::tps:c[@type='zAddress']"&gt;&lt;br /&gt;&amp;lt;!-- removed --&gt;&lt;br /&gt;&amp;lt;/xsl:when&gt;&lt;br /&gt;&amp;lt;xsl:otherwise&gt;&amp;lt;xsl:copy-of select="."/&gt;&amp;lt;/xsl:otherwise&gt;&lt;br /&gt;&amp;lt;/xsl:choose&gt;&lt;br /&gt;&amp;lt;/xsl:template&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;xsl:template match="tps:c[@type='zAddress']"&gt;&lt;br /&gt;&amp;lt;xsl:choose&gt;&lt;br /&gt;&amp;lt;xsl:when test="text() = ',' and following-sibling::tps:c[1][@type='zZip']"&gt;&lt;br /&gt;&amp;lt;!-- removed --&gt;&lt;br /&gt;&amp;lt;/xsl:when&gt;&lt;br /&gt;&amp;lt;xsl:otherwise&gt;&amp;lt;xsl:copy-of select="."/&gt;&amp;lt;/xsl:otherwise&gt;&lt;br /&gt;&amp;lt;/xsl:choose&gt;&lt;br /&gt;&amp;lt;/xsl:template&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/xsl:stylesheet&gt;&lt;/pre&gt;&lt;/i&gt;&lt;p/&gt;What would this look like using XQuery Update Facility?&lt;p/&gt;&lt;pre&gt;declare namespace tps = "http://www.typefi.com/ContentXML";&lt;br /&gt;&lt;br /&gt;copy $doc := .&lt;br /&gt;modify&lt;br /&gt;  (delete node $doc//tps:c[@type='zZip']&lt;br /&gt;                          [preceding-sibling::tps:c[@type='zAddress']],&lt;br /&gt;   delete node $doc//tps:c[@type='zAddress']&lt;br /&gt;                          [.=(","," ")]&lt;br /&gt;                          [following-sibling::tps:c[1][@type='zZip']])&lt;br /&gt;return $doc&lt;/pre&gt;&lt;p/&gt;I don't want to end up in one of those endless XQuery versus XSLT discussions. But beside the fact that XQuery Update Facility adds a nice palette of new functionality to XQuery, I believe it offers concise, well readable solutions. &lt;/p&gt;&lt;div class="techtags"&gt;Tech Tags: &lt;a href="http://technorati.com/tag/XQuery" rel="tag" class="techtag" title="http://technorati.com/tag/XQuery"&gt;XQuery&lt;/a&gt;&lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://www.xml-connection.com/2008/05/xquery-update-facility-versus-xslt.html' title='XQuery Update Facility versus XSLT?'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5304121007865177116&amp;postID=189886729357884806' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.xml-connection.com/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default/189886729357884806'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default/189886729357884806'/><author><name>marc</name><uri>http://www.blogger.com/profile/05398140192633313588</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-5304121007865177116.post-5616035587057941358</id><published>2008-04-30T16:43:00.000-04:00</published><updated>2008-04-30T16:44:47.312-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='example'/><category scheme='http://www.blogger.com/atom/ns#' term='XQuery'/><title type='text'>Transforming XML using XQuery updates</title><content type='html'>In one of my &lt;a href="http://www.xml-connection.com/2008/04/w3c-xml-query-working-group-published.html "&gt;previous posts&lt;/a&gt; I blogged about the new W3C XML Query publications, including &lt;a href="http://www.w3.org/TR/2008/CR-xquery-update-10-20080314/"&gt;XQuery Update Facility&lt;/a&gt;.&lt;p/&gt;Talking to people, I feel a majority relate XQuery Update Facility with updating XML documents in some persistent store. But there is actually more, it is also about transforming and enriching (transient) documents. In fact a use case hard to handle with &lt;a href="http://www.w3.org/TR/2007/REC-xquery-20070123/"&gt;XQuery 1.0&lt;/a&gt;.&lt;p/&gt;Note the XQuery Update Facility is today in W3C &lt;a href="http://www.w3.org/2004/02/Process-20040205/tr.html#RecsCR"&gt;Candidate Recommendation&lt;/a&gt; status. Although not yet supported by &lt;a href="http://www.xquery.com/"&gt;DataDirect XQuery&lt;/a&gt;, we are following the progression of the specification closely, and hope to communicate about our plans soon, when the specification moves into &lt;a href="http://www.w3.org/2004/02/Process-20040205/tr.html#RecsPR"&gt;Proposed Recommendation&lt;/a&gt; status.&lt;p/&gt;Anyway, I want to give a feel on what will be possible in the near future.&lt;p/&gt;Let’s consider a concrete example. Not so long ago I posted a series on &lt;a href="http://www.xml-connection.com/2007/12/xquery-generating-multiple-xml.html"&gt;XQuery generating multiple XML documents&lt;/a&gt;, let’s continue with this theme. Assume you have a directory with XML documents, and these need to be enriched with data coming out of your relational database. For example, orders need to be completed with the shipping address.&lt;p/&gt;Let’s enrich all our orders, each a seperate XML document. Using the customer’s name available in the order, we lookup the shipping address in our relational database and enrich subsequently the order with that shipping address.&lt;p/&gt;In the margin, we use the utility function &lt;code&gt;local:get-file-name&lt;/code&gt;, which we introduced &lt;a href="http://www.xml-connection.com/2007/12/xquery-generating-multiple-xml.html"&gt;before&lt;/a&gt;.&lt;p/&gt;&lt;pre&gt;for $order in fn:collection("file:///C:/inputorders?select=*.xml")&lt;br /&gt;let $filename := concat("file:///C:/outputorders/", &lt;br /&gt;                        local:get-file-name(document-uri($order)))&lt;br /&gt;let $newOrder :=&lt;br /&gt;  &amp;lt;order id="{$order/order/@id}"&gt;{&lt;br /&gt;    $order/order/customer,&lt;br /&gt;   &amp;lt;address&gt;{&lt;br /&gt;     fn:collection("CUSTOMERS")/CUSTOMERS[NAME = $order/order/customer]/ADDRESS/text()&lt;br /&gt;   }&amp;lt;/address&gt;,&lt;br /&gt;   $order/order/totalprice, &lt;br /&gt;   $order/order/priority,&lt;br /&gt;   $order/order/deliverydate,&lt;br /&gt;   $order/order/notes,&lt;br /&gt;   $order/order/lineitems&lt;br /&gt;  }&amp;lt;/order&gt;                   &lt;br /&gt;return&lt;br /&gt;  ddtek:serialize-to-url($newOrder, $filename, "")&lt;br /&gt;&lt;/pre&gt;&lt;p/&gt;Basically we read information out of the input document, and recreate the output using the same structure, but extending it with the shipping address.&lt;br /&gt;There are a number of issues with such approach.&lt;ul&gt;&lt;li&gt;The more complex the input documents are, the more complex and longer the query will be.&lt;/li&gt;&lt;li&gt;The query is specific to the document structure. When the document structure evolves, the query needs to be updated.&lt;/li&gt;&lt;li&gt;If you need to handle different document types, either your query becomes more complex or multiple queries are to be used.&lt;/li&gt;&lt;/ul&gt;And as you can imagine, the more complex your documents are, the more these issues are relevant. The example above is in fact over simplified. Typical XML documents in the industry are much more complex, think for example on some of the ones we use in our tutorial &lt;a href="http://www.xquery.com/ACORD/"&gt;How DataDirect XQuery Helps the Insurance Industry Deal with ACORD Standards&lt;/a&gt;.&lt;p/&gt;Using XQuery Update Facility this becomes much simpler. It helps to resolve the raised concerns, resulting in more maintainable queries, and eventually increased productivity.&lt;br/&gt;In the following query we simply enrich all XML documents by adding a corresponding address element after each customer element. Such approach is much more robust, and is ready to handle future revisions of the orders XML Schema.&lt;p/&gt;&lt;pre&gt;for $order in fn:collection("file:///C:/inputorders?select=*.xml")&lt;br /&gt;let $filename := concat("file:///C:/outputorders/", &lt;br /&gt;                        local:get-file-name(document-uri($order)))&lt;br /&gt;return&lt;br /&gt;  copy $newOrder := $order&lt;br /&gt;  modify&lt;br /&gt;    insert node&lt;br /&gt;      &amp;lt;address&gt;{&lt;br /&gt;        fn:collection("CUSTOMERS")/CUSTOMERS[NAME = $order/order/customer]/ADDRESS/text()}&lt;br /&gt;      &amp;lt;/address&gt;&lt;br /&gt;    after $newOrder/order/customer&lt;br /&gt;  return&lt;br /&gt;    ddtek:serialize-to-url($newOrder, $filename, "")&lt;/pre&gt;&lt;p/&gt;Queries like the above one are already fully functional in our development lab. At DataDirect we are excited about all the new functionality the XQuery Update Facility will bring to the XML development community.&lt;/p&gt;&lt;div class="techtags"&gt;Tech Tags: &lt;a href="http://technorati.com/tag/XQuery" rel="tag" class="techtag" title="http://technorati.com/tag/XQuery"&gt;XQuery&lt;/a&gt;&lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://www.xml-connection.com/2008/04/transforming-xml-using-xquery-updates.html' title='Transforming XML using XQuery updates'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5304121007865177116&amp;postID=5616035587057941358' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.xml-connection.com/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default/5616035587057941358'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default/5616035587057941358'/><author><name>marc</name><uri>http://www.blogger.com/profile/05398140192633313588</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-5304121007865177116.post-19207647715323459</id><published>2008-04-22T11:32:00.003-04:00</published><updated>2008-04-22T11:37:36.519-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='stock'/><category scheme='http://www.blogger.com/atom/ns#' term='CSV'/><category scheme='http://www.blogger.com/atom/ns#' term='SOA'/><category scheme='http://www.blogger.com/atom/ns#' term='XQuery'/><category scheme='http://www.blogger.com/atom/ns#' term='Web services'/><title type='text'>Stock quotes, CSV, XQuery and Web services</title><content type='html'>&lt;a href="http://www.xml-connection.com/uploaded_images/stocks-706365.gif"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://www.xml-connection.com/uploaded_images/stocks-706362.gif" border="0" alt="" /&gt;&lt;/a&gt;&lt;p&gt;Not long ago I could rely on a variety of free Web services to fetch the semi-live quotes of my preferred stock tickers. Unfortunately, one by one all those Web services have either disappeared or started requiring a subscription... and for writing a few demos now and then, the subscription model doesn't work that well for me.&lt;/p&gt;&lt;p&gt;I started thinking about alternatives; one option could be to fetch an HTML page from one of the many Web sites that expose stock quotes; but then extracting the information I'm looking for, reformatting it, or mashing it up or reshaping it in a different XML structure would be too painful. HTML layouts change frequently, and navigating HTML even after converting it to well formed XML (XHTML) is usually error prone.&lt;/p&gt;&lt;p&gt;When I mentioned that to one of our lead engineers, Tony Lavinio pointed out that Yahoo! exposes a service which returns a comma separated value (CSV) file given a list of tickers and a few options (that you can find described in a few places on the Internet). It's as simple as invoking a URL; for example, try this:&lt;/p&gt;&lt;p&gt;&lt;a href="http://finance.yahoo.com/d/quotes.csv?s=PRGS,AAPL,JAVA,MSFT&amp;f=snl1"&gt;http://finance.yahoo.com/d/quotes.csv?s=PRGS,AAPL,JAVA,MSFT&amp;amp;f=snl1&lt;/a&gt;&lt;/p&gt;&lt;p&gt;If Microsoft Excel is installed on your computer, you will most likely get the results back in an Excel spreadsheet. The options at the end control how many and what kind of &amp;quot;columns&amp;quot; you get back (&amp;quot;s&amp;quot; is the symbol, &amp;quot;n&amp;quot; is the company name, &amp;quot;l1&amp;quot; is the latest value). There are more options, as I mentioned; the following URL will return you more information for each stock ticker:&lt;/p&gt;&lt;span class="{ color:#800080; }"&gt;&lt;a href="http://finance.yahoo.com/d/quotes.csv?s=PRGS,AAPL,JAVA,MSFT&amp;amp;f=snl1chgopvd1t1jkxerba"&gt;http://finance.yahoo.com/d/quotes.csv?s=PRGS,AAPL,JAVA,MSFT&amp;amp;f=snl1chgopvd1t1jkxerba&lt;/a&gt;&lt;/span&gt;  &lt;p&gt;Well, OK; that's interesting; but how does it help me to create my own  HTML mash-ups, or my own XML reports? The Yahoo! service is very nice, but  it returns a CSV format, not XML - which, as you can guess, is what I would like to manipulate. Once again &lt;a href="http://www.xmlconverters.com"&gt;XML Converters &lt;/a&gt;come to the rescue: open your  &lt;a href="http://www.stylusstudio.com/download"&gt;Stylus Studio IDE&lt;/a&gt;, create a new XQuery and copy and paste this:&lt;/p&gt;doc(&lt;span style="color:#800080;"&gt;&amp;quot;converter:CSV?http://finance.yahoo.com/d/quotes.csv?s=PRGS,AAPL,JAVA,MSFT&amp;amp;amp;f=snl1&amp;quot;&lt;/span&gt;)  &lt;p&gt;This time you'll get an XML document back:&lt;/p&gt;&lt;font face="Courier New" size="2"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;table&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;row&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;column.0&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;PRGS&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;/column.0&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;column.1&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;PROGRESS SOFTWARE&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;/column.1&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;column.2&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;30.07&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;/column.2&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;/row&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;row&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;column.0&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;AAPL&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;/column.0&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;column.1&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;APPLE INC&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;/column.1&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;column.2&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;168.16&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;/column.2&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;/row&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;row&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;column.0&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;JAVA&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;/column.0&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;column.1&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;SUN MICROSYSTEMS &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;/column.1&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;column.2&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;15.78&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;/column.2&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;/row&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;row&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;column.0&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;MSFT&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;/column.0&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;column.1&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;MICROSOFT CP&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;/column.1&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;column.2&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;30.42&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;/column.2&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;/row&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a4630b;"&gt;/table&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;p&gt;That's something I can use to create my own HTML content or my XML report! I can just change the XQuery a bit to get that XML formatted into an HTML table, for example:&lt;/p&gt;&lt;font face="Courier New" size="2"&gt;&amp;lt;&lt;span style="color:#ab670c;"&gt;table&lt;/span&gt;&lt;span style="color:#d00020;"&gt; cellspacing=&lt;/span&gt; &lt;span style="color:#000090;"&gt;&amp;quot;1&amp;quot;&lt;/span&gt; &lt;span style="color:#d00020;"&gt;cellpadding=&lt;/span&gt;&lt;span style="color:#000090;"&gt;&amp;quot;4&amp;quot;&lt;/span&gt; &lt;span style="color:#d00020;"&gt;border=&lt;/span&gt;&lt;span style="color:#000090;"&gt;&amp;quot;1&amp;quot;&lt;/span&gt;&amp;gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;for&lt;/span&gt; $row &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; doc(&lt;span style="color:#800080;"&gt;&amp;quot;converter:CSV?http://finance.yahoo.com/d/quotes.csv?s=PRGS,AAPL,JAVA,MSFT&amp;amp;amp;f=snl1hg&amp;quot;&lt;/span&gt;)/table/row&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;return&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color:#ab670c;"&gt;tr&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color:#ab670c;"&gt;td&lt;/span&gt;&amp;gt;{ &lt;span style="color:#008000;"&gt;(:s symbol:)&lt;/span&gt; $row/column.0/text() }&amp;lt;/&lt;span style="color:#ab670c;"&gt;td&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color:#ab670c;"&gt;td&lt;/span&gt;&amp;gt;{ &lt;span style="color:#008000;"&gt;(:n name:)&lt;/span&gt; $row/column.1/text() }&amp;lt;/&lt;span style="color:#ab670c;"&gt;td&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color:#ab670c;"&gt;td&lt;/span&gt;&amp;gt;{ &lt;span style="color:#008000;"&gt;(:l1 last value:)&lt;/span&gt; $row/column.2/text() }&amp;lt;/&lt;span style="color:#ab670c;"&gt;td&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color:#ab670c;"&gt;td&lt;/span&gt;&amp;gt;{ &lt;span style="color:#008000;"&gt;(:h day's high:)&lt;/span&gt; $row/column.3/text() }&amp;lt;/&lt;span style="color:#ab670c;"&gt;td&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color:#ab670c;"&gt;td&lt;/span&gt;&amp;gt;{ &lt;span style="color:#008000;"&gt;(:g day's low:)&lt;/span&gt; $row/column.4/text() }&amp;lt;/&lt;span style="color:#ab670c;"&gt;td&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;span style="color:#ab670c;"&gt;tr&lt;/span&gt;&amp;gt;&lt;br /&gt;}&amp;lt;/&lt;span style="color:#ab670c;"&gt;table&lt;/span&gt;&amp;gt;&lt;/font&gt;&lt;p&gt;The result will look something like this:&lt;/p&gt;&lt;table cellspacing="1" cellpadding="4" border="1"&gt; &lt;tr&gt;  &lt;td&gt;&lt;font size="2"&gt;PRGS&lt;/font&gt;&lt;/td&gt;  &lt;td&gt;&lt;font size="2"&gt;PROGRESS SOFTWARE&lt;/font&gt;&lt;/td&gt;  &lt;td&gt;&lt;font size="2"&gt;29.58&lt;/font&gt;&lt;/td&gt;  &lt;td&gt;&lt;font size="2"&gt;29.87&lt;/font&gt;&lt;/td&gt;  &lt;td&gt;&lt;font size="2"&gt;29.58&lt;/font&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt;&lt;font size="2"&gt;AAPL&lt;/font&gt;&lt;/td&gt;  &lt;td&gt;&lt;font size="2"&gt;APPLE INC&lt;/font&gt;&lt;/td&gt;  &lt;td&gt;&lt;font size="2"&gt;167.527&lt;/font&gt;&lt;/td&gt;  &lt;td&gt;&lt;font size="2"&gt;168.00&lt;/font&gt;&lt;/td&gt;  &lt;td&gt;&lt;font size="2"&gt;167.05&lt;/font&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt;&lt;font size="2"&gt;JAVA&lt;/font&gt;&lt;/td&gt;  &lt;td&gt;&lt;font size="2"&gt;SUN MICROSYSTEMS &lt;/font&gt; &lt;/td&gt;  &lt;td&gt;&lt;font size="2"&gt;15.64&lt;/font&gt;&lt;/td&gt;  &lt;td&gt;&lt;font size="2"&gt;15.70&lt;/font&gt;&lt;/td&gt;  &lt;td&gt;&lt;font size="2"&gt;15.60&lt;/font&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt;&lt;font size="2"&gt;MSFT&lt;/font&gt;&lt;/td&gt;  &lt;td&gt;&lt;font size="2"&gt;MICROSOFT CP&lt;/font&gt;&lt;/td&gt;  &lt;td&gt;&lt;font size="2"&gt;30.46&lt;/font&gt;&lt;/td&gt;  &lt;td&gt;&lt;font size="2"&gt;30.64&lt;/font&gt;&lt;/td&gt;  &lt;td&gt;&lt;font size="2"&gt;30.43&lt;/font&gt;&lt;/td&gt; &lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;Now, what if I want to create my own Web service that returns information about one or more stock tickers? If you have read this &lt;a href="http://www.xml-connection.com/2008/03/xquery-and-web-services-some-practical.html"&gt;blog entry&lt;/a&gt; about how to expose and consume Web service with &lt;a href="http://www.xquery.com"&gt;DataDirect XQuery&lt;/a&gt;, you will know that creating an XQuery-based stock quote Web service is as easy as creating a simple XQuery with one external variable that accepts a list of stock tickers:&lt;/p&gt;&lt;span style="color:#0000ff;"&gt; &lt;font face="Courier New" size="2" color="#000000"&gt;getQuotes.xquery:&lt;/font&gt;&lt;/span&gt;&lt;p&gt;&lt;font face="Courier New" size="2"&gt;&lt;span style="color:#0000ff;"&gt;declare&lt;/span&gt;&lt;span style="color:#0000ff;"&gt; variable&lt;/span&gt; $tickers &lt;span style="color:#0000ff;"&gt;as&lt;/span&gt; xs:string &lt;span style="color:#0000ff;"&gt;external&lt;/span&gt;;&lt;br /&gt;&amp;lt;&lt;span style="color:#ab670c;"&gt;quotes&lt;/span&gt;&amp;gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;for&lt;/span&gt; $row &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; doc(concat(&lt;span style="color:#800080;"&gt;&amp;quot;converter:CSV?http://finance.yahoo.com/d/quotes.csv?s=&amp;quot;&lt;/span&gt;, $tickers, &lt;span style="color:#800080;"&gt;&amp;quot;&amp;amp;amp;f=snl1hg&amp;quot;&lt;/span&gt;))/table/row&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;return&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color:#ab670c;"&gt;stock&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color:#ab670c;"&gt;symbol&lt;/span&gt;&amp;gt;{ $row/column.0/text() }&amp;lt;/&lt;span style="color:#ab670c;"&gt;symbol&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color:#ab670c;"&gt;name&lt;/span&gt;&amp;gt;{ $row/column.1/text() }&amp;lt;/&lt;span style="color:#ab670c;"&gt;name&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color:#ab670c;"&gt;last-value&lt;/span&gt;&amp;gt;{ $row/column.2/text() }&amp;lt;/&lt;span style="color:#ab670c;"&gt;last-value&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color:#ab670c;"&gt;day-high&lt;/span&gt;&amp;gt;{ $row/column.3/text() }&amp;lt;/&lt;span style="color:#ab670c;"&gt;day-high&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color:#ab670c;"&gt;day-low&lt;/span&gt;&amp;gt;{ $row/column.4/text() }&amp;lt;/&lt;span style="color:#ab670c;"&gt;day-low&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;span style="color:#ab670c;"&gt;stock&lt;/span&gt;&amp;gt;&lt;br /&gt;}&amp;lt;/&lt;span style="color:#ab670c;"&gt;quotes&lt;/span&gt;&amp;gt;&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Deploying that XQuery in the &lt;a href="http://www.xquery.com/examples/web-service-example/"&gt;DataDirect XQuery Web service framework&lt;/a&gt; will expose a new WSDL/SOAP operation, and a new REST service that we can use from any environment that supports Web service invocation. Do you want to try it? Point your browser at:&lt;/p&gt;&lt;p&gt;&lt;a href="http://examples.xquery.com/stock-quotes"&gt; http://examples.xquery.com/stock-quotes&lt;/a&gt;&lt;/p&gt;&lt;p&gt;From there you can retrieve the WSDL corresponding to the XQuery above (&lt;i&gt;getQuotes.xquery&lt;/i&gt;), or try the service itself through the Web interface itself! To achieve that I didn't do any more coding than writing the XQuery listed above! As you can see, I also added there a second XQuery (&lt;i&gt;getQuotesEx.xquery&lt;/i&gt;) which allows you to specify different options:&lt;/p&gt;&lt;span style="color:#0000ff;"&gt; &lt;font face="Courier New" size="2" color="#000000"&gt;getQuotesEx.xquery:&lt;/font&gt;&lt;/span&gt;&lt;p&gt;&lt;font face="Courier New" size="2"&gt;&lt;span style="color:#0000ff;"&gt;declare &lt;/span&gt; &lt;span style="color:#0000ff;"&gt;variable&lt;/span&gt; $tickers &lt;span style="color:#0000ff;"&gt;as&lt;/span&gt; xs:string &lt;span style="color:#0000ff;"&gt;external&lt;/span&gt;;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;declare&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;variable&lt;/span&gt; $options &lt;span style="color:#0000ff;"&gt;as&lt;/span&gt; xs:string &lt;span style="color:#0000ff;"&gt;external&lt;/span&gt;;&lt;br /&gt;&amp;lt;&lt;span style="color:#ab670c;"&gt;quotes&lt;/span&gt;&amp;gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;for&lt;/span&gt; $row &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; doc(concat(&lt;span style="color:#800080;"&gt;&amp;quot;converter:CSV?http://finance.yahoo.com/d/quotes.csv?s=&amp;quot;&lt;/span&gt;, $tickers, &lt;span style="color:#800080;"&gt;&amp;quot;&amp;amp;amp;f=&amp;quot;&lt;/span&gt;, $options))/table/row&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;return &lt;/span&gt;$row&lt;br /&gt;}&amp;lt;/&lt;span style="color:#ab670c;"&gt;quotes&lt;/span&gt;&amp;gt;&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;The XML returned might be formatted in a more pleasant way adding some translation of each option in a reasonable element name returned as result, but I'll leave that exercise to someone else.&lt;/p&gt;&lt;p&gt;Thanks to the power and flexibility of &lt;a href="http://www.xquery.com"&gt; DataDirect XQuery &lt;/a&gt;and &lt;a href="http://www.xmlconverters.com"&gt;XML Converters&lt;/a&gt;, and thanks to the Yahoo! Finance CSV service, I now have again Web services I can use to retrieve all the information I need about any stock ticker!&lt;/p&gt;</content><link rel='alternate' type='text/html' href='http://www.xml-connection.com/2008/04/stock-quotes-csv-xquery-and-web_6581.html' title='Stock quotes, CSV, XQuery and Web services'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5304121007865177116&amp;postID=19207647715323459' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.xml-connection.com/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default/19207647715323459'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default/19207647715323459'/><author><name>Minollo</name><uri>http://www.blogger.com/profile/04961670236511943029</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-5304121007865177116.post-131498957215968240</id><published>2008-04-05T18:04:00.000-04:00</published><updated>2008-04-05T18:05:10.278-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='XQuery'/><title type='text'>W3C XML Query Working Group published new documents</title><content type='html'>Several new W3C XML Query publications have hit the street the last weeks.&lt;p/&gt;First of all the &lt;a href="http://www.w3.org/XML/Query/"&gt;XML Query Working Group&lt;/a&gt; published a Candidate Recommendation of &lt;a href="http://www.w3.org/TR/2008/CR-xquery-update-10-20080314/"&gt;XQuery Update Facility 1.0&lt;/a&gt;. Together with this Candidate Recommendation, the Working Group published an update of the &lt;a href="http://www.w3.org/TR/2008/CR-xquery-update-10-requirements-20080314/"&gt;XQuery Update Facility 1.0 Requirements&lt;/a&gt; and &lt;a href="http://www.w3.org/TR/2008/CR-xquery-update-10-use-cases-20080314/"&gt;XQuery Update Facility 1.0 Use Cases&lt;/a&gt;.&lt;p/&gt;Where XQuery 1.0 only allows to "query", the XQuery Update Facility adds "update" capabilities to XQuery. The obvious use case is to update XML documents stored in a database, but XQuery Update Facility is about more!&lt;br/&gt;It also enables transformations and enrichment of both transient and persisted XML documents. Such operations are rather complex with XQuery 1.0. I will talk about some of these uses cases in a future post, and show what XQuery Update Facility adds to the XQuery world when it comes to transformations and data enrichment.&lt;p/&gt;When will &lt;a href="http://www.xquery.com/"&gt;DataDirect XQuery&lt;/a&gt; support the XQuery Update Facility? If you were hoping to read here about an a concrete date, I have to disappoint you. All I can say right now is that DataDirect follows closely the XQuery Update Facility development process. We will be able to make this more concrete later this year, when the XQuery Update Facility moves into Proposed Recommendation.&lt;br/&gt;In the meantime, don’t forget that DataDirect XQuery offers today the ability to update your database through XQuery, &lt;a href="http://www.blogger.com/profile/04961670236511943029"&gt;Minollo&lt;/a&gt; blogged about &lt;a href="http://www.xml-connection.com/2008/01/bulk-load-of-xml-data-into-relational.html"&gt;a nice use case&lt;/a&gt; not so long ago.&lt;p/&gt;I believe a significant limitations of the XQuery Update Facility is that an expressions is either "updating" or "non updating". In other words, within a single query it is not possible to both perform an update and return a query result. Looks like a common use case to me. The XML Query Working Group is trying to answer this through XQuery Scripting Extensions.&lt;p/&gt;A first Working Draft of &lt;a href="http://www.w3.org/TR/2008/WD-xquery-sx-10-20080328/"&gt;XQuery Scripting Extension 1.0&lt;/a&gt; made it to the public recently. As this is a first Working Draft, don’t expect things to be written in stone. Everything is open for change and improvements. As with most of the XQuery specifications, this one also is accompanied  by a &lt;a href="http://www.w3.org/TR/2008/WD-xquery-sx-10-use-cases-20080328/"&gt;Use Cases&lt;/a&gt; document, it provides the usage scenarios that motivate the changes in the XQuery Scripting Extension. I’m a fan of the use cases approach, it’s a good source for learning.&lt;p/&gt;As said above, the ability to both "update" and "query" is required, and this is definitely the most important functionality I see in the XQuery Scripting Extensions. Some of the procedural extensions (assignments, while-loop, etc) are somehow questionable. It has to be seen how these will be used in a declarative language like XQuery. Will such concepts result in confusion for the user? Will productivity of XQuery programming improve through the procedural extensions? The future will tell...&lt;p/&gt;The XML Query Working Group has been busy lately, and also started with XQuery 1.1. Still preliminary, but the &lt;a href="http://www.w3.org/TR/xquery-11-requirements/"&gt;Requirements&lt;/a&gt; and a first version of the &lt;a href="http://www.w3.org/TR/xquery-11-use-cases/"&gt;Uses Cases&lt;/a&gt; were published mid March.&lt;/p&gt;&lt;div class="techtags"&gt;Tech Tags: &lt;a href="http://technorati.com/tag/XQuery" rel="tag" class="techtag" title="http://technorati.com/tag/XQuery"&gt;XQuery&lt;/a&gt;&lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://www.xml-connection.com/2008/04/w3c-xml-query-working-group-published.html' title='W3C XML Query Working Group published new documents'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5304121007865177116&amp;postID=131498957215968240' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.xml-connection.com/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default/131498957215968240'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default/131498957215968240'/><author><name>marc</name><uri>http://www.blogger.com/profile/05398140192633313588</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-5304121007865177116.post-4645460979115397287</id><published>2008-03-27T04:01:00.001-04:00</published><updated>2008-03-27T05:03:04.049-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='XQuery'/><category scheme='http://www.blogger.com/atom/ns#' term='relational'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='database'/><title type='text'>Joining XML with RDBMS, how and what are the consequences?</title><content type='html'>A few months ago, my friend &lt;a href="http://www.blogger.com/profile/04961670236511943029"&gt;Minollo&lt;/a&gt; blogged about &lt;a href="http://www.xml-connection.com/2007/08/we-recently-noticed-some-questions-on.html"&gt;XQuery against RDBMS: let the engine optimize your SQL&lt;/a&gt;. And last week again, a question on some newsgroup attracted our attention.&lt;p&gt;Imagine you have an XML document with customers, there might be one or a few hundred, and want to retrieve all orders for these customers out of your Oracle database. One could write something as follows, using a general comparison in the where clause.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;pre&gt;for $order in collection("ORDERS")/ORDERS&lt;br /&gt;where $order/O_CUSTKEY = doc("customers.xml")/customers/customer&lt;br /&gt;return&lt;br /&gt;  &amp;lt;order id="{$order/O_ORDERKEY}"&gt;&lt;br /&gt;    &amp;lt;customer&gt;{$order/O_CUSTKEY/data(.)}&amp;lt;/customer&gt;&lt;br /&gt;    &amp;lt;date&gt;{$order/O_ORDERDATE/data(.)}&amp;lt;/date&gt;&lt;br /&gt;    &amp;lt;price&gt;{$order/O_TOTALPRICE/data(.)}&amp;lt;/price&gt;&lt;br /&gt;  &amp;lt;/order&gt;&lt;/pre&gt;&lt;p&gt;As explained in the white paper &lt;a href="http://www.xquery.com/white_papers/generating_sql/"&gt;Implementing XQuery efficiently for relational databases&lt;/a&gt;, DataDirect XQuery always handles general comparisons efficiently and translates them into SQL - taking advantage of database indexes and only retrieving the relevant data out of the database.&lt;/p&gt;&lt;p&gt;Most other XQuery implementations don't translate such general comparisons into SQL, because the second argument of the general comparison is a sequence of customers. In other words, the where clause is not evaluated by the database engine, with all the negative performance and scalability consequences that implies. Basically, all records in the ORDERS table are retrieved out of the database, and filtering is accomplished in memory.&lt;/p&gt;&lt;p&gt;As advised on the newsgroup, one can rewrite the query as follows.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;pre&gt;for $customer in doc("customers.xml")/customers/customer&lt;br /&gt;for $order in collection("ORDERS")/ORDERS&lt;br /&gt;where $order/O_CUSTKEY = $customer&lt;br /&gt;return&lt;br /&gt;  &amp;lt;order id="{$order/O_ORDERKEY}"&gt;&lt;br /&gt;    &amp;lt;customer&gt;{$order/O_CUSTKEY/data(.)}&amp;lt;/customer&gt;&lt;br /&gt;    &amp;lt;date&gt;{$order/O_ORDERDATE/data(.)}&amp;lt;/date&gt;&lt;br /&gt;    &amp;lt;price&gt;{$order/O_TOTALPRICE/data(.)}&amp;lt;/price&gt;&lt;br /&gt;  &amp;lt;/order&gt;&lt;/pre&gt;&lt;p&gt;Both queries yield the same result. Well, to be technically accurate, there are some differences.&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;the order of the returned orders might be different. With the second query, the orders are grouped per customer&lt;/li&gt;&lt;li&gt;in order to make both queries equivalent, with the second alternative, you need to get distinct values out of the customers.xml&lt;/li&gt;&lt;/ul&gt;But ok, let's assume for a moment both queries yield the same result.&lt;p&gt;One interesting thing about this second query, compared to the first, is that most XQuery implementations are capable of translating this where clause in SQL as both arguments of the comparison are single values. And you end up with SQL as follows, executed through a nested loop algorithm.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;pre&gt;select  O_ORDERKEY, O_CUSTKEY, O_ORDERDATE, O_TOTALPRICE&lt;br /&gt;from ORDERS&lt;br /&gt;where O_CUSTKEY = ?&lt;/pre&gt;&lt;p&gt;Further, better implementations will try to minimize the number of roundtrips to the database, and combine multiple requests in a single SQL statement. Smells like a topic for another post, anyway...&lt;/p&gt;&lt;p&gt;Looks great, our initial concerns are answered, the where clause is evaluated by the SQL engine. We're perfectly happy, right?&lt;/p&gt;&lt;p&gt;Unfortunately, there is a significant drawback with the second query! Suppose, for example, we want to order our results by ORDERDATE and TOTALPRICE.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;pre&gt;for $customer in doc("customers.xml")/customers/customer&lt;br /&gt;for $order in collection("ORDERS")/ORDERS&lt;br /&gt;where $order/O_CUSTKEY = $customer&lt;br /&gt;order by $order/O_ORDERDATE, $order/O_TOTALPRICE&lt;br /&gt;return&lt;br /&gt;  &amp;lt;order id="{$order/O_ORDERKEY}"&gt;&lt;br /&gt;    &amp;lt;customer&gt;{$order/O_CUSTKEY/data(.)}&amp;lt;/customer&gt;&lt;br /&gt;    &amp;lt;date&gt;{$order/O_ORDERDATE/data(.)}&amp;lt;/date&gt;&lt;br /&gt;    &amp;lt;price&gt;{$order/O_TOTALPRICE/data(.)}&amp;lt;/price&gt;&lt;br /&gt;  &amp;lt;/order&gt;&lt;/pre&gt;&lt;p&gt;Although the where clause is translated into SQL, the order by clause is not. It is simply not possible! Remember that multiple SQL statements will be executed in a nested loop, all these results are buffered in memory, after which we need to order the buffered results. This is clearly a significant drawback of the proposed alternative. Handing order by clauses out of your database engine, implies a serious performance penalty and excessive memory consumption, even with medium sized query results.&lt;/p&gt;&lt;p&gt;Let's go back to our initial query and add the order by clause.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;pre&gt;for $order in collection("ORDERS")/ORDERS&lt;br /&gt;where $order/O_CUSTKEY = doc("customers.xml")/customers/customer&lt;br /&gt;order by $order/O_ORDERDATE, $order/O_TOTALPRICE&lt;br /&gt;return&lt;br /&gt;  &amp;lt;order id="{$order/O_ORDERKEY}"&gt;&lt;br /&gt;    &amp;lt;customer&gt;{$order/O_CUSTKEY/data(.)}&amp;lt;/customer&gt;&lt;br /&gt;    &amp;lt;date&gt;{$order/O_ORDERDATE/data(.)}&amp;lt;/date&gt;&lt;br /&gt;    &amp;lt;price&gt;{$order/O_TOTALPRICE/data(.)}&amp;lt;/price&gt;&lt;br /&gt;  &amp;lt;/order&gt;&lt;/pre&gt;&lt;p&gt;If you have an XQuery implementation that is capable of translating such where clauses into SQL, the topic this post started with, it can as a consequence go further and also translate the order by clause into SQL! With DataDirect XQuery, the &lt;a href="http://media.datadirect.com/download/docs/ddxquery/allddxq/reference/advancedfeatures6.html#wp212090"&gt;execution plan&lt;/a&gt; for this last query is as follows. Note that both the where and order by clause are pushed into SQL and processed by your Oracle database.&lt;/p&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.xml-connection.com/uploaded_images/20080326_plan-719271.JPG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; cursor: pointer;" src="http://www.xml-connection.com/uploaded_images/20080326_plan-719271.JPG" alt="" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;As you see, choosing the right XQuery implementation can make a huge difference. If you want to find out more about how DataDirect XQuery generates SQL and leverages the strengths of your current database investment, check out this &lt;a href="http://www.xquery.com/white_papers/generating_sql/"&gt;white paper&lt;/a&gt;.&lt;/p&gt;&lt;div class="techtags"&gt;Tech Tags: &lt;a href="http://technorati.com/tag/XQuery" rel="tag" class="techtag"&gt;XQuery&lt;/a&gt; &lt;a href="http://technorati.com/tag/SQL" rel="tag" class="techtag"&gt;SQL&lt;/a&gt; &lt;a href="http://technorati.com/tag/join+xml+database" rel="tag" class="techtag"&gt;join+xml+database&lt;/a&gt; &lt;a href="http://technorati.com/tag/performance" rel="tag" class="techtag"&gt;performance&lt;/a&gt; &lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://www.xml-connection.com/2008/03/joining-xml-with-rdbms-how-and-what-are.html' title='Joining XML with RDBMS, how and what are the consequences?'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5304121007865177116&amp;postID=4645460979115397287' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.xml-connection.com/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default/4645460979115397287'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default/4645460979115397287'/><author><name>marc</name><uri>http://www.blogger.com/profile/05398140192633313588</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-5304121007865177116.post-8385482763641587538</id><published>2008-03-20T22:02:00.010-04:00</published><updated>2008-03-20T23:33:16.852-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='OOXML'/><category scheme='http://www.blogger.com/atom/ns#' term='office'/><category scheme='http://www.blogger.com/atom/ns#' term='XQuery'/><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><title type='text'>Using XQuery to join two Excel spreadsheets? Why not?</title><content type='html'>&lt;a href="http://www.xml-connection.com/uploaded_images/spreadsheet-769986.gif"&gt;&lt;img style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://www.xml-connection.com/uploaded_images/spreadsheet-769853.gif" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;This afternoon I was having some fun (not!) reviewing some third party license agreements, when someone emailed me a couple of Excel spreadsheets saying "Hey Minollo! I have these two spreadsheets; one has a list of all employees since 1990 in &lt;a href="http://www.progress.com/"&gt;Progress Corporation &lt;/a&gt;and the cities where they lived when they were hired; the other one has a list of the current employees and in which Progress division they work; I need to create a list of all the current employees with details about the division they work in and the town the live (or lived) in. Is there anything that "&lt;a href="http://www.xquery.com/"&gt;XQuery thing&lt;/a&gt;" you always talk me about can do for me here?"&lt;br /&gt;&lt;br /&gt;Well, the temptation to keep reviewing license agreements rather than playing with XQuery was strong... but I resisted! I had to help this guy! :)&lt;br /&gt;&lt;br /&gt;I was happy to notice that the spreadsheets had been saved using the Office Open XML (OOXML) format; OOXML is basically a package of XML files describing the document (text, spreadsheet, slides) that it represents. Being XML-based, it's quite easy to inspect it using an XML query language; the package is a zip format, so individual documents can be retrieved using the standard "jar:" file scheme, for example.&lt;br /&gt;&lt;br /&gt;So, coming back to the guy asking for help joining two spreadsheets; what can we do for him? If you look at the structure of the two spreadsheets he sent me (attached to this post), you'll see two XML documents that are relevant to us:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:courier new;"&gt;xl/worksheets/sheet1.xml&lt;/span&gt;&lt;br /&gt;This file contains the content of each non-empty cell in the spreadsheet. The document is split in &lt;row&gt;elements and each &lt;row&gt;element has a number of cells represented by &lt;c&gt;elements. When the content of a &lt;c&gt;element is a character string, like in this particular case, the &lt;c&gt;element contains a &lt;v&gt;element whose value is the index of the corresponding character string in a list of all the character strings used in the spreadsheet&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:courier new;"&gt;xl/sharedStrings.xml&lt;/span&gt;&lt;br /&gt;This file contains all the character strings used as content of cells in the spreadsheet; the order is relevant, as the character strings are referenced using an index (like described above)&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p&gt;To retrieve the whole content of xl/worksheets/sheet1.xml from c:\doc1.xlsx using a Java-based XQuery processor like DataDirect XQuery, you can just us the standard fn:doc() function:&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;fn:doc(&lt;span style="color:#cc33cc;"&gt;"jar:file:///c:/doc1.xlsx!/xl/worksheets/sheet1.xml"&lt;/span&gt;)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;The index corresponding to the character string contained in the first cell of the first row in the spreadsheet can be retrieved doing:&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;fn:doc(&lt;span style="color:#cc33cc;"&gt;"jar:file:///c:/doc1.xlsx!/xl/worksheets/sheet1.xml"&lt;/span&gt;)//&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;ooxml:sheetData/ooxml:row[1]/ooxml:c[1]/ooxml:v&lt;/span&gt;&lt;/p&gt;&lt;p&gt;...where ooxml is a namespace prefix associated to the URI http://schemas.openxmlformats.org/spreadsheetml/2006/main .&lt;/p&gt;&lt;p&gt;And if you have the index of the character string, the character string itself can be retrieved as:&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;fn:doc(&lt;span style="color:#cc33cc;"&gt;"jar:file:///c:/doc1.xlsx!/xl/sharedStrings.xml"&lt;/span&gt;)//&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;ooxml:si[$theIndex+1]/ooxml:t/text()&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Easy, isn't it!?&lt;/p&gt;&lt;p&gt;Add some syntax, a couple of FLWOR expressions, a few HTML tags, and here you go! This XQuery just joins the two spreadsheets and creates an easy to read HTML report:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;span style="color:#3333ff;"&gt;&amp;nbsp;declare namespace &lt;/span&gt;ooxml=&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#cc33cc;"&gt;"&lt;/span&gt;&lt;span style="color:#cc33cc;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;color:#cc33cc;"&gt;http://schemas.openxmlformats.org/spreadsheetml/2006/main"&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&amp;nbsp;let &lt;/span&gt;$doc1Strings &lt;span style="color:#3333ff;"&gt;:= &lt;/span&gt;doc(&lt;span style="color:#cc33cc;"&gt;"jar:file:///c:/doc1.xlsx!/xl/sharedStrings.xml"&lt;/span&gt;)//ooxml:si&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&amp;nbsp;let &lt;/span&gt;$doc2Strings &lt;span style="color:#3333ff;"&gt;:= &lt;/span&gt;doc&lt;span style="color:#cc33cc;"&gt;&lt;span style="color:#000000;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#cc33cc;"&gt;"jar:file:///c:/doc2.xlsx!/xl/sharedStrings.xml"&lt;/span&gt;)//ooxml:si&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&amp;nbsp;return&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#cc6600;"&gt;&lt;span style="color:#000000;"&gt;&amp;nbsp;&amp;nbsp;&lt;&lt;/span&gt;table&lt;/span&gt;&lt;span style="color:#000000;"&gt;&gt;&lt;/span&gt; {&lt;br /&gt;&lt;span style="color:#cc6600;"&gt;&lt;span style="color:#000000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;/span&gt;tr &lt;/span&gt;&lt;span style="color:#cc0000;"&gt;style&lt;/span&gt;=&lt;span style="color:#cc33cc;"&gt;"font-weight: bold"&lt;/span&gt;&gt;&lt;&lt;span style="color:#cc6600;"&gt;td&lt;/span&gt;&gt;Name&lt;&lt;span style="color:#cc6600;"&gt;/td&lt;/span&gt;&gt;&lt;&lt;span style="color:#cc6600;"&gt;td&lt;/span&gt;&gt;Division&lt;&lt;span style="color:#cc6600;"&gt;/td&lt;/span&gt;&gt;&lt;&lt;span style="color:#cc6600;"&gt;td&lt;/span&gt;&gt;City&lt;&lt;span style="color:#cc6600;"&gt;/td&lt;/span&gt;&gt;&lt;&lt;span style="color:#cc6600;"&gt;/tr&lt;/span&gt;&gt;,&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;for &lt;/span&gt;$row1 &lt;span style="color:#3333ff;"&gt;in&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;doc(&lt;span style="color:#cc33cc;"&gt;"jar:file:///c:/doc1.xlsx!/xl/worksheets/sheet1.xml"&lt;/span&gt;)//&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ooxml:sheetData/ooxml:row,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$row2 &lt;span style="color:#3333ff;"&gt;in &lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;doc(&lt;span style="color:#cc33cc;"&gt;"jar:file:///c:/doc2.xlsx!/xl/worksheets/sheet1.xml"&lt;/span&gt;)//&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ooxml:sheetData/ooxml:row&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;let &lt;/span&gt;$col1-1 &lt;span style="color:#3333ff;"&gt;:= &lt;/span&gt;$doc1Strings[$row1/ooxml:c[1]/ooxml:v/number()+1]/ooxml:t/text()&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;let &lt;/span&gt;$col2-1 &lt;span style="color:#3333ff;"&gt;:= &lt;/span&gt;$doc2Strings[$row2/ooxml:c[1]/ooxml:v/number()+1]/ooxml:t/text()&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;where &lt;/span&gt;$col1-1 &lt;span style="color:#3333ff;"&gt;= &lt;/span&gt;$col2-1&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;let &lt;/span&gt;$col1-2 &lt;span style="color:#3333ff;"&gt;:= &lt;/span&gt;$doc1Strings[$row1/ooxml:c[2]/ooxml:v/number()+1]/ooxml:t/text()&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;let &lt;/span&gt;$col2-2 &lt;span style="color:#3333ff;"&gt;:= &lt;/span&gt;$doc2Strings[$row2/ooxml:c[2]/ooxml:v/number()+1]/ooxml:t/text()&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#cc6600;"&gt;tr&lt;/span&gt;&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#cc6600;"&gt;td&lt;/span&gt;&gt;{$col1-1}&lt;&lt;span style="color:#cc6600;"&gt;/td&lt;/span&gt;&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#cc6600;"&gt;td&lt;/span&gt;&gt;{$col2-2}&lt;&lt;span style="color:#cc6600;"&gt;/td&lt;/span&gt;&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#cc6600;"&gt;td&lt;/span&gt;&gt;{$col1-2}&lt;&lt;span style="color:#cc6600;"&gt;/td&lt;/span&gt;&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#cc6600;"&gt;/tr&lt;/span&gt;&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;} &lt;&lt;span style="color:#cc6600;"&gt;/table&lt;/span&gt;&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;It's that simple! Here are the two spreadsheets, if you want to try it yourself: &lt;a href="http://www.xml-connection.com/doc1.xlsx"&gt;doc1.xlsx&lt;/a&gt;, &lt;a href="http://www.xml-connection.com/doc2.xlsx"&gt;doc2.xlsx&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://www.xml-connection.com/2008/03/using-xquery-to-join-two-excel.html' title='Using XQuery to join two Excel spreadsheets? Why not?'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5304121007865177116&amp;postID=8385482763641587538' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.xml-connection.com/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default/8385482763641587538'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default/8385482763641587538'/><author><name>Minollo</name><uri>http://www.blogger.com/profile/04961670236511943029</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-5304121007865177116.post-4552895048999870803</id><published>2008-03-11T15:54:00.005-04:00</published><updated>2008-03-11T16:26:15.064-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='XQuery'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='workshop'/><title type='text'>A free XQuery workshop close to you!</title><content type='html'>&lt;a href="http://www.xml-connection.com/uploaded_images/www2-701889.gif"&gt;&lt;img style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://www.xml-connection.com/uploaded_images/www2-701870.gif" border="0" /&gt;&lt;/a&gt;Many of you have been writing us positive comments about the technical content of this &lt;a href="http://www.xml-connection.com/"&gt;Blog&lt;/a&gt;. We are happy to hear you find the information in this pages useful; both &lt;a href="http://www.blogger.com/profile/05398140192633313588"&gt;Marc &lt;/a&gt;and &lt;a href="http://www.blogger.com/profile/04961670236511943029"&gt;I &lt;/a&gt;always try hard posting on topics about which we hear a lot of interest when we talk to XQuery developers and users of our XML products, &lt;a href="http://www.xquery.com/"&gt;DataDirect XQuery &lt;/a&gt;and &lt;a href="http://www.xmlconverters.com/"&gt;XML Converters&lt;/a&gt;. &lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;div&gt;One of the things we have been hearing from you is that you would like us to offer &lt;a href="http://www.xquery.com/events/xq-workshop.html"&gt;workshops or tutorials &lt;/a&gt;on how to use XQuery in real life scenarios; and I'm glad to let you know that we have recently announced a tour of a few cities in the United States and Europe to offer you all a *free* &lt;a href="http://www.xquery.com/events/xq-workshop.html"&gt;workshop on XQuery&lt;/a&gt;! During this hands-on workshop we will be writing, testing and deploying real XML and XQuery-based solutions, live in front of you!&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;We will start with some typical scenarios where a hypothetical IT organization needs to create a set of data services exposing various functionality. The workshop covers:&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Transforming XML documents into user-defined formats&lt;/li&gt;&lt;li&gt;Aggregating XML documents with relational data&lt;/li&gt;&lt;li&gt;Consuming Web services in XQuery&lt;/li&gt;&lt;li&gt;Exposing XQuery as data services&lt;/li&gt;&lt;li&gt;Integrating with non-XML B2B standards, like EDI&lt;/li&gt;&lt;li&gt;Adhering to XML industry standards, such as ACORD for insurance &lt;/li&gt;&lt;/ul&gt;&lt;p&gt;The workshop is highly interactive, and we really need your help to solve the various problems that we introduce! Again, these events are entirely free and you just need to register in advance to attend; dates, locations and registration details are available &lt;a href="http://www.xquery.com/events/xq-workshop.html"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;We all hope to see you soon in one of the cities we are visiting.&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://www.xml-connection.com/2008/03/free-xquery-workshop-close-to-you.html' title='A free XQuery workshop close to you!'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5304121007865177116&amp;postID=4552895048999870803' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.xml-connection.com/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default/4552895048999870803'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default/4552895048999870803'/><author><name>Minollo</name><uri>http://www.blogger.com/profile/04961670236511943029</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-5304121007865177116.post-6998446492146435022</id><published>2008-03-10T12:53:00.004-04:00</published><updated>2008-03-10T21:04:20.197-04:00</updated><title type='text'>XQuery and Web Services: some practical examples</title><content type='html'>&lt;a href="http://www.xml-connection.com/uploaded_images/web1-789146.gif"&gt;&lt;img style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://www.xml-connection.com/uploaded_images/web1-785965.gif" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;We have been mentioning in several occasions - like &lt;a href="http://www.soamag.com/I10/0907-3.asp"&gt;here&lt;/a&gt; - that using XQuery in the context of Web services is an extremely powerful and flexible approach. The fact that XQuery and Web services share the same underlying data model (at least in the vast majority of practical cases), it makes it extremely appealing to use XQuery to access and merge information returned by one or more Web services, maybe aggregate it with data available in RDBMS and maybe even expose the resulting XQuery itself as a Web service.&lt;br /&gt;&lt;br /&gt;As most of us have an engineering background rather than a marketing one, we often find it much easier to &lt;em&gt;show &lt;/em&gt;something than to talk about it. That's why we have &lt;a href="http://www.xquery.com/examples/web-service-example/"&gt;created a few pages &lt;/a&gt;on our website that describe how DataDirect XQuery can be exposed as a Web service without any additional coding, supporting both WSDL/SOAP or REST interfaces; and how you can use &lt;a href="http://www.xquery.com/examples/web-service-example/photo-search/"&gt;DataDirect XQuery to consume other Web services&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;We will keep adding Web service-based examples over time; so make sure you visit often!</content><link rel='alternate' type='text/html' href='http://www.xml-connection.com/2008/03/xquery-and-web-services-some-practical.html' title='XQuery and Web Services: some practical examples'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5304121007865177116&amp;postID=6998446492146435022' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.xml-connection.com/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default/6998446492146435022'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default/6998446492146435022'/><author><name>Minollo</name><uri>http://www.blogger.com/profile/04961670236511943029</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-5304121007865177116.post-7977885890480592273</id><published>2008-03-04T06:37:00.010-05:00</published><updated>2008-03-04T07:16:09.121-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='XQJ'/><title type='text'>Approval for XQJ 1.0</title><content type='html'>I &lt;a href="http://www.xml-connection.com/2008/02/xqj-goes-for-final-approval-ballot.html "&gt;blogged&lt;/a&gt; last week on submitting &lt;a href="http://www.jcp.org/en/jsr/detail?id=225"&gt;XQJ&lt;/a&gt; to the JCP for final approval. Yesterday, it successfully passed the Final Approval Ballot in the &lt;a href="http://www.jcp.org/en/participation/committee#SEEE"&gt;JCP Executive committee&lt;/a&gt;.&lt;p/&gt;XQJ 1.0 will be released in the coming weeks! I'll keep you informed when the download page becomes available, and about DataDirect's plans to officially support XQJ 1.0.&lt;p/&gt;I would like to use this opportunity, and thank everyone in the JSR-225 Expert Group for their efforts on this specification.&lt;p/&gt;&lt;script type="text/javascript"&gt;digg_skin = 'compact'; digg_url = 'http://www.xml-connection.com/2008/03/approval-for-xqj-10.html'&lt;/script&gt;&lt;script src="http://digg.com/tools/diggthis.js" type="text/javascript"&gt;&lt;/script&gt;&lt;/p&gt;&lt;div class="techtags"&gt;Tech Tags: &lt;a href="http://technorati.com/tag/XQJ" rel="tag" class="techtag" title="http://technorati.com/tag/XQJ"&gt;XQJ&lt;/a&gt;&lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://www.xml-connection.com/2008/03/approval-for-xqj-10.html' title='Approval for XQJ 1.0'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5304121007865177116&amp;postID=7977885890480592273' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.xml-connection.com/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default/7977885890480592273'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default/7977885890480592273'/><author><name>marc</name><uri>http://www.blogger.com/profile/05398140192633313588</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-5304121007865177116.post-3039642036890398430</id><published>2008-02-20T14:21:00.000-05:00</published><updated>2008-02-20T14:22:29.023-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='XQJ'/><title type='text'>XQJ goes for Final Approval Ballot</title><content type='html'>The XQJ specification (&lt;a href="http://www.jcp.org/en/jsr/detail?id=225"&gt;JSR 225&lt;/a&gt;) has been submitted to the JCP for final approval. The Final Approval Ballot lasts from February 19 until March 3. I'll keep you posted here.&lt;p/&gt;Want to know more about XQJ, we have a &lt;a href="http://www.xquery.com/tutorials/xqj_tutorial/"&gt;tutorial&lt;/a&gt; covering most functionality. And there are already several implementations available, including &lt;a href="http://www.xquery.com/"&gt;DataDirect XQuery&lt;/a&gt;.&lt;p/&gt;&lt;script type="text/javascript"&gt;digg_skin = 'compact'; digg_url = 'http://www.xml-connection.com/2008/02/xqj-goes-for-final-approval-ballot.html'&lt;/script&gt;&lt;script src="http://digg.com/tools/diggthis.js" type="text/javascript"&gt;&lt;/script&gt;&lt;/p&gt;&lt;div class="techtags"&gt;Tech Tags: &lt;a href="http://technorati.com/tag/XQJ" rel="tag" class="techtag" title="http://technorati.com/tag/XQJ"&gt;XQJ&lt;/a&gt;&lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://www.xml-connection.com/2008/02/xqj-goes-for-final-approval-ballot.html' title='XQJ goes for Final Approval Ballot'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5304121007865177116&amp;postID=3039642036890398430' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.xml-connection.com/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default/3039642036890398430'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default/3039642036890398430'/><author><name>marc</name><uri>http://www.blogger.com/profile/05398140192633313588</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-5304121007865177116.post-6271097007488230441</id><published>2008-02-18T13:57:00.008-05:00</published><updated>2008-02-18T17:41:05.218-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='format'/><category scheme='http://www.blogger.com/atom/ns#' term='proprietary'/><category scheme='http://www.blogger.com/atom/ns#' term='fixed width'/><category scheme='http://www.blogger.com/atom/ns#' term='XQuery'/><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><title type='text'>Converting proprietary file formats to specific XML structures</title><content type='html'>&lt;a href="http://www.xml-connection.com/uploaded_images/documents-707576.gif"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://www.xml-connection.com/uploaded_images/documents-707574.gif" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;We have talked in the past about how you can use &lt;a href="http://www.xquery.com"&gt;XQuery&lt;/a&gt; to deal with &lt;a href="http://www.xmlconverters.com/standards/"&gt;EDI&lt;/a&gt; message (&lt;a href="http://www.xml-connection.com/2007/12/transform-directory-of-edi-messages.html"&gt;transform a directory of EDI messages&lt;/a&gt;, &lt;a href="http://www.xml-connection.com/2007/12/create-edi-messages-out-of-your.html"&gt;create EDI messages out of your database&lt;/a&gt;, &lt;a href="http://www.xml-connection.com/2008/01/converting-tab-delimited-files-into-edi.html"&gt;converting tab delimited files into EDI&lt;/a&gt;). But sometimes you are not dealing with EDI; it's not infrequent that companies still rely on proprietary file formats to exchange or circulate information.&lt;br /&gt;For example, a few days ago we received a request from a user who needed to convert a file in a proprietary format into a specific XML structure. The sample file he sent us looked something like this:&lt;/p&gt;&lt;br /&gt;&lt;div style="border-style: solid; border-width: 1px; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px"&gt; &lt;font face="Courier New" size="2"&gt;10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0123456789MR JOHN&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SMITH&lt;br /&gt; 20&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0123456789ACCT1&lt;br /&gt; 30&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0123456789SALARY&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;500000&lt;br /&gt; 30&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0123456789BONUS&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1000&lt;br /&gt; 20&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0123456789ACCT2&lt;br /&gt; 30&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0123456789OTHER&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;100&lt;br /&gt; 10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1234566790MR DAVID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DOE&lt;br /&gt; 20&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1234567890ACCT1&lt;br /&gt; 30&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1234567890SALARY&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;10000&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;This isn't EDI, CSV, tab delimited or any of the other standard or semi-standard ways to represent information in text files; it's a proprietary format based on a specific interpretation of the size and position of the fields. This is the description of records and fields that the user shared with us:&lt;/p&gt;&lt;br /&gt;&lt;div style="border-style: solid; border-width: 1px; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px"&gt; one block is made of:&lt;br /&gt;&amp;nbsp; one &lt;i&gt;record 10 &lt;/i&gt;(customer)&lt;br /&gt;&amp;nbsp; 1 to N &lt;i&gt;record 20 &lt;/i&gt;per record 10 (accounts)&lt;br /&gt;&amp;nbsp; 1 to N &lt;i&gt;record 30 &lt;/i&gt;per record 20 (transactions)&lt;br /&gt;&lt;br /&gt; &lt;i&gt;record 10&lt;br /&gt;&amp;nbsp; record type &lt;/i&gt;on 10 characters&lt;br /&gt; &lt;i&gt;&amp;nbsp; customer id &lt;/i&gt;on 10 characters&lt;br /&gt; &lt;i&gt;&amp;nbsp; customer lastname &lt;/i&gt;on 20 characters&lt;br /&gt; &lt;i&gt;&amp;nbsp; customer firstname &lt;/i&gt;on 30 characters&lt;br /&gt;&lt;br /&gt; &lt;i&gt;record 20&lt;br /&gt;&amp;nbsp; record type &lt;/i&gt;on 10 characters&lt;br /&gt; &lt;i&gt;&amp;nbsp; customer id &lt;/i&gt;on 10 characters&lt;br /&gt; &lt;i&gt;&amp;nbsp; account id &lt;/i&gt;on 10 characters&lt;br /&gt;&lt;br /&gt; &lt;i&gt;record 30&lt;br /&gt;&amp;nbsp; record type &lt;/i&gt;on 10 characters&lt;br /&gt; &lt;i&gt;&amp;nbsp; customer id &lt;/i&gt;on 10 characters&lt;br /&gt; &lt;i&gt;&amp;nbsp; label &lt;/i&gt;on 10 characters&lt;br /&gt; &lt;i&gt;&amp;nbsp; value &lt;/i&gt;on 10 characters&lt;/div&gt;&lt;br /&gt;&lt;p&gt;How can we deal with something like this without building our own parser? &lt;a href="http://www.xmlconverters.com"&gt;DataDirect XML Converters &lt;/a&gt;and &lt;a href="http://www.stylusstudio.com"&gt;Stylus Studio&lt;/a&gt; can definitely help! XML Converters support what we call &amp;quot;&lt;a href="http://www.stylusstudio.com/text_file_to_xml.html"&gt;custom conversions&lt;/a&gt;&amp;quot;; a custom conversion defines how files belonging to the same format family should be converted to XML by XML Converters. As the definition of a custom conversion can be a tedious task, Stylus Studio provides an editor that allows you to create custom conversion through an intuitive graphical interface. Explaining how that would work in this case is probably more complicated than actually doing it... so, here is a &lt;a href="http://download.xmlconverters.com/xmlconverters/blog-custom-conversion.wmv"&gt;short video which describes all the operations&lt;/a&gt; you would do in Stylus Studio to convert the file provided by the user into XML.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Thanks to the custom conversion created using Stylus Studio, we are now able to manipulate the proprietary format file as XML; but, as mentioned above, the user needs to convert the file into a specific XML format. Using the example above, the desired XML result should look like this:&lt;/p&gt;&lt;br /&gt;&lt;div style="border-style: solid; border-width: 1px; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px"&gt; &lt;font face="Courier New" size="1"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;root&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;record_10&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;10&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;customer_id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;0123456789&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/customer_id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;lastname&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;MR JOHN&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/lastname&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;firstname&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;SMITH&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/firstname&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/record_10&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;record_20&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;20&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;customer_id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;0123456789&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/customer_id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;account_id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;ACCT1&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/account_id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/record_20&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;record_30&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;30&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;customer_id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;0123456789&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/customer_id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;label&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;SALARY&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/label&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;value&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;500000&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/value&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/record_30&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;record_30&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;30&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;customer_id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;0123456789&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/customer_id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;label&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;BONUS&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/label&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;value&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;1000&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/value&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/record_30&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;record_20&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;20&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;customer_id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;0123456789&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/customer_id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;account_id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;ACCT2&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/account_id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/record_20&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;record_30&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;30&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;customer_id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;0123456789&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/customer_id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;label&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;OTHER&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/label&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;value&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;100&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/value&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/record_30&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;record_10&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;10&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;customer_id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;1234566790&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/customer_id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;lastname&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;MR DAVID&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/lastname&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;firstname&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;DOE&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/firstname&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/record_10&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;record_20&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;20&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;customer_id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;1234567890&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/customer_id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;account_id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;ACCT1&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/account_id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/record_20&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;record_30&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;30&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;customer_id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;1234567890&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/customer_id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;label&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;SALARY&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/label&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;value&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;10000&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/value&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/record_30&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#ea8f0f"&gt;/root&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;This is where the combination of DataDirect XQuery and XML Converters proves particularly helpful: not only we are able to move from a proprietary file format to well formed XML, but we also have all the power, performance and scalability of XQuery to deal with such XML to transform it (potentially, even augment it!) into the final format that we need. The following XQuery - which implicitly relies on the custom converter described above - does the trick; notice that we created a couple of functions to take care of the positional grouping which is required to generate the desired output; that makes the XQuery much easier to read and more reusable:&lt;/p&gt;&lt;br /&gt;&lt;div style="border-style: solid; border-width: 1px; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px"&gt;&lt;font face="Courier New" size="1"&gt;&lt;span style="color:#0000ff;"&gt;declare&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;function&lt;/span&gt; local:getRelated20s($item) {&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;let&lt;/span&gt; $nextItem &lt;span style="color:#008080;"&gt;:=&lt;/span&gt;$item/&lt;span style="color:#0000ff;"&gt;following-sibling::&lt;/span&gt;*[local-name()&lt;span style="color:#008080;"&gt;!=&lt;/span&gt;&lt;span style="color:#800080;"&gt;&amp;quot;record_20&amp;quot;&lt;/span&gt;&lt;span style="color:#008080;"&gt;and&lt;/span&gt; local-name()&lt;span style="color:#008080;"&gt;!=&lt;/span&gt;&lt;span style="color:#800080;"&gt;&amp;quot;record_30&amp;quot;&lt;/span&gt;][1]&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;for&lt;/span&gt; $related &lt;span style="color:#0000ff;"&gt;in &lt;/span&gt;$item/&lt;span style="color:#0000ff;"&gt;following-sibling::&lt;/span&gt;*[local-name()&lt;span style="color:#008080;"&gt;=&lt;/span&gt;&lt;span style="color:#800080;"&gt;&amp;quot;record_20&amp;quot;&lt;/span&gt;]&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;where&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; ($nextItem) &lt;span style="color:#0000ff;"&gt;then&lt;/span&gt; $related &lt;span style="color:#008080;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; $nextItem&lt;span style="color:#0000ff;"&gt; else&lt;/span&gt; true()&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; $related&lt;br /&gt; };&lt;br /&gt; &lt;span style="color:#0000ff;"&gt;declare&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;function&lt;/span&gt; local:getRelated30s($item) {&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;let&lt;/span&gt; $nextItem &lt;span style="color:#008080;"&gt;:=&lt;/span&gt; $item/&lt;span style="color:#0000ff;"&gt;following-sibling::&lt;/span&gt;*[local-name()&lt;span style="color:#008080;"&gt;!=&lt;/span&gt;&lt;span style="color:#800080;"&gt;&amp;quot;record_30&amp;quot;&lt;/span&gt;][1]&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;for&lt;/span&gt; $related &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; $item/&lt;span style="color:#0000ff;"&gt;following-sibling::&lt;/span&gt;*[local-name()&lt;span style="color:#008080;"&gt;=&lt;/span&gt;&lt;span style="color:#800080;"&gt;&amp;quot;record_30&amp;quot;&lt;/span&gt;]&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;where&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt;($nextItem) &lt;span style="color:#0000ff;"&gt;then&lt;/span&gt; $related &lt;span style="color:#008080;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; $nextItem &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt; true()&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; $related&lt;br /&gt; };&lt;br /&gt; &amp;lt;&lt;span style="color:#ea8f10;"&gt;DataSets&lt;/span&gt;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;for&lt;/span&gt; $record_10 &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; doc(&lt;span style="color:#800080;"&gt;'converter:file:///c:/blog1/sample.conv?sampleinput.txt'&lt;/span&gt;)/root/record_10&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;return&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color:#ea8f10;"&gt;DataSet&lt;/span&gt;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color:#ea8f10;"&gt;CustomerId&lt;/span&gt;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{$record_10/customer_id/text()}&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;span style="color:#ea8f10;"&gt;CustomerId&lt;/span&gt;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color:#ea8f10;"&gt;CustomerName&lt;/span&gt;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{$record_10/lastname/text()}&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;span style="color:#ea8f10;"&gt;CustomerName&lt;/span&gt;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color:#ea8f10;"&gt;CustomerFirstName&lt;/span&gt;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{$record_10/firstname/text()}&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;span style="color:#ea8f10;"&gt;CustomerFirstName&lt;/span&gt;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color:#ea8f10;"&gt;Accounts&lt;/span&gt;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;for&lt;/span&gt; $record_20 &lt;span style="color:#0000ff;"&gt; in&lt;/span&gt; local:getRelated20s($record_10)&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;return&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color:#ea8f10;"&gt;Account&lt;/span&gt;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color:#ea8f10;"&gt;AccountId&lt;/span&gt;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{$record_20/account_id/text()}&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;span style="color:#ea8f10;"&gt;AccountId&lt;/span&gt;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color:#ea8f10;"&gt;Transactions&lt;/span&gt;&amp;gt; {&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;for&lt;/span&gt; $record_30 &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; local:getRelated30s($record_20)&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;return&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color:#ea8f10;"&gt;Transaction&lt;/span&gt;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color:#ea8f10;"&gt;Label&lt;/span&gt;&amp;gt;{$record_30/label/text()}&amp;lt;/&lt;span style="color:#ea8f10;"&gt;Label&lt;/span&gt;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;span style="color:#ea8f10;"&gt;Value&lt;/span&gt;&amp;gt;{$record_30/value/text()}&amp;lt;/&lt;span style="color:#ea8f10;"&gt;Value&lt;/span&gt;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;span style="color:#ea8f10;"&gt;Transaction&lt;/span&gt;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;lt;/&lt;span style="color:#ea8f10;"&gt;Transactions&lt;/span&gt;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;span style="color:#ea8f10;"&gt;Account&lt;/span&gt;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;span style="color:#ea8f10;"&gt;Accounts&lt;/span&gt;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;span style="color:#ea8f10;"&gt;DataSet&lt;/span&gt;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt; &amp;lt;/&lt;span style="color:#ea8f10;"&gt;DataSets&lt;/span&gt;&amp;gt; &lt;/font&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;Once again, thanks to the fact that DataDirect XQuery and XML Converters make it possible to manipulate a wide variety of data sources (even proprietary ones!), you are able to deal with transformation (and possibly aggregation) problems from an XML point of view, shielding as much as possible those tasks from the low level details of the data sources.&lt;/p&gt;</content><link rel='alternate' type='text/html' href='http://www.xml-connection.com/2008/02/convertig-proprietary-file-formats-to.html' title='Converting proprietary file formats to specific XML structures'/><link rel='enclosure' type='video/mp4' href='http://www.blogger.com/video-play.mp4?contentId=1f89550a058e0444&amp;type=video%2Fmp4' length='0'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5304121007865177116&amp;postID=6271097007488230441' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.xml-connection.com/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default/6271097007488230441'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default/6271097007488230441'/><author><name>Minollo</name><uri>http://www.blogger.com/profile/04961670236511943029</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-5304121007865177116.post-3581905302910366559</id><published>2008-02-06T14:32:00.000-05:00</published><updated>2008-02-06T16:18:53.987-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='XQuery'/><title type='text'>XQuery creates HTML including images</title><content type='html'>This is the fourth post in the series &lt;a href="http://www.xml-connection.com/2007/12/xquery-generating-multiple-xml.html%20"&gt;XQuery generating multiple documents&lt;/a&gt;. Today we show how to create an HTML document referencing JPEG files through XQuery. The &lt;a href="http://www.xquery.com/"&gt;DataDirect XQuery&lt;/a&gt; built-in function &lt;a href="http://media.datadirect.com/download/docs/ddxquery/allddxq/reference/xquerysupport7.html#wp298908"&gt;ddtek:serialize-to-url &lt;/a&gt; is used to save the JPEG images.&lt;p/&gt;The idea is that all the data, including the images, are stored in a relational database. The queries in this post have been tested with DataDirect XQuery against &lt;a href="http://www.xquery.com/sql_server/"&gt;SQL Server&lt;/a&gt;, but as we will demonstrate this works perfectly against any other database supported by DataDirect XQuery - &lt;a href="http://www.xquery.com/oracle/"&gt;Oracle&lt;/a&gt;, &lt;a href="http://www.xquery.com/db2/"&gt;DB2&lt;/a&gt;, &lt;a href="http://www.xquery.com/sybase/"&gt;Sybase&lt;/a&gt;, &lt;a href="http://www.xquery.com/mysql/"&gt;MySQL&lt;/a&gt;, etc.&lt;p&gt;XQuery is known to query and produce XML, but how can it be used to produce images, JPEG files in this particular example? This is another example where the &lt;a href="http://www.xmlconverters.com/"&gt;DataDirect XML Converters&lt;/a&gt; come to rescue.&lt;/p&gt;&lt;p&gt;The JPEG images are stored in our database, and are retrieved by DataDirect XQuery as xs:hexbinary data. Subsequently the DataDirect XML Converters are used to convert the xs:hexbinary into a binary stream, which is saved as a JPEG file.&lt;/p&gt;&lt;p&gt;The following query shows how to generate the main HTML page which references the JPEG files. The idea here is to save the HTML document in the same directory as the JPEG files.&lt;br /&gt;The table in our SQL Server database is fairly simple, having 3 columns with the name of the image, a small description and the actual picture.&lt;/p&gt;&lt;pre&gt;&amp;lt;html&gt;{&lt;br /&gt;  "My favourite pictures.",&amp;lt;p/&gt;,&lt;br /&gt;  (: loop over all images in the database:)&lt;br /&gt;  for $image in collection("images")/images&lt;br /&gt;  (: the file name of the JPEG file :)&lt;br /&gt;  let $filename := concat($image/name, ".jpg")&lt;br /&gt;  (: create some virtual XML, which will be&lt;br /&gt;     processed by the XML Converters :)&lt;br /&gt;  let $jpeg := &amp;lt;jpeg&gt;{$image/image/text()}&amp;lt;/jpeg&gt;&lt;br /&gt;  return&lt;br /&gt;    (&amp;lt;a href="./{$filename}"&gt;{&lt;br /&gt;       $image/description,&lt;br /&gt;       (: create the JPEG file :)&lt;br /&gt;       ddtek:serialize-to-url($jpeg,&lt;br /&gt;                              concat("C:/test", $filename),&lt;br /&gt;                              "method=binary")&lt;br /&gt;     }&amp;lt;/a&gt;,&lt;br /&gt;     &amp;lt;br/&gt;)&lt;br /&gt;}&amp;lt;/html&gt;&lt;/pre&gt;&lt;p/&gt;In this example we've used JPEG files, but you can apply the outlined technique with any other binary format.&lt;p/&gt;&lt;script type="text/javascript"&gt;digg_skin = 'compact'; digg_url = 'http://www.xml-connection.com/2008/02/xquery-creates-html-including-images.html'&lt;/script&gt;&lt;script src="http://digg.com/tools/diggthis.js" type="text/javascript"&gt;&lt;/script&gt;&lt;/p&gt;&lt;div class="techtags"&gt;Tech Tags: &lt;a href="http://technorati.com/tag/XQuery" rel="tag" class="techtag" title="http://technorati.com/tag/XQuery"&gt;XQuery&lt;/a&gt;&lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://www.xml-connection.com/2008/02/xquery-creates-html-including-images.html' title='XQuery creates HTML including images'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5304121007865177116&amp;postID=3581905302910366559' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.xml-connection.com/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default/3581905302910366559'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5304121007865177116/posts/default/3581905302910366559'/><author><name>marc</name><uri>http://www.blogger.com/profile/05398140192633313588</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-5304121007865177116.post-1176356777302822836</id><published>2008-01-29T14:27:00.000-05:00</published><updated>2008-01-30T11:39:38.316-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='example'/><category scheme='http://www.blogger.com/atom/ns#' term='conversion'/><category scheme='http://www.blogger.com/atom/ns#' term='x12'/><category scheme='http://www.blogger.com/atom/ns#' term='XQuery'/><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><category scheme='http://www.blogger.com/atom/ns#' term='edi'/><title type='text'>Converting tab delimited files into EDI</title><content type='html'>&lt;a href="http://www.xml-connection.com/uploaded_images/puzzle-710241.gif"&gt;&lt;img style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://www.xml-connection.com/uploaded_images/puzzle-710234.gif" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;A few days ago I received a email saying "&lt;em&gt;I am a &lt;a href="http://www.xquery.com/"&gt;DataDirect XQuery &lt;/a&gt;user, and I'm successfully using your product to create XML-based reports from incoming EDI messages. Now I'm in need to do something somewhat different: it may happen that my company receives &lt;a href="http://www.xmlconverters.com/standards/flat-files/"&gt;tab-delimited messages&lt;/a&gt;, and those messages need to be translated to &lt;a href="http://www.xmlconverters.com/standards/x12/"&gt;EDI X12 831&lt;/a&gt;, rather than converted to XML. Can your product help me handling tab-delimited to EDI conversions?&lt;/em&gt;".&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;Not being a marketing person, I usually like showing how things are done, rather than just claiming that they can be easily done using our products... :)&lt;/div&gt;&lt;div&gt;So, I asked the user for an example of his data, a tab-delimited file. If you have read some of the &lt;a href="http://www.xml-connection.com/2007/10/converting-between-edi-and-xml-why.html"&gt;other posts in this Blog&lt;/a&gt;, you will know that &lt;a href="http://www.xquery.com/"&gt;DataDirect XQuery &lt;/a&gt;can access tab-delimited files thanks to the &lt;a href="http://www.xmlconverters.com/"&gt;XML Converters technology&lt;/a&gt;. So, consider this tab-delimited file:&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;id description quantity unitprice&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;001 Telephone 1 23.00&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;002 Desk 1 129.00&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;003 Keyboard 2 21.00&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;The following XQuery will return, for example, all the description fields in the tab-delimited input message:&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;items&lt;/span&gt;&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:80%;"&gt;&lt;span style="color:#3333ff;"&gt;&amp;nbsp;&amp;nbsp;for&lt;/span&gt; $item &lt;span style="color:#3333ff;"&gt;in&lt;/span&gt; doc(&lt;span style="color:#cc33cc;"&gt;"converter:TAB:first=yes?file:///c:/sample.tab"&lt;/span&gt;)//row&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:80%;"&gt;&lt;span style="color:#3333ff;"&gt;&amp;nbsp;&amp;nbsp;return&lt;/span&gt; $item/description&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;} &lt;&lt;span style="color:#996633;"&gt;/items&lt;/span&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;The result is:&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;items&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;description&lt;/span&gt;&gt;Telephone&lt;&lt;span style="color:#996633;"&gt;/description&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;description&lt;/span&gt;&gt;Desk&lt;&lt;span style="color:#996633;"&gt;/description&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;description&lt;/span&gt;&gt;Keyboard&lt;&lt;span style="color:#996633;"&gt;/description&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;/items&lt;/span&gt;&gt; &lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;That shows that we can handle a tab-delimited file in &lt;a href="http://www.xquery.com/"&gt;DataDirect XQuery &lt;/a&gt;and generate XML; but it doesn't help much our user: he needs to output EDI.&lt;/div&gt;&lt;div&gt;But we know how to do that; Marc has shown us in &lt;a href="http://www.xml-connection.com/2007/12/create-edi-messages-out-of-your.html"&gt;this post how you can create EDI messages from XQuery&lt;/a&gt;. We just need to apply the same idea to our example; the following XQuery uses the incoming tab-delimited file to apparently generate an XML fragment consistent with a specific vocabulary; that vocabulary is what the underlying XML Converters technology knows how to translate in the corresponding EDI message (an &lt;a href="http://www.xmlconverters.com/standards/x12/"&gt;X12 832 &lt;/a&gt;message in this case, which is a price/sales catalog). The &lt;a href="http://media.datadirect.com/download/docs/ddxquery/allddxq/reference/xqjsupport19.html#wp166619"&gt;serialization option at the beginning &lt;/a&gt;of the XQuery is instructing DataDirect XQuery to output a raw EDI message rather than XML; that way we are moving data from a tab-delimited file format into an EDI message manipulating it as if it was all XML, but without ever materializing it as XML! Many of the EDI fields typically specified are omitted here; but this example will run if you want to see how it works.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:80%;"&gt;&lt;span style="color:#3333ff;"&gt;&amp;nbsp;declare option &lt;/span&gt;ddtek:serialize &lt;span style="color:#993399;"&gt;"method=EDI,long=yes"&lt;/span&gt;;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;X12&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;ISA&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;ISA06-InterchangeSenderId&lt;/span&gt;&gt;1515151515&lt;&lt;span style="color:#996633;"&gt;/ISA06-InterchangeSenderId&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;ISA08-InterchangeReceiverId&lt;/span&gt;&gt;5151515151&lt;&lt;span style="color:#996633;"&gt;/ISA08-InterchangeReceiverId&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;ISA11-RepetitionSeparator&lt;/span&gt;&gt;^&lt;&lt;span style="color:#996633;"&gt;/ISA11-RepetitionSeparator&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;ISA13-InterchangeControlNumber&lt;/span&gt;&gt;000032123&lt;&lt;span style="color:#996633;"&gt;/ISA13-InterchangeControlNumber&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;ISA14-AcknowledgmentRequested&lt;/span&gt;&gt;0&lt;&lt;span style="color:#996633;"&gt;/ISA14-AcknowledgmentRequested&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;ISA15-UsageIndicator&lt;/span&gt;&gt;P&lt;&lt;span style="color:#996633;"&gt;/ISA15-UsageIndicator&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;ISA16-ComponentElementSeparator&lt;/span&gt;&gt;*&lt;&lt;span style="color:#996633;"&gt;/ISA16-ComponentElementSeparator&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;/ISA&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;GS&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;GS01-FunctionalIdentifierCode&lt;/span&gt;&gt;CT&lt;&lt;span style="color:#996633;"&gt;/GS01-FunctionalIdentifierCode&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;GS02-ApplicationSendersCode&lt;/span&gt;&gt;9988776655&lt;&lt;span style="color:#996633;"&gt;/GS02-ApplicationSendersCode&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;GS03-ApplicationReceiversCode&lt;/span&gt;&gt;1122334455&lt;&lt;span style="color:#996633;"&gt;/GS03-ApplicationReceiversCode&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&lt;span style="color:#996633;"&gt;&lt;span style="color:#000000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;/span&gt;GS06-GroupControlNumber&lt;/span&gt;&gt;128&lt;&lt;span style="color:#996633;"&gt;/GS06-GroupControlNumber&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;GS07-ResponsibleAgencyCode&lt;/span&gt;&gt;X&lt;&lt;span style="color:#996633;"&gt;/GS07-ResponsibleAgencyCode&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;GS08-VersionReleaseIndustry&lt;/span&gt;&gt;004030&lt;&lt;span style="color:#996633;"&gt;/GS08-VersionReleaseIndustry&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;/GS&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;TS_832&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;ST&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;ST01-TransactionSetIdentifierCode&lt;/span&gt;&gt;832&lt;&lt;span style="color:#996633;"&gt;/ST01-TransactionSetIdentifierCode&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;ST02-TransactionSetControlNumber&lt;/span&gt;&gt;12345&lt;&lt;span style="color:#996633;"&gt;/ST02-TransactionSetControlNumber&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;/ST&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;BCT&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;BCT01-CatalogPurposeCode&lt;/span&gt;&gt;CP&lt;&lt;span style="color:#996633;"&gt;/BCT01-CatalogPurposeCode&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;BCT02-CatalogNumber&lt;/span&gt;&gt;GOV56789&lt;&lt;span style="color:#996633;"&gt;/BCT02-CatalogNumber&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;BCT10-TransactionSetPurposeCode&lt;/span&gt;&gt;00&lt;&lt;span style="color:#996633;"&gt;/BCT10-TransactionSetPurposeCode&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;/BCT&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&lt;span style="color:#000099;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for &lt;/span&gt;$row &lt;span style="color:#000099;"&gt;in &lt;/span&gt;doc(&lt;span style="color:#993399;"&gt;'converter:TAB:first=yes?file:///c:/sample.tab'&lt;/span&gt;)/table/row&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&lt;span style="color:#000099;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;GROUP_5&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;LIN&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:80%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt;span style="color:#996633;"&gt;LIN02-ProductServiceIdQualifier&lt;/span&gt;&gt;MF&lt;&lt;span style="color:#996633;"&gt;/LIN02-ProductServiceIdQualifier&lt;/span&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:couri