Conditional Shredding in DBXL - David Airapetyan
in

InfoPath Dev

David Airapetyan

Conditional Shredding in DBXL

The DBXL shredding allows mapping the data fields of each saved document into a database table. But what if we do not want all data to be mapped? It turns out that one can leverage the power of XPath to create arbitrary conditions on when the shredding happens.

The way DBXL shredding works is as follows: first the mapping XPath is executed, then if it results in a nodeset it is inserted into the database. So in order to prevent shredding, simply provide an xpath that does not evaluate to a nodeset! To ensure that the entire document does not get shredded into a table based on some condition, set that condition on the very top xpath, the one that maps to the table.

Here is a specific example. Consider a very simple solution with two fields: "data" and a Boolean "shred" that specifies whether or not we want to shred the data for that particular document:



Assume a table named ConditionalShredding exists in the database, one that contains a docid column and a column for the data:



Usually, when mapping to this table, one would map /my:myFields to the ConditionalShredding table, DBXL::docId special value to the docId column and the my:data field to the data column. With conditional shredding, it's all the same, only you specify the condition on the root node:
/my:myFields[my:shred = 'true']
Now only documents which have my:shred set to true will shred into the ConditionalShredding database even though all documents will still be stored in DBXL! Here is a screenshot of the complete mapping for this example:


 


Note: if using a condition on the root node, the current version of DBXL can no longer detect that a child node is under the root path. This just means that you have to type all the column xpaths in manually. However, there is a trick to make this easier:
First, do all of your mapping as you would usually do it, and only then add the condition to the root node, as the very last step.

Comments

No Comments

About davidair

I am a Computer Science graduate from McGill University in Montreal, Canada. I have over seven years of industry experience including almost five of them spent with the Microsoft Corporation where I shipped several versions of Microsoft Office InfoPath. Originally from Russia, I am fluent in several languages, including Russian, English, French, C#, C++ and Perl. I currently reside in Montreal and work for Qdabra Software.
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.