Monthly Archives: April 2013

Alternative to XPath as Constants

Now-a-days, XQuery and XPath are used heavily in all applications as XML has become a standard for data exchange in most of the applications. The modularization phase in any application development creates a need to manage the location of data dynamically.

In XPath/XQuery we all know that it doesn’t support dynamic evaluation of XPath from STRING without using EVAL function from 3rd party which is quite performance inefficient for large data. But the need for having a configuration for XPath from a specific element/node is still there.

This is again a solution to address the modularization of XQuery implementation and to address the CONSTANTs mapping for XPath which can be used by a specific XQuery dynamically.

Now, to set the context, we use XQuery LIB/SUB module to manage our constants or global data. I am taking advantage of this functionality to get a bit closer to the target goal. Below is what I configured.

1. Create a Sub/Lib module to manage the XPath which are required to be fetched dynamically from one source or different sources.
2. Create 1 liner functions for each XPath that needs to be generated dynamically.
3. Pass the source to each function in the Sub/Lib module as a start reference.
4. HardCode the exact XPath post the source in that XQuery function.
5. The XQuery functions becomes your constant XPath variable to be used.
6. Use the XQuery function as a constant in your Main XQuery.

Advantages of this approach are that it decouples the constant mapping from main XQuery file to a dedicate XPath configuration file. The only difference is that we use functions instead of variables.

Below is an example.

1. This is a sample XML for the example.
1

2. This is a sample LIB Module for the XQuery – Dynamic XPath function.

2

3. This is the main XQuery module calling 4 ways to generate the result.

3

Please provide your options or views on this.

In  the end, it’s not the years in your life that count. It’s the life in your  years.
– Abraham Lincoln

VISIO: Auto Save Pages to PNG

Hello again! This particular post is again an actual solution to one of the problem that my team faced. As you all know that we use VISIOs in every project to make process flows, organization chart and lot of other non-project things 🙂 to present the information in a very nice manner.

Also, the VISIOs are normally kept together in pages of a single VSD file. It happen to be the case that we were asked to create PNG/Images from the VISIOs – all pages and embed into word document. There were 4 VISIO files with 40 pages each and it was damm time consuming to do -> File -> SaveAs -> PNG for all VISIO pages.

I happened to know a bit of VB programming under VISIO and wrote a small piece of code. This code requires a new VSD to be created and give input the VISIO/VISIOs to save all pages to a PNG file based on the page name.

Now, my team is using this utility to manage the change reflect all the PNG in fraction of sections.

Procedure to use this code:

1. Create a new VSD file
2. Enable Macro
3. Open Code Editot Alt+F11
4. Paste the Code
5. Run

Below is the code:

VISIO_PAGE_PNG

The code can be download from HERE.

Hope you find it useful!

“Automation does not make optimism obsolete.”
– George Keith Funston