• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XPATH and concat curiosity

 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have an xml viz.
<element>
<component>....</component>
<event>....</event>
<event>....</event>
<event>....</event>
<event>....</event>
</element>

The number of events will be dynamic.
For a relevant component,we need to return the cooresponding events pipe-delimited.
We arrive at the particular component through SelectNodes - is there a smart,concide XPATH expression which can allow me to return the set of events in the way we want,rather than recursing through the set.
Note that component and event nodes are parent(ed) by 'element'.
We are using javascript.
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure that I understand this. The XPath expression to identify those nodes is just "/element/component/event". Of course that won't give you the contents of the nodes, concatenated, with pipes delimiting the data, but XPath doesn't do that sort of thing anyway. You would have to do that in your Javascript code, but you wouldn't need recursion.
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Assuming you need this using xslt, use keys as below:

Define a key
<xsl:key name="EventKey" match="/element/event" use="../component"/>

Now use the key to get the event nodes using component
key('EventKey','WhatEverThecomponent') returns all the event nodes

vinay
(vinay.l@tcs.com)
 
reply
    Bookmark Topic Watch Topic
  • New Topic