• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Namespance prefix transparent XPath lookup

 
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Our application is receiving data in a form of XML files from multiple sources. We are extracting some field values from these XML file using XPath and populating in the database.
The XML files we are receiving are having different prefix for the same namespace. Our XPath code is capable of performing lookup based on any one prefix.

How to perform XPath lookup which is prefix transparent?





 
Ranch Hand
Posts: 734
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The situation is like this. The prefix for binding to a non-null namespace in the xpath is quite arbitrary in nature as long as the uri bound to it is the proper namespace uri. However, working with team or alone, it is sometimes---if not you, it may be some of your colleagues---very tempting to use the same as appeared in the xml document. Hence, it is of no harm to put the possible prefixes used in the incoming xml inside a lookup table if not just as a reminder. Besides, you can use some "universal" prefix (say "s10", as long as it won't possible appear in the xml as prefix for some other namespace) specifically binding to the .../Student/1.0 namespace at the consumer-side, that is agreed upon amongst the dev team or yourself.

Hence, if I capture the essential of what you've meant by transparent, you can do this in the NamespaceContent handling.

That's the idea. After that, you can use tns or ns1 or the fixed s01 as prefix in the xpath for the targetted namespace to bind to.
 
them good ole boys were drinking whiskey and rye singin' this'll be the day that I die. Drink tiny ad.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic