<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Native XML Database</title>
	<atom:link href="http://nativexmldatabase.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://nativexmldatabase.com</link>
	<description></description>
	<lastBuildDate>Tue, 08 May 2012 23:47:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='nativexmldatabase.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Native XML Database</title>
		<link>http://nativexmldatabase.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://nativexmldatabase.com/osd.xml" title="Native XML Database" />
	<atom:link rel='hub' href='http://nativexmldatabase.com/?pushpress=hub'/>
		<item>
		<title>XML Enhancements in DB2 10 for Linux, UNIX, and Windows</title>
		<link>http://nativexmldatabase.com/2012/04/19/xml-enhancements-in-db2-10-for-linux-unix-and-windows/</link>
		<comments>http://nativexmldatabase.com/2012/04/19/xml-enhancements-in-db2-10-for-linux-unix-and-windows/#comments</comments>
		<pubDate>Fri, 20 Apr 2012 01:15:07 +0000</pubDate>
		<dc:creator>Matthias Nicola</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nativexmldatabase.com/?p=1424</guid>
		<description><![CDATA[You might have noticed that DB2 10 for Linux, UNIX, and Windows was announced earlier this month, and it contains a bunch of great new features. One of the new features that I am particularly excited about is Time Travel, which enables bitemporal data managenment in DB2. DB2 10 also includes a variety of useful [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nativexmldatabase.com&#038;blog=3215007&#038;post=1424&#038;subd=purexml&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>You might have noticed that DB2 10 for Linux, UNIX, and Windows was <a href="http://www.ibm.com/software/data/db2-warehouse-10/">announced</a> earlier this month, and it contains a bunch of great new features. One of the new features that I am particularly excited about is <a href="http://www-01.ibm.com/software/data/db2/linux-unix-windows/time-travel-query.html">Time Travel</a>, which enables <a href="http://www.ibm.com/developerworks/data/library/techarticle/dm-1204db2temporaldata/">bitemporal data managenment</a> in DB2.</p>
<p>DB2 10 also includes a variety of useful XML enhancements. Let&#8217;s take a quick look at the most important ones here:</p>
<h3>New XML Index Data Types: Integer, Decimal</h3>
<p>As you know, when you create an index on an XML element or attribute you must specify the data type that DB2 should use to interpret and index the specifies nodes. The reason is that the usage of XML Schema, which might define data types, is optional. And even if an XML Schema was used, it might not define a data type for each and every element and attribute.</p>
<p>Before DB2 10, an XML index for numeric values is specified with the data type DOUBLE, so that any type of numeric values can be indexed. In DB2 10 you can also specify the data types INTEGER and DECIMAL to define a numeric XML index.</p>
<p>If you know that a certain element or attribute can only contain INTEGER (or DECIMAL) values, then you can improve query performance by creating the XML index with the most appropriate type. For example, assume that <strong>dept</strong> is a table that has an XML column <strong>deptdoc</strong>. Then you can define the following indexes in DB2 10:</p>
<p><span style="color:#0000ff;">create unique index idx1 on dept(deptdoc) generate key using</span><br />
<span style="color:#0000ff;"> xmlpattern &#8216;/dept/employee/@id&#8217; as sql <strong>integer</strong>;</span></p>
<p><span style="color:#0000ff;">create index idx2 on dept(deptdoc) generate key using</span><br />
<span style="color:#0000ff;"> xmlpattern &#8216;/dept/employee/salary&#8217; as sql <strong>decimal(6,2)</strong>;</span></p>
<p>You don&#8217;t need to change existing queries to use these new indexes!</p>
<h3>XML Indexes for Case-Insensitive Search</h3>
<p>DB2 10 allows you to define case-insensitive indexes and search very efficiently for string values regardless of their upper case or lower case spelling. For example, to enable case-insensitive search of employee names, you could create the following index:</p>
<p><span style="color:#0000ff;">create unique index idx1 on dept(deptdoc) generate key using</span><br />
<span style="color:#0000ff;"> xmlpattern &#8216;/dept/employee/<strong>name/fn:upper-case(.)</strong>&#8216; as sql varchar(40);</span></p>
<p>This index stores all key values in upper-case. To find employees with names such as Peter Pan, PETER PAN,  Peter PAN, pEtEr pAn, etc. you could write the following query that can use the index above:</p>
<p><span style="color:#0000ff;">SELECT *</span><br />
<span style="color:#0000ff;"> FROM dept</span><br />
<span style="color:#0000ff;"> WHERE XMLEXISTS(&#8216;$DEPTDOC/dept/employee[<strong>name/fn:upper-case(.)</strong> = "PETER PAN"]&#8216;);</span></p>
<h3>Index support for Prefix Search</h3>
<p>Previously, the following query with the fn:starts-with() function could not use an XML index to find all employees whose name starts with &#8220;Jo&#8221;:</p>
<p><span style="color:#0000ff;">SELECT *</span><br />
<span style="color:#0000ff;"> FROM dept</span><br />
<span style="color:#0000ff;"> WHERE XMLEXISTS(&#8216;$DEPTDOC/dept/employee[<strong>fn:starts-with</strong>(name, "Jo")]&#8216;);</span></p>
<p>In DB2 10, this query can benefit from existing XML indexes of type VARCHAR(n) that may exist on the &lt;name&gt; element.</p>
<h3>XML Indexes for Existential (Structural) Predicates</h3>
<p>An <em>existential predicate</em>, sometimes called <em>structural predicate</em>, is a predicate that checks the existence of an XML element or attribute in an XML document, regardless of its value.</p>
<p>For example, imagine you want to find all documents that contain a &lt;comment&gt; element for an employee. One of the following queries comes to mind:</p>
<p><span style="color:#0000ff;">SELECT * </span><br />
<span style="color:#0000ff;">FROM dept</span><br />
<span style="color:#0000ff;">WHERE XMLEXISTS(&#8216;$DEPTDOC<strong>/dept/employee[comment]</strong>&#8216;);</span></p>
<p><span style="color:#0000ff;">SELECT * </span><br />
<span style="color:#0000ff;">FROM dept</span><br />
<span style="color:#0000ff;">WHERE XMLEXISTS(&#8216;$DEPTDOC<strong>/dept/employee[fn:exists(comment)]</strong>&#8216;);</span></p>
<p>To support such queries, DB2 10 allows you to create an XML index with the fn:exists function, like this:</p>
<p><span style="color:#0000ff;">create unique index idx1 on dept(deptdoc) generate key using</span><br />
<span style="color:#0000ff;">xmlpattern &#8216;/dept/employee/<strong>fn:exists(comment)</strong>&#8216; as sql <strong>varchar(1)</strong>;</span></p>
<p>This index must be defined as VARCHAR(1) and each index key represents true or false to indicate the existence of the &lt;comment&gt; element in a given document.</p>
<h3>Friendly XML query behavior</h3>
<p>DB2 10 also includes several enhancements that make XML queries behave in a more friendly manner. Let&#8217;s look at just one of several cases. For example, consider the following query that has a numeric predicate on the @id attribute:</p>
<p><span style="color:#0000ff;">select *</span><br />
<span style="color:#0000ff;">from dept</span><br />
<span style="color:#0000ff;">where xmlexists(&#8216;$DEPTDOC/dept[@id = 15]&#8216;);</span></p>
<p>What happens if this query encounters an XML document where the @id attribute has a non-numeric string value such as &#8220;WW Sales&#8221;?  In DB2 9.x this situation would cause a type error at run-time and the query would fail and abort with an error message. Although this behavior was compliant with the language standard, it is not very useful. If you look for the department with id = 15, any department with non-numeric id can never be a match. Therefore, DB2 10 simply evaluates the predicate to FALSE in this case, i.e. ignores the document with the non-numeric id, and continues processing the query.</p>
<h3>Binary XML client/server communication</h3>
<p>With DB2 10, Java applications can choose the format in which XML is transmitted between the application and the DB2 server. You can choose between traditional textual XML and a new binary XML format that is a compressed on-the-wire format for XML.</p>
<p>On the application side, the encoding and decoding of XML to and from the binary format is performed by the JDBC driver (JCC 4.9 or higher). The JDBC driver can convert the binary XML format to and from a text,  DOM, SAX, or StAX representation. The use of binary XML provides the most notable performance gain for Java applications that already consume or produce XML in SAX format.</p>
<p>Applications can exchange XML with the DB2 server (through inserts, queries, etc.) and completely avoid the serialization of XML to text, i.e. neither the client nor the server needs to deal with textual XML for the purpose of insert or retrieving XML. Eliminating the parsing and serialization of textual XML can enable significantly better end-to-end performance.</p>
<p>Other IBM products that support this binary XML communication format include DB2 10 for z/OS, the WebSphere Application Server XML Feature Pack, and the WebSphere Datapower appliance.</p>
<h3>Query Performance Enhancements</h3>
<p>DB2 10 also includes a number of performance improvements for common types of XML queries, including many types of queries that use the XMLTABLE function.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/purexml.wordpress.com/1424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/purexml.wordpress.com/1424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/purexml.wordpress.com/1424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/purexml.wordpress.com/1424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/purexml.wordpress.com/1424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/purexml.wordpress.com/1424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/purexml.wordpress.com/1424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/purexml.wordpress.com/1424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/purexml.wordpress.com/1424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/purexml.wordpress.com/1424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/purexml.wordpress.com/1424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/purexml.wordpress.com/1424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/purexml.wordpress.com/1424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/purexml.wordpress.com/1424/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nativexmldatabase.com&#038;blog=3215007&#038;post=1424&#038;subd=purexml&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nativexmldatabase.com/2012/04/19/xml-enhancements-in-db2-10-for-linux-unix-and-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0fa2a8696cf3869ab2ded9243422d875?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matthias</media:title>
		</media:content>
	</item>
		<item>
		<title>What is an XML Schema and why should I care?</title>
		<link>http://nativexmldatabase.com/2012/02/29/what-is-an-xml-schema-and-why-should-i-care/</link>
		<comments>http://nativexmldatabase.com/2012/02/29/what-is-an-xml-schema-and-why-should-i-care/#comments</comments>
		<pubDate>Thu, 01 Mar 2012 05:33:28 +0000</pubDate>
		<dc:creator>Matthias Nicola</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nativexmldatabase.com/?p=1417</guid>
		<description><![CDATA[What is an XML Schema? Some of you may already know this, others don&#8217;t. So before I&#8217;m going to share some more technical information about XML Schemas in subsequent blog posts, I better get some of the basics out of the way first. When you process and manage information in XML format, you can choose [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nativexmldatabase.com&#038;blog=3215007&#038;post=1417&#038;subd=purexml&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>What is an XML Schema?</strong> Some of you may already know this, others don&#8217;t. So before I&#8217;m going to share some more technical information about XML Schemas in subsequent blog posts, I better get some of the basics out of the way first.</p>
<p>When you process and manage information in XML format, you can choose to use an XML Schema with your XML documents. Roughly speaking, an XML Schema can be used to define what you want your XML documents to look like. For example, in an XML Schema you can define:</p>
<ul>
<li>Which elements and attributes are allowed to occur in your XML documents</li>
<li>How the elements can be or must be nested, or the order in which the elements must appear</li>
<li>Which elements or attributes are mandatory vs. optional</li>
<li>The number of times a given element can be repeated within a document (e.g. to allow for multiple phone numbers per customer, multiple items per order, etc.)</li>
<li>The data types of the element and attribute values, such as xs:integer, xs:decimal, xs:string, etc.</li>
<li>The namespaces that the elements belong to</li>
<li>&#8230;and so on.</li>
</ul>
<p>If you choose to create an XML Schema, it may define just some or all of the aspects listed above. The designer of the XML Schema can choose the degree to which the schema constraints the characteristics of the XML documents. For example, an XML Schema can be very loose and define only a few key features for your XML documents and allow for a lot of flexibility. Or it can be very strict to tightly control the XML data in every aspect. Or anything in between.</p>
<p>The use of an XML Schema is optional, i.e. an XML Schema is not required to store, index, query, or update XML documents. However, an XML Schema can be very useful to ensure that the XML documents that you receive or  produce are compliant with certain structural rules that allow applications to process the XML. In other words, XML Schemas help you to enforce data quality.</p>
<p><strong>Validation</strong></p>
<p>If an document complies with a given XML Schema, then the document is said to be <strong>valid</strong> for this schema. A document might be valid for one schema but invalid for another schema. The process of testing an XML document for compliance with an XML Schema is called <strong>validation</strong>.</p>
<p>When an XML document is parsed by an XML parser, validation can be enabled as an optional part of the parsing process. Full validation of an XML document always requires XML parsing. For many documents and schemas, validation typically incurs only a small delta cost (in terms of CPU usage) on top of the cost of XML parsing.</p>
<p><strong>What does an an XML Schema look like?</strong></p>
<p>An XML Schema itself is an XML document! But, a very special document that needs to comply with very specific rules that are defined by -you guessed it!- another XML Schema, i.e. the schema for schemas.</p>
<p>Large XML schemas can consist of multiple schema documents that reference each other through import and include relationships. This allows you to compose an XML Schema out of smaller building blocks in a modular fashion.</p>
<p>I don&#8217;t want to go into the syntax details of XML Schemas here, but there are some useful resources available:</p>
<ul>
<li>The XML Schema Primer: <a href="http://www.w3.org/TR/xmlschema-0/">http://www.w3.org/TR/xmlschema-0/</a></li>
<li>A tutorial: <a href="http://www.w3schools.com/schema/default.asp">http://www.w3schools.com/schema/default.asp</a></li>
<li>Best practices for XML Schema design: <a href="http://www.xfront.com/BestPracticesHomepage.html">http://www.xfront.com/BestPracticesHomepage.html</a></li>
</ul>
<p><strong>When and why should I use an XML Schema?</strong></p>
<p>Simply put, if you want to ensure data quality and detect XML documents that do not comply with an expected format, use an XML Schema and validate each document!</p>
<p>However, what if XML documents pass through multiple components of your IT infrastructure, such as a message queue, an application server, an enterprise service bus, and the database system? If these components do not modify the XML but merely read &amp; route it, examine whether <em>all</em> of these components need to validate each document. For example, if the application server has already validated a document before insertion into a DB2 database, does the document need to be validated again in DB2? Maybe not, if you trust the application layer. Maybe yes, if you don&#8217;t.</p>
<p>An XML Schema is also often used as a &#8220;contract&#8221; between two or more parties that exchange XML documents. With this contract the parties agree on a specific format and structure of the XML messages that they send and receive, to ensure seamless operation.</p>
<p>Practically every vertical industry has defined XML Schemas to standardize XML message formats for the data processing in their industry. A good overview is given by the introduction of this article:</p>
<p>&#8220;Getting started with Industry Formats and Services with pureXML&#8221;: <a href="http://www.ibm.com/developerworks/data/library/techarticle/dm-0705malaika/">http://www.ibm.com/developerworks/data/library/techarticle/dm-0705malaika/</a></p>
<p><strong>How can I validate XML documents in DB2?<br />
</strong></p>
<p>Simple. First, you register one or multiple XML Schemas in the DB2 database. This can be done with CLP commands, stored procedures, or through API calls in the JDBC or .NET interface to DB2. After a schema is registered in DB2, you can use it to validate XML documents in DB2, typically when you insert, load, or update XML documents. You can enforce a single XML Schema for all XML documents in an XML column, or you can allow multiple XML Schemas per column. A database administrator can force automatic validation upon document insert, or allow applications to choose one of the previously registered schema for validation whenever a document inserted.</p>
<p><strong>And&#8230; validation can also be done in SQL statements?</strong></p>
<p>Yup. The SQL standard defines a function called <a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.sql.ref.doc/doc/r0022197.html">XMLVALIDATE</a>, which can be used for document validation in INSERT statement, UPDATE statements, triggers, stored procedures, and even in queries.</p>
<p>Here is a simple example of an INSERT statement that adds a row to a customer customer table, which consists of an integer ID column and an XML column called &#8220;doc&#8221;:</p>
<p><span style="color:#0000ff;">INSERT INTO customer(id, doc) </span><br />
<span style="color:#0000ff;">VALUES (?, XMLVALIDATE( ? ACCORDING TO XMLSCHEMA ID db2admin.custxsd) );</span></p>
<p>The id and the document are provided by parameter markers &#8220;?&#8221;, and the XMLVALIDATE function that is wrapped around the second parameter ensures validation against the XML Schema that has been regoistered under the identifier db2admin.custxsd.</p>
<p>If the inserted document is not compliant with the XML Schema, the INSERT statement fails with an appropriate error message. Similarly, the XMLVALIDATE function can also be used in the right-hand side of the SET clause of an UPDATE statement that modifies or replaces an XML document.</p>
<p>Ok, so much for now. In my next blog post we&#8217;ll go into more detail.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/purexml.wordpress.com/1417/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/purexml.wordpress.com/1417/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/purexml.wordpress.com/1417/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/purexml.wordpress.com/1417/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/purexml.wordpress.com/1417/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/purexml.wordpress.com/1417/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/purexml.wordpress.com/1417/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/purexml.wordpress.com/1417/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/purexml.wordpress.com/1417/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/purexml.wordpress.com/1417/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/purexml.wordpress.com/1417/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/purexml.wordpress.com/1417/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/purexml.wordpress.com/1417/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/purexml.wordpress.com/1417/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nativexmldatabase.com&#038;blog=3215007&#038;post=1417&#038;subd=purexml&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nativexmldatabase.com/2012/02/29/what-is-an-xml-schema-and-why-should-i-care/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0fa2a8696cf3869ab2ded9243422d875?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matthias</media:title>
		</media:content>
	</item>
		<item>
		<title>How to list the paths of all elements in an XML document?</title>
		<link>http://nativexmldatabase.com/2012/02/04/how-to-list-the-paths-of-all-elements-in-an-xml-document/</link>
		<comments>http://nativexmldatabase.com/2012/02/04/how-to-list-the-paths-of-all-elements-in-an-xml-document/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 21:35:32 +0000</pubDate>
		<dc:creator>Matthias Nicola</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nativexmldatabase.com/?p=1408</guid>
		<description><![CDATA[A common question is how to obtain a list of all the elements and attributes that occur in an XML document. Producing such a list is what I call &#8220;XML profiling&#8221; and in a previous blog post I have discussed several SQL/XML queries that can do this. An extension of this question is how to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nativexmldatabase.com&#038;blog=3215007&#038;post=1408&#038;subd=purexml&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A common question is how to obtain a list of all the elements and attributes that occur in an XML document. Producing such a list is what I call &#8220;XML profiling&#8221; and in a <a href="http://nativexmldatabase.com/2010/05/26/xml-profiling-how-to-get-a-list-of-all-elements-and-attributes/">previous blog post</a> I have discussed several SQL/XML queries that can do this.</p>
<p>An extension of this question is how to get the paths of all the elements and attributes in a document. This seemingly simple task is -unfortunately- not nearly as simple as one would think! XPath and XQuery do not have a function that takes a given element or attribute as input and returns the full path to that node.</p>
<p>The solution is to write a query that traverses the XML document level by level to collect the element names at every level and concatenate them appropriately to construct the paths for every elements and attributes at every level.</p>
<p>There are many ways in which this can be done. You can use XQuery or SQL/XML and you can choose whether to use recursion or not. Let&#8217;s look at a few examples.</p>
<p>First, let&#8217;s create a simple table with a small document that we can use in the examples:</p>
<p><pre class="brush: sql;">
create table mytable(xmldoc XML);

insert into mytable values(
'&lt;Message&gt;
   &lt;Type&gt;Urgent&lt;/Type&gt;
   &lt;Person id =&quot;123&quot;&gt;
     &lt;FirstName&gt;Robert&lt;/FirstName&gt;
     &lt;LastName&gt;Tester&lt;/LastName&gt;
   &lt;/Person&gt;
 &lt;/Message&gt;');
</pre></p>
<p>A first and straightforward solution is to start at the root of the document, then at the first level of child nodes, and then at the children of each these child nodes, and so on. For each element or attribute we construct the path by concatenating the path from the parent with the name of the element or attribute. We do this for all nodes at a given level in the tree and then move to the next level of the document.:</p>
<p><pre class="brush: sql;">
xquery
for $L1 in db2-fn:xmlcolumn(&quot;MYTABLE.XMLDOC&quot;)/*
let $L1path := fn:string-join( ($L1/local-name() ),&quot;/&quot; )
return (
  $L1path,
  for $L2 in $L1/(*,@*)
  let $L2path := fn:string-join( ($L1path, $L2/local-name() ),&quot;/&quot; )
  return (
    $L2path,
    for $L3 in $L2/(*,@*)
    let $L3path := fn:string-join( ($L2path, $L3/local-name() ),&quot;/&quot; )
    return (

    $L3path,
    for $L4 in $L3/(*,@*)
    let $L4path := fn:string-join( ($L3path, $L4/local-name() ),&quot;/&quot; )
    return (

    $L4path,
    for $L5 in $L4/(*,@*)
    let $L5path := fn:string-join( ($L4path, $L5/local-name() ),&quot;/&quot; )
    return ($L5path)))));

Message
Message/Type
Message/Person
Message/Person/id
Message/Person/FirstName
Message/Person/LastName

6 record(s) selected.
</pre></p>
<p>The obvious shortcoming of this query is that it assumes a maximum of 5 levels in the document. If your documents are deeper than this, you can easily extend the query so that it goes down to 10 or 20 levels, whatever you need. That&#8217;s maybe not very elegant, but it works if you can define an upper bound on the depths of your XML documents, which is usually possible.</p>
<p>You probably notice that the path <strong>Message/Person/id</strong> should actually be <strong>Message/Person/@id</strong> because &#8220;id&#8221; is an XML attribute. The query can enhanced to take care of such details. In the last two sample queries of my <a href="http://nativexmldatabase.com/2010/05/26/xml-profiling-how-to-get-a-list-of-all-elements-and-attributes/">XML profiling post</a> you have seen how to use the <code>self::attribute()</code> test for this purpose.</p>
<p>If you prefer a more elegant solution that does not require any assumption about the maximum depths of the XML documents, then you need to code a recursive query, either in XQuery or in SQL/XML. Let&#8217;s try SQL/XML for a change.</p>
<p>You may already be familiar with how recursive SQL works. If not, you can look at <a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.sql.ref.doc/doc/r0000879.html">several existing examples</a>. The basic idea is to use a WITH clause, also called &#8220;common table expression&#8221;, that contains a UNION ALL between the start of the processing and a recursive reference back to the common table expression itself. The following  augments this approach with the XMLTABLE function that extracts nodes and node names from the XML:</p>
<p><pre class="brush: sql;">
WITH pathstable (name, node, xpath) AS (
  SELECT x.name AS name, x.node AS xmlnode,'/' || x.name AS xpath
  FROM mytable,
       XMLTABLE('$XMLDOC/*'
        COLUMNS
          name    varchar(30) PATH './local-name()',
          node    XML         PATH '.') AS x
  UNION ALL
  SELECT y.name AS name, y.node AS xmlnode, xpath|| '/' || y.name AS xpath
  FROM pathstable,
       XMLTABLE('$XMLNODE/(*,@*)' PASSING pathstable.node AS &quot;XMLNODE&quot;
        COLUMNS
         name    varchar(30) PATH 'local-name()',
         node    XML         PATH '.') AS y
) SELECT name, xpath
  FROM pathstable;

NAME                           XPATH
------------------------------ -------------------------------
Message                        /Message
Type                           /Message/Type
Person                         /Message/Person
id                             /Message/Person/id
FirstName                      /Message/Person/FirstName
LastName                       /Message/Person/LastName

6 record(s) selected
</pre></p>
<p>If you want to list the element and attribute values for each path, then you can easily modify this query as follows:</p>
<p><pre class="brush: sql;">
WITH pathstable (name, node, xpath, value) AS (
  SELECT x.name AS name, x.node AS xmlnode,
         '/' || x.name AS xpath, x.value as value
  FROM mytable,
       XMLTABLE('$XMLDOC/*'
        COLUMNS
          name    varchar(30) PATH './local-name()',
          value   varchar(20) PATH 'xs:string(.)',
          xmlnode XML         PATH '.') AS x
  UNION ALL
  SELECT y.name AS name, y.node AS xmlnode,
         xpath|| '/' || y.name AS xpath, y.value as value
  FROM pathstable,
       XMLTABLE('$XMLNODE/(*,@*)' PASSING pathstable.node AS &quot;XMLNODE&quot;
        COLUMNS
          name    varchar(30) PATH 'local-name()',
          value   varchar(20) PATH 'xs:string(.)',
          xmlnode XML         PATH '.') AS y
) SELECT xpath, value
  FROM pathstable;

XPATH                           VALUE
------------------------------- --------------------
/Message                        UrgentRobertTester
/Message/Type                   Urgent
/Message/Person                 RobertTester
/Message/Person/id              123
/Message/Person/FirstName       Robert
/Message/Person/LastName        Tester

6 record(s) selected
</pre></p>
<p>A few things to note:</p>
<ul>
<li>The value of an XML element is defined at the concatenation of all text nodes in the subtree under that element. This explains the values that you see for /Message and /Message/Person in the example above.</li>
<li>For longer paths you may need to increase the length of the VARCHAR(n) in the XMLTABLE function.</li>
<li>In DB2 you may receive warning SQL0347W, which says that this query might recursively run into an infinite loop. But, this would only happen if your XML document was infinitely deep, which isn&#8217;t possible. So, you can safely ignore that warning.</li>
</ul>
<p>&nbsp;</p>
<pre></pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/purexml.wordpress.com/1408/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/purexml.wordpress.com/1408/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/purexml.wordpress.com/1408/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/purexml.wordpress.com/1408/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/purexml.wordpress.com/1408/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/purexml.wordpress.com/1408/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/purexml.wordpress.com/1408/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/purexml.wordpress.com/1408/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/purexml.wordpress.com/1408/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/purexml.wordpress.com/1408/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/purexml.wordpress.com/1408/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/purexml.wordpress.com/1408/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/purexml.wordpress.com/1408/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/purexml.wordpress.com/1408/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nativexmldatabase.com&#038;blog=3215007&#038;post=1408&#038;subd=purexml&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nativexmldatabase.com/2012/02/04/how-to-list-the-paths-of-all-elements-in-an-xml-document/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0fa2a8696cf3869ab2ded9243422d875?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matthias</media:title>
		</media:content>
	</item>
		<item>
		<title>Business Records in the 21st Century</title>
		<link>http://nativexmldatabase.com/2012/01/21/business-records-in-the-21st-century/</link>
		<comments>http://nativexmldatabase.com/2012/01/21/business-records-in-the-21st-century/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 16:46:08 +0000</pubDate>
		<dc:creator>Matthias Nicola</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nativexmldatabase.com/?p=1402</guid>
		<description><![CDATA[Part 2 of our article &#8220;Data normalization reconsidered&#8221; is now available at http://www.ibm.com/developerworks/data/library/techarticle/dm-1201normalizationpart2/index.html The second part discusses alternatives to a traditional normalized relational representation of data. Such alternatives include for example XML, JSON, and RDF because they can often help you overcome normalization issues or improve schema flexibility, or both. In the 21st century, digitized [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nativexmldatabase.com&#038;blog=3215007&#038;post=1402&#038;subd=purexml&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Part 2 of our article &#8220;Data normalization reconsidered&#8221; is now available at</p>
<p><a href="http://www.ibm.com/developerworks/data/library/techarticle/dm-1201normalizationpart2/index.html">http://www.ibm.com/developerworks/data/library/techarticle/dm-1201normalizationpart2/index.html</a></p>
<p>The second part discusses alternatives to a traditional normalized relational representation of data. Such alternatives include for example XML, JSON, and RDF because they can often help you overcome normalization issues or improve schema flexibility, or both. In the 21st century, digitized business records are often created in XML to begin with, which makes XML an attractive choice as the database level storage format.</p>
<p>This article also contains a performance comparison between XML and relational data that was conducted for a real-world application scenario at a major international logistics company.</p>
<p>At the end of the article you find comparison tables that summarize the pros and cons of different data representations.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/purexml.wordpress.com/1402/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/purexml.wordpress.com/1402/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/purexml.wordpress.com/1402/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/purexml.wordpress.com/1402/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/purexml.wordpress.com/1402/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/purexml.wordpress.com/1402/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/purexml.wordpress.com/1402/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/purexml.wordpress.com/1402/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/purexml.wordpress.com/1402/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/purexml.wordpress.com/1402/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/purexml.wordpress.com/1402/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/purexml.wordpress.com/1402/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/purexml.wordpress.com/1402/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/purexml.wordpress.com/1402/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nativexmldatabase.com&#038;blog=3215007&#038;post=1402&#038;subd=purexml&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nativexmldatabase.com/2012/01/21/business-records-in-the-21st-century/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0fa2a8696cf3869ab2ded9243422d875?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matthias</media:title>
		</media:content>
	</item>
		<item>
		<title>Data Normalization Reconsidered</title>
		<link>http://nativexmldatabase.com/2012/01/08/data-normalization-reconsidered/</link>
		<comments>http://nativexmldatabase.com/2012/01/08/data-normalization-reconsidered/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 03:52:21 +0000</pubDate>
		<dc:creator>Matthias Nicola</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nativexmldatabase.com/?p=1396</guid>
		<description><![CDATA[Normalization is a design methodology for relational database schemas and aims to minimize data redundancy and avoid data anomalies, such as update anomalies. The consequence of normalization is that business records (such as a purchase order, an insurance claim, a financial transaction, etc.) are split into pieces that are scattered over potentially many relational tables. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nativexmldatabase.com&#038;blog=3215007&#038;post=1396&#038;subd=purexml&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Normalization is a design methodology for relational database schemas and aims to minimize data redundancy and avoid data anomalies, such as update anomalies. The consequence of normalization is that business records (such as a purchase order, an insurance claim, a financial transaction, etc.) are split into pieces that are scattered over potentially many relational tables.</p>
<p>In addition to its benefits, normalization also introduces several drawbacks:</p>
<ul>
<li>The insert of a single logical business record requires the insertion of multiple (often many) physical rows</li>
<li>The retrieval of a single business record requires complex multi-way joins or a series of separate queries</li>
<li>Business records undergo a potentially expensive conversion from their original representation outside the database to a normalized format and back</li>
<li>The normalized representation of business records is often difficult to understand because it is very different from the original format of the business record, such as a paper form or an XML message.</li>
</ul>
<p>These issues raise the question whether normalization should be applied as categorically as some people believe. Indeed, there are several reasons for reconsidering normalization, such as:</p>
<ul>
<li>Throughout history, humans have always stored their business records &#8220;intact&#8221;, and it was only the introduction of databases that has &#8220;required&#8221; normalization</li>
<li>Normalization was introduced when storage space was extremely scarce and expensive, which is not (or much less) the case anymore today</li>
<li>Today, business records are often much more complex than they used to be in the 1970s when normalization was introduced, and this complexity amplifies the disadvantages of normalization</li>
<li>De-normalization is becoming more and more popular, e.g. in star schemas for data warehousing, but also in emerging storage systems such as HBase, Google&#8217;s BigTable, etc.</li>
</ul>
<p>Today, business records are often created and exchanged in a digital format, and this format is often XML. XML is a non-normalized data format that can provide several benefits:</p>
<ul>
<li>A single business record often maps naturally to a single XML document</li>
<li>A single business record/XML document can be inserted (and retrieved) in an XML database as a single operation</li>
<li>If you store XML as XML (i.e. without conversion to relational), the representation of a business record is the same inside and outside the database, which is tremendously valuable</li>
</ul>
<p>When business records already exist in XML format outside the database anyway, then it is usually best to also store them as XML and not to convert into a normalized relational schema.</p>
<p>My colleague Susan Malaika and I have collected our thoughts and observations on normalization in a 2-part article titled &#8220;<a href="http://www.ibm.com/developerworks/data/library/techarticle/dm-1112normalization/index.html"><strong>Data Normalization Reconsidered</strong></a>&#8220;. The first part has recently been published on developerWorks and can be found here:</p>
<p><a href="http://www.ibm.com/developerworks/data/library/techarticle/dm-1112normalization/index.html">http://www.ibm.com/developerworks/data/library/techarticle/dm-1112normalization/index.html</a></p>
<p>The 2nd part will appear soon. Happy reading!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/purexml.wordpress.com/1396/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/purexml.wordpress.com/1396/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/purexml.wordpress.com/1396/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/purexml.wordpress.com/1396/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/purexml.wordpress.com/1396/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/purexml.wordpress.com/1396/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/purexml.wordpress.com/1396/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/purexml.wordpress.com/1396/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/purexml.wordpress.com/1396/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/purexml.wordpress.com/1396/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/purexml.wordpress.com/1396/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/purexml.wordpress.com/1396/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/purexml.wordpress.com/1396/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/purexml.wordpress.com/1396/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nativexmldatabase.com&#038;blog=3215007&#038;post=1396&#038;subd=purexml&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nativexmldatabase.com/2012/01/08/data-normalization-reconsidered/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0fa2a8696cf3869ab2ded9243422d875?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matthias</media:title>
		</media:content>
	</item>
		<item>
		<title>XQuery support in DB2 10 for z/OS</title>
		<link>http://nativexmldatabase.com/2011/11/30/xquery-support-in-db2-10-for-zos/</link>
		<comments>http://nativexmldatabase.com/2011/11/30/xquery-support-in-db2-10-for-zos/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 06:13:58 +0000</pubDate>
		<dc:creator>Matthias Nicola</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nativexmldatabase.com/?p=1374</guid>
		<description><![CDATA[If you think that mainframe computers are old dinosaurs that only run ancient COBOL code &#8211; think again! Now mainframes also run XQuery! While DB2 for Linux, UNIX, and Windows has been supporting XQuery and SQL/XML since Version 9.1 (released in 2006), DB2 9 for z/OS &#8220;only&#8221; supported XPath and SQL/XML. I have put the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nativexmldatabase.com&#038;blog=3215007&#038;post=1374&#038;subd=purexml&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you think that mainframe computers are old dinosaurs that only run ancient COBOL code &#8211; think again! Now mainframes also run XQuery!</p>
<p>While <a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.xml.doc/doc/xqrcontainer.html">DB2 for Linux, UNIX, and Windows</a> has been supporting XQuery and <a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.xml.doc/doc/c0023896.html">SQL/XML</a> since Version 9.1 (released in 2006), DB2 9 for z/OS &#8220;only&#8221; supported XPath and SQL/XML.</p>
<p>I have put the word &#8220;only&#8221; in quotes because for many applications XPath and SQL/XML are fully sufficient. When you combine XPath expressions with SQL/XML functions such as <a href="http://www.ibm.com/developerworks/data/library/techarticle/dm-0708nicola/">XMLTABLE</a> plus other SQL language constructs you can write <em>very</em> powerful XML queries and accomplish many of the same things that you can do with XQuery.</p>
<p>DB2 10 for z/OS has added a variety of <a href="http://nativexmldatabase.com/2010/11/18/new-xml-features-in-db2-10-for-zos/">new XML features</a> such as node-level XML updates, XML-type parameters and variables in stored procedures and user-defined functions, and enhancements for XML Schemas and XML indexes.</p>
<p>With APARs PM47617 and PM47618, DB2 for z/OS now also supports XQuery within the SQL functions XMLTABLE, XMLQUERY, XMLEXISTS, and XMLMODIFY.</p>
<p>So what are the additional capabilities and benefits that XQuery provides? Examples include:</p>
<ul>
<li>You can compose new XML structures using direct element constructors</li>
<li>You can use FLWOR expressions (for-let-where-order by-return) to iterate over and manipulate intermediate query results</li>
<li>You can join and combine information from multiple XML documents</li>
<li>You can use XQuery comma-expressions to construct and use new sequences of XML nodes</li>
<li>You can code if-then-else logic to implement conditional expressions</li>
<li>etc.</li>
</ul>
<p>Let&#8217;s look at some examples.</p>
<p><strong>Construct new XML structures with direct element and attribute constructors</strong></p>
<p>The following query constructs a new order summary document from each order (XML document) that is selected from the &#8220;orders&#8221; table. New elements, such as &lt;orderSummary&gt; and &lt;orderedItems&gt; are constructed by providing the start and end tags explicitly. Similarly, the attribute orderNumber is also constructed explicitly. The content of the constructed elements and attributes is computed by XPath (or XQuery) expressions that extract selected information from each source document.</p>
<p><pre class="brush: sql;">
SELECT XMLQUERY('
          &lt;orderSummary orderNumber=&quot;{$po/order/orderNo/text()}&quot;&gt;
             &lt;orderedItems&gt;{$o/order/items/item/itemName}&lt;/orderedItems&gt;
          &lt;/orderSummary&gt;'
       PASSING orders.orderdoc AS &quot;po&quot;)
FROM orders
WHERE ...
</pre></p>
<p><strong>FLWOR expressions</strong></p>
<p>The next query joins the tables &#8220;orders&#8221; and &#8220;items&#8221; on their XML columns &#8220;orderdoc&#8221; and &#8220;details&#8221;, respectively. The join predicate in the XMLEXISTS ensures that we find the items that match a given order and that we don&#8217;t produce a Cartesian product. For each pair of order document and item document, the FLWOR expression in the SELECT clause combines information from both documents into a new documents that contains the item name, the ordered quantity, and the item details.</p>
<p><pre class="brush: sql;">
SELECT XMLQUERY('for $o in $po/orders/items/item
                   for $i in $it/item
                 where $o/itemName = $i/name
                 return &lt;orderdItem&gt;
                           {$i/name}
                           {$o/item/quantity}
                           {$i/details}
                        &lt;/orderdItem&gt;'
         PASSING orders.orderdoc AS &quot;po&quot;, items.details as &quot;it&quot;)
FROM orders, items
WHERE
XMLEXISTS('$po/order/items/item[itemName = $it/item/name]'
           PASSING orders.orderdoc AS &quot;po&quot;, items.details as &quot;it&quot;)
</pre></p>
<p>&nbsp;</p>
<p>For more information on XQuery in DB2 10 for z/OS, here is a good place to continue reading:</p>
<p><a href="http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/topic/com.ibm.db2z10.doc.xml/src/tpc/db2z_expover.htm">http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/topic/com.ibm.db2z10.doc.xml/src/tpc/db2z_expover.htm</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/purexml.wordpress.com/1374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/purexml.wordpress.com/1374/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/purexml.wordpress.com/1374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/purexml.wordpress.com/1374/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/purexml.wordpress.com/1374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/purexml.wordpress.com/1374/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/purexml.wordpress.com/1374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/purexml.wordpress.com/1374/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/purexml.wordpress.com/1374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/purexml.wordpress.com/1374/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/purexml.wordpress.com/1374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/purexml.wordpress.com/1374/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/purexml.wordpress.com/1374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/purexml.wordpress.com/1374/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nativexmldatabase.com&#038;blog=3215007&#038;post=1374&#038;subd=purexml&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nativexmldatabase.com/2011/11/30/xquery-support-in-db2-10-for-zos/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0fa2a8696cf3869ab2ded9243422d875?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matthias</media:title>
		</media:content>
	</item>
		<item>
		<title>TPoX 2.1 has been released!</title>
		<link>http://nativexmldatabase.com/2011/11/15/tpox-2-1-has-been-released/</link>
		<comments>http://nativexmldatabase.com/2011/11/15/tpox-2-1-has-been-released/#comments</comments>
		<pubDate>Wed, 16 Nov 2011 02:57:44 +0000</pubDate>
		<dc:creator>Matthias Nicola</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nativexmldatabase.com/?p=1358</guid>
		<description><![CDATA[First, what is TPoX?  I have two answers to that question. Answer 1: TPoX, short for &#8220;Transaction Processing over XML&#8221;, is an XML database benchmark that executes and measures a multi-user XML workload. The workload contains XML queries (70%) as well as XML insert, update, and delete operations (30%). TPoX simulates a simple financial application [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nativexmldatabase.com&#038;blog=3215007&#038;post=1358&#038;subd=purexml&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>First, what is TPoX?  I have two answers to that question.</p>
<p><span style="text-decoration:underline;"><strong>Answer 1:</strong></span></p>
<p><a href="http://tpox.sourceforge.net/">TPoX</a>, short for &#8220;Transaction Processing over XML&#8221;, is an XML database benchmark that executes and measures a multi-user XML workload. The workload contains XML queries (70%) as well as XML insert, update, and delete operations (30%). TPoX simulates a simple financial application that issues XQuery or SQL/XML transactions to stress XML storage, XML indexing, XML Schema support, XML updates, logging, concurrency and other components of an XML database system.</p>
<p>The <a href="http://sourceforge.net/projects/tpox/files/tpox/v2.1/">TPoX package</a> contains:</p>
<ul>
<li>an <a href="http://tpox.svn.sourceforge.net/viewvc/*checkout*/tpox/TPoX/documentation/TPoX_DataGeneration_v2.1.pdf">XML data generator</a></li>
<li>an extensible <a href="http://tpox.svn.sourceforge.net/viewvc/tpox/TPoX21/documentation/WorkloadDriverUsage_v2.1.pdf">Workload Driver</a>, written in Java</li>
<li>three <a href="http://tpox.sourceforge.net/tpoxdata.htm">XML Schemas</a> that define the XML structures</li>
<li>a set of <a href="http://tpox.svn.sourceforge.net/viewvc/*checkout*/tpox/TPoX/documentation/TPoX_BenchmarkProposal_v2.1.pdf">predefined transactions</a>, which can be changed easily</li>
</ul>
<p>TPoX has been developed by Intel and IBM, but is freely available and <a href="http://sourceforge.net/projects/tpox/">open source</a> since 2007. A variety of TPoX <a href="http://tpox.sourceforge.net/tpoxresults.htm">performance results</a> and <a href="http://tpox.sourceforge.net/tpoxresults.htm#Other_TPoX_Usage">other usage of TPoX</a> have been reported.</p>
<p><span style="text-decoration:underline;"><strong>Answer 2:</strong></span></p>
<p>TPoX is a very flexible and extensible tool for performance testing of relational databases, XML databases, and other systems. For example, if you have a populated relational database you can use the TPoX workload driver to parameterize, execute, and measure plain old SQL transactions with hundreds of simulated database users. I have used TPoX for a lot of relational performance testing, because it’s so easy to setup and measure concurrent workloads. The workload driver reports throughput, min/ax/avg response times, percentiles and confidence intervals for response times, and other useful metrics. Oh, and by the way, TPoX happens to include an XML data generator and a set of sample XML transactions, in case you&#8217;re interested in XML database performance.</p>
<p>&nbsp;</p>
<p>In the latest release, <strong>TPoX 2.1</strong>, we have further enhanced the extensibility of the TPoX Workload Driver. The XML data and XML transactions are still the same.</p>
<p>Some of the enhancements in TPoX 2.1 include:</p>
<ul>
<li>higher precision in reported response times</li>
<li>proper handling and counting of deadlocks, if any</li>
<li>easier post-processing of results in Excel or other spreadsheets software</li>
<li>new types of workload parameters such as random dates, random timestamps, sequences, etc.</li>
<li>in addition to SQL, SQL/XML, and XQuery, transactions can now be also supplied as <strong>Java plugins</strong>, allowing you to run and measure anything (concurrently!) that you can code in Java, such as:</li>
</ul>
<blockquote>
<ul>
<li>complex transactions that include application logic</li>
<li>calls to <strong>web services</strong> or <strong>message queues</strong></li>
<li>obtaining data from <strong>RSS</strong> or <strong>ATOM</strong> feeds</li>
<li>transactions against databases or <strong>content repositories</strong> that do not have a JDBC interface</li>
</ul>
</blockquote>
<p>We have already found these extensions extremely valuable for some of our own performance testing, and we&#8217;re happy to share them. You can <a href="http://sourceforge.net/projects/tpox/files/tpox/v2.1/">download TPoX 2.1</a> (free, open source) and find more detailed information in the release notes as well as the TPoX documentation that is included in the download.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/purexml.wordpress.com/1358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/purexml.wordpress.com/1358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/purexml.wordpress.com/1358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/purexml.wordpress.com/1358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/purexml.wordpress.com/1358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/purexml.wordpress.com/1358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/purexml.wordpress.com/1358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/purexml.wordpress.com/1358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/purexml.wordpress.com/1358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/purexml.wordpress.com/1358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/purexml.wordpress.com/1358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/purexml.wordpress.com/1358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/purexml.wordpress.com/1358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/purexml.wordpress.com/1358/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nativexmldatabase.com&#038;blog=3215007&#038;post=1358&#038;subd=purexml&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nativexmldatabase.com/2011/11/15/tpox-2-1-has-been-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0fa2a8696cf3869ab2ded9243422d875?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matthias</media:title>
		</media:content>
	</item>
		<item>
		<title>XML in Las Vegas !</title>
		<link>http://nativexmldatabase.com/2011/10/18/xml-in-las-vegas/</link>
		<comments>http://nativexmldatabase.com/2011/10/18/xml-in-las-vegas/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 22:33:55 +0000</pubDate>
		<dc:creator>Matthias Nicola</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nativexmldatabase.com/?p=1349</guid>
		<description><![CDATA[The annual Information on Demand conference in Las Vegas (Oct 23-27, 2011) is always a great venue to get updated on the latest topics in data management. The IOD conference offers a broad range of technical sessions, business sessions, hands-on labs, and lots of networking opportunities. More than 200 customer speakers will present their first-hand [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nativexmldatabase.com&#038;blog=3215007&#038;post=1349&#038;subd=purexml&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The annual <a href="http://www-01.ibm.com/software/data/2011-conference/">Information on Demand conference</a> in Las Vegas (Oct 23-27, 2011) is always a great venue to get updated on the latest topics in data management. The IOD conference offers a broad range of technical sessions, business sessions, hands-on labs, and lots of networking opportunities. More than <a href="http://www-01.ibm.com/software/data/2011-conference/2011-customer-speakers.html">200 customer speakers </a>will present their first-hand experiences with IBM Software.</p>
<p>The conference is in the Mandalay Bay conventation center. Various topics around DB2 pureXML are covered in presentations and hands-on labs. Some of them are listed here:</p>
<p><span style="color:#333399;">2088A &#8211; DB2 pureXML for Beginners</span><br />
<span style="color:#333399;">Mon, Oct 24, 2011, 3:45 PM &#8211; 5:00 PM</span></p>
<p><span style="color:#333399;">1120B &#8211; DB2 pureXML: Develop Your Application Prototype in Minutes, not Days</span><br />
<span style="color:#333399;">Tue, Oct 25, 2011, 9:45 AM &#8211; 12:45 PM (hands-on lab)</span></p>
<p><span style="color:#333399;">1930A &#8211; DB2 for z/OS SOA Solutions Powered by pureXML and DataPower</span><br />
<span style="color:#333399;">Wed, Oct 26, 2011, 3:15 PM &#8211; 4:15 PM</span></p>
<p><span style="color:#333399;">2691A &#8211; Architecting with IBM pureXML and Temporal Data in DB2 10 for z/OS</span><br />
<span style="color:#333399;">Thu, Oct 27, 2011, 8:15 AM &#8211; 9:30 AM </span></p>
<p><span style="color:#333399;">2087B &#8211; Get Connected: Publishing Relational Data as XML Messages</span><br />
<span style="color:#333399;">Thu, Oct 27, 2011, 3:30 PM &#8211; 4:30 PM</span></p>
<p>If you&#8217;re going to IOD, don&#8217;t miss these sessions!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/purexml.wordpress.com/1349/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/purexml.wordpress.com/1349/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/purexml.wordpress.com/1349/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/purexml.wordpress.com/1349/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/purexml.wordpress.com/1349/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/purexml.wordpress.com/1349/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/purexml.wordpress.com/1349/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/purexml.wordpress.com/1349/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/purexml.wordpress.com/1349/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/purexml.wordpress.com/1349/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/purexml.wordpress.com/1349/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/purexml.wordpress.com/1349/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/purexml.wordpress.com/1349/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/purexml.wordpress.com/1349/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nativexmldatabase.com&#038;blog=3215007&#038;post=1349&#038;subd=purexml&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nativexmldatabase.com/2011/10/18/xml-in-las-vegas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0fa2a8696cf3869ab2ded9243422d875?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matthias</media:title>
		</media:content>
	</item>
		<item>
		<title>Advanced SQL/XML: Joins and FLWOR Expressions in the XMLTABLE Function</title>
		<link>http://nativexmldatabase.com/2011/10/09/advanced-sqlxml-joins-and-flwor-expressions-in-the-xmltable-function/</link>
		<comments>http://nativexmldatabase.com/2011/10/09/advanced-sqlxml-joins-and-flwor-expressions-in-the-xmltable-function/#comments</comments>
		<pubDate>Mon, 10 Oct 2011 03:23:31 +0000</pubDate>
		<dc:creator>Matthias Nicola</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nativexmldatabase.com/?p=1336</guid>
		<description><![CDATA[If you look at existing documentation and examples of the XMLTABLE function, you find that most examples use simple XPath expressions inside the XMLTABLE function and rarely more complex XQuery expressions such as FLWOR expressions. This is also true for my 2 articles on XMLTABLE: XMLTABLE By Example, Part1 and Part2: http://www.ibm.com/developerworks/data/library/techarticle/dm-0708nicola/ http://www.ibm.com/developerworks/data/library/techarticle/dm-0709nicola/ Why is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nativexmldatabase.com&#038;blog=3215007&#038;post=1336&#038;subd=purexml&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you look at existing documentation and examples of the XMLTABLE function, you find that most examples use simple XPath expressions inside the XMLTABLE function and rarely more complex XQuery expressions such as FLWOR expressions. This is also true for my 2 articles on XMLTABLE:</p>
<p>XMLTABLE By Example, Part1 and Part2:<br />
<a href="http://www.ibm.com/developerworks/data/library/techarticle/dm-0708nicola/">http://www.ibm.com/developerworks/data/library/techarticle/dm-0708nicola/</a><br />
<a href="http://www.ibm.com/developerworks/data/library/techarticle/dm-0709nicola/">http://www.ibm.com/developerworks/data/library/techarticle/dm-0709nicola/</a></p>
<p>Why is that? Is it because XQuery expressions other than plain path expressions are never required in the XMLTABLE function? Well, let&#8217;s take a look at that question&#8230;</p>
<p>First, I do believe that many typical SQL/XML queries can indeed be coded with just regular XPath in the XMLTABLE function. I have seen that this is true in many real application deployments.</p>
<p>But, sometimes it can certainly be useful to embed more complex XQuery expressions than just XPath in an XMLTABLE function. For example, in my blog post &#8220;<a href="http://nativexmldatabase.com/2010/05/26/xml-profiling-how-to-get-a-list-of-all-elements-and-attributes/">How to get a list of all elements and attributes</a>&#8221; you saw that I used the XQuery <a href="http://www.w3.org/TR/xquery/#dt-comma-operator">comma operator</a> to construct a sequence from two expressions. In that case the comma expression was //(*,@*) to get all elements and all attributes. In the same post you also saw the use of the XQuery <a href="http://www.w3.org/TR/xquery/#id-conditionals">if-then-else</a> expression in the column definition of the XMLTABLE function.</p>
<p>Using FLWOR expression in the XMLTABLE function can be useful if you join and combine XML from two different XML columns. For example let&#8217;s consider the following two tables with te subsequent sample documents:</p>
<p><pre class="brush: sql;">

CREATE TABLE order(orderdetails XML);
CREATE TABLE product(description XML);

INSERT INTO order VALUES('
&lt;order&gt;
  &lt;orderNo&gt;123&lt;/orderNo&gt;
  &lt;item&gt;
    &lt;pid&gt;24TX98&lt;/pid&gt;
    &lt;quantity&gt;1&lt;/quantity&gt;
    &lt;price&gt;29.95&lt;/price&gt;
  &lt;/item&gt; 
  &lt;item&gt;
    &lt;pid&gt;901V8&lt;/pid&gt;
    &lt;quantity&gt;2&lt;/quantity&gt;
    &lt;price&gt;5.00&lt;/price&gt;
  &lt;/item&gt; 
&lt;/order&gt;');

INSERT INTO product VALUES('
&lt;product pid=&quot;24TX98&quot;&gt;
  &lt;name&gt;Outdoor paint&lt;/name&gt;
  &lt;description&gt;
    &lt;weight&gt;3kg&lt;/weight&gt;
    &lt;color&gt;white&lt;/color&gt;
  &lt;/description&gt;   
&lt;/product&gt;');

INSERT INTO product VALUES('
&lt;product pid=&quot;901V8&quot;&gt;
  &lt;name&gt;Paint brush&lt;/name&gt;
  &lt;description&gt;
    &lt;weight&gt;0.1kg&lt;/weight&gt;
  &lt;/description&gt;   
&lt;/product&gt;');

</pre></p>
<p>The order table contains one XML document per order, and the product table one XML document per product. Each product has a @pid attribute as a unique identifier, and  orders have /order/item/pid elements to specify which products have been ordered. Naturally, this allows us to perform a join between orders and products.</p>
<p>For example, the following query is a join to retrieve the product information for all the products that have been ordered in order 123:</p>
<p><pre class="brush: sql;">

SELECT product.description
FROM order, product
WHERE XMLEXISTS('$ORDERDETAILS/order[orderNo = 123]')
  AND XMLEXISTS('$DESCRIPTION/product[ @pid/fn:string(.) =
                   $ORDERDETAILS/order/item/pid/fn:string(.) ]');

</pre></p>
<p>This query returns one row (one XML document) for each product that is referenced in order 123.</p>
<p>Now, what if you want to combine data from an order document and the associated product documents, and return this information in one relational row per product?  For example, assume you want rows that show the product ID and product weight (from the product documents) as well as the price and quantity of that product in the order document.</p>
<p>In that case you could use an XQuery FLWOR expression to perform the join and combine the product and order information in the XMLTABLE function, as shown in the following query.</p>
<p>Since the product and order tables appear in the FROM clause of the query, the FLWOR expression references their XML columns through the variables $DESCRIPTION and $ORDERDETAILS. The return clause of the FLWOR expression constructs XML fragments that combine the desired elements and attributes from each matching pair of product and order documents. The constructed &lt;result&gt; elements are then input to the COLUMNS clause where they are broken up into relational columns.</p>
<p><pre class="brush: sql;">

SELECT T.*
FROM order, product,
     XMLTABLE('for $o in $ORDERDETAILS/order[orderNo = 123]/item
                for $p in $DESCRIPTION/product
                where $p/@pid/fn:string(.) = $o/pid/fn:string(.)
                return
                    &lt;result&gt;
                        {$p/@pid}
                        {$p/description/weight}
                        {$o/quantity}
                        {$o/price}
                    &lt;/result&gt;'
         COLUMNS
             prodid VARCHAR(15)  PATH '@pid',
             weight VARCHAR(5)   PATH 'weight',
             qty    INTEGER      PATH 'quantity',
             price  DECIMAL(6,2) PATH 'price')
         AS T;

   
PRODID          WEIGHT QTY         PRICE
--------------- ------ ----------- --------
24TX98          3kg              1    29.95
901V8           0.1kg            2     5.00

  2 record(s) selected.

</pre></p>
<p>It is worthwhile noting that you can produce the same result set without the use of FLWOR expressions, as shown in the next query. This query uses two XMLTABLE function, one for the desired order information and one for the desired product information. The key trick is that the two XMLTABLE function are joined on the product ID using the predicate [@pid = $p]. Without this predicate the two XMLTABLE functions would produce a Cartesian product, which is not desired.</p>
<p><pre class="brush: sql;">

SELECT T2.prodid, T2.weight, T1.qty, T1.price
FROM order, product,
     XMLTABLE('$ORDERDETAILS/order/item'
        COLUMNS
           prodid VARCHAR(15)  PATH 'pid',
           qty    INTEGER      PATH 'quantity',
           price  DECIMAL(6,2) PATH 'price')
     AS T1,
     XMLTABLE('$DESCRIPTION/product[@pid = $p]'
                                  PASSING T1.prodid AS &quot;p&quot;
        COLUMNS
           prodid VARCHAR(15)  PATH '@pid',
           weight VARCHAR(5)   PATH 'description/weight')
     AS T2;

 
                  
PRODID          WEIGHT QTY         PRICE
--------------- ------ ----------- --------
24TX98          3kg              1    29.95
901V8           0.1kg            2     5.00

  2 record(s) selected.

</pre></p>
<p>The join predicate between the two XMLTABLE functions can also be placed in the SQL WHERE clause:</p>
<p><pre class="brush: sql;">

SELECT T2.prodid, T2.weight, T1.qty, T1.price
FROM order, product,
     XMLTABLE('$ORDERDETAILS/order/item'
        COLUMNS
           prodid VARCHAR(15)  PATH 'pid',
           qty    INTEGER      PATH 'quantity',
           price  DECIMAL(6,2) PATH 'price')
     AS T1,
     XMLTABLE('$DESCRIPTION/product'
        COLUMNS
           prodid VARCHAR(15)  PATH '@pid',
           weight VARCHAR(5)   PATH 'description/weight')
     AS T2
WHERE T1.prodid = T2.prodid;       

</pre></p>
<p>However, this query applies the join predicate <em>after</em> the XMLTABLE functions have produced their rows, which can be slower than the previous query where the predicate was in the XMLTABLE function itself.</p>
<p>You can find many more examples of the XMLTABLE function, XML joins, and joins between XML and relational columns in Chapter 9 of the <a href="http://tinyurl.com/pureXML">DB2 pureXML Cookbook</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/purexml.wordpress.com/1336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/purexml.wordpress.com/1336/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/purexml.wordpress.com/1336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/purexml.wordpress.com/1336/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/purexml.wordpress.com/1336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/purexml.wordpress.com/1336/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/purexml.wordpress.com/1336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/purexml.wordpress.com/1336/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/purexml.wordpress.com/1336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/purexml.wordpress.com/1336/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/purexml.wordpress.com/1336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/purexml.wordpress.com/1336/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/purexml.wordpress.com/1336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/purexml.wordpress.com/1336/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nativexmldatabase.com&#038;blog=3215007&#038;post=1336&#038;subd=purexml&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nativexmldatabase.com/2011/10/09/advanced-sqlxml-joins-and-flwor-expressions-in-the-xmltable-function/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0fa2a8696cf3869ab2ded9243422d875?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matthias</media:title>
		</media:content>
	</item>
		<item>
		<title>At your service: REST with DB2 pureXML!</title>
		<link>http://nativexmldatabase.com/2011/09/29/rest-with-db2-purexml/</link>
		<comments>http://nativexmldatabase.com/2011/09/29/rest-with-db2-purexml/#comments</comments>
		<pubDate>Fri, 30 Sep 2011 06:59:53 +0000</pubDate>
		<dc:creator>Matthias Nicola</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nativexmldatabase.com/?p=1321</guid>
		<description><![CDATA[Undeniably, XML is the message format of choice for many service-oriented architectures and application integration efforts. Also, many SOA and web service implementaions use REST as the protocol for accessing URL-addressable resources and services. REST stands for Representational State Transfer and is built on top of HTTP, which acts as the underlying transport layer. With [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nativexmldatabase.com&#038;blog=3215007&#038;post=1321&#038;subd=purexml&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Undeniably, XML is the message format of choice for many service-oriented architectures and application integration efforts. Also, many SOA and web service implementaions use REST as the protocol for accessing URL-addressable resources and services. REST stands for Representational State Transfer and is built on top of HTTP, which acts as the underlying transport layer.</p>
<p>With a new set user-defined functions (UDFs) in DB2, it has become very simple to issue REST requests directly from your SQL statements or DB2 stored procedures. This enables DB2 to easily interact with REST-based services and integrate information from the web or URL-based resources into the database.</p>
<p>The new REST UDFs allow you to receive and provide information in binary format (BLOB) or textual format (CLOB), which includes but is not limited to XML. The basic REST UDFs are scalar functions that perform the simple HTTP operations GET, POST, PUT, and DELETE. These UDFs are:</p>
<ul>
<li>DB2XML.HTTPGETCLOB</li>
<li>DB2XML.HTTPPOSTCLOB</li>
<li>DB2XML.HTTPPUTCLOB</li>
<li>DB2XML.HTTPDELETECLOB</li>
</ul>
<ul>
<li>DB2XML.HTTPGETBLOB</li>
<li>DB2XML.HTTPPOSTBLOB</li>
<li>DB2XML.HTTPPUTBLOB</li>
<li>DB2XML.HTTPDELETEBLOB</li>
</ul>
<p>Each of these functions take a URL and, optionally, an HTTP header as input paramaters. Additionally, the POST and PUT functions have a third parameter for the BLOB or CLOB data that you want to upload.</p>
<p>The REST UDFs are implemented in Java and support HTTP as well as HTTPS with SSL encryption.</p>
<p>When you use these UDFs in SQL statements to receive information, you can:</p>
<ul>
<li>insert the information into DB2 tables</li>
<li>use the information as a parameter to search for related data in DB2</li>
<li>join the information with existing data in DB2</li>
<li>process the information in a stored procedure</li>
<li>or use the information in any other way that SQL provides</li>
</ul>
<p>In particular, if the information is in XML format you can apply any DB2 pureXML functions to it, such as:</p>
<ul>
<li>the XMLQUERY function to extract pieces from the XML message</li>
<li>the XMLTABLE function to split the XML into smaller XML pieces</li>
<li>the XMLTABLE function to shred the XML into relational tables</li>
<li>the XMLVALIDATE function to validate the XML against an XML Schema</li>
<li>etc.</li>
</ul>
<p>If you are interested and want to try this for yourself, read the following article:<br />
<strong> &#8220;Accessing HTTP and RESTful services from DB2: Introducing the REST user-defined functions for DB2&#8243;</strong><br />
<a href="http://www.ibm.com/developerworks/data/library/techarticle/dm-1105httprestdb2/"> http://www.ibm.com/developerworks/data/library/techarticle/dm-1105httprestdb2/</a></p>
<p>This article describes the REST functions for DB2 in more detail and presents several concrete usage examples. The UDFs themselves are available for download at the bottom of this article.</p>
<p>Enjoy your REST !</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/purexml.wordpress.com/1321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/purexml.wordpress.com/1321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/purexml.wordpress.com/1321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/purexml.wordpress.com/1321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/purexml.wordpress.com/1321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/purexml.wordpress.com/1321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/purexml.wordpress.com/1321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/purexml.wordpress.com/1321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/purexml.wordpress.com/1321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/purexml.wordpress.com/1321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/purexml.wordpress.com/1321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/purexml.wordpress.com/1321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/purexml.wordpress.com/1321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/purexml.wordpress.com/1321/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nativexmldatabase.com&#038;blog=3215007&#038;post=1321&#038;subd=purexml&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nativexmldatabase.com/2011/09/29/rest-with-db2-purexml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0fa2a8696cf3869ab2ded9243422d875?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matthias</media:title>
		</media:content>
	</item>
	</channel>
</rss>
