• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Abhishek Tanwar

I build web & mobile experiences

  • HOME
  • BLOG
  • CONTACT ME
  • DISCLAIMER & COPYRIGHTS
You are here: Home / Uncategorized / Alternative to XPath as Constants

Alternative to XPath as Constants

April 26, 2013 by Abhishek Tanwar

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

Share this:

  • Facebook
  • X

Like this:

Like Loading...

Filed Under: Uncategorized Tagged With: dynamic xpath, xpath, xpath constants, xquery

Primary Sidebar

  • Behance
  • Email
  • Facebook
  • GitHub
  • LinkedIn

Popular Posts

How To Integrate React in JSP Application
SaaS, PaaS, IaaS
XQuery highlighting in Notepad++
Standard Design Patterns – Applied to JAVA
XQDT Installation on Eclipse JUNO

Categories

  • Building APIs
  • Building Mobile Apps
  • Building Web Apps
  • Coding Challenges
  • Extensions
  • Fullstack
  • Patterns
  • Tips & Tricks
  • Uncategorized
  • VSCode

Tags

2022 vscode extensions Abstract Factory alienware amazing vscode extensions apple challenges coding coding-challenges Design Patterns dota2 dota2 items dynamic web service call dynamic webservice invocation enterprise integration express flex helpful vscode extensions how to implement mfa in nodejs increasing productivity using vscode integration pattern macro message channel message endpoint message pattern message router message translator messaging mfa offline action processing offline actions in struts pipes and filters PRG in struts react Steam struts System Emulator threads in struts utilities vscode vscode customization vscode extensions vscode productivity extensions xquery xquery 1.0 xquery design principles

Recent Posts

  • 15+ VSCode Extensions To Improve Your Productivity
  • Productivity and Quality Extensions for ReactJS in VSCode..
  • My goto VSCode plugins for 2022…
  • How to enable MFA for your application in Node.JS?
  • Structuring Express Application – How I do it?

Categories

  • Building APIs (8)
  • Building Mobile Apps (1)
  • Building Web Apps (7)
  • Coding Challenges (3)
  • Extensions (1)
  • Fullstack (6)
  • Patterns (8)
  • Tips & Tricks (41)
  • Uncategorized (43)
  • VSCode (2)

Tags

2022 vscode extensions Abstract Factory alienware amazing vscode extensions apple challenges coding coding-challenges Design Patterns dota2 dota2 items dynamic web service call dynamic webservice invocation enterprise integration express flex helpful vscode extensions how to implement mfa in nodejs increasing productivity using vscode integration pattern macro message channel message endpoint message pattern message router message translator messaging mfa offline action processing offline actions in struts pipes and filters PRG in struts react Steam struts System Emulator threads in struts utilities vscode vscode customization vscode extensions vscode productivity extensions xquery xquery 1.0 xquery design principles

Archives

  • August 2023 (1)
  • March 2022 (1)
  • February 2022 (1)
  • November 2020 (1)
  • April 2020 (2)
  • May 2019 (1)
  • April 2019 (1)
  • March 2019 (1)
  • December 2018 (1)
  • July 2018 (4)
  • June 2018 (3)
  • March 2018 (1)
  • May 2016 (1)
  • December 2015 (1)
  • May 2015 (1)
  • April 2015 (2)
  • March 2015 (1)
  • December 2014 (2)
  • November 2014 (2)
  • October 2014 (1)
  • August 2014 (2)
  • July 2014 (1)
  • April 2014 (1)
  • March 2014 (1)
  • February 2014 (2)
  • January 2014 (1)
  • December 2013 (4)
  • November 2013 (4)
  • October 2013 (3)
  • September 2013 (4)
  • August 2013 (2)
  • July 2013 (5)
  • June 2013 (9)
  • May 2013 (6)
  • April 2013 (2)
  • March 2013 (2)
  • January 2013 (1)
  • November 2012 (2)
  • HOME
  • BLOG
  • CONTACT ME
  • DISCLAIMER & COPYRIGHTS

Copyright © 2025

%d