473,790 Members | 2,951 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trouble with XPath for "preceding sibling"

14 New Member
Hi All,

I am facing a problem while fetching a preceding sibling with some specific name from current node.

Following is the sample XML which I am using

<Root>
<document>
<tid>100</tid>
<location>SB</location>
<category>C1</category>
</document>
<document>
<tid>101</tid>
<location>SB</location>
<category>C3</category>
</document>
<document>
<tid>102</tid>
<location>JK</location>
<category>C4</category>
</document>
</Root>

Now suppose I am on 3rd <document> node [that is "tid = 102" ] and I want to check the values for the previous document's <location> node. If its is different than the current document's <location> then I need to call some other template.

Can anyone please help. This is very urgent!


Thanks in advance
Apurva G.
Mar 28 '08 #1
3 3991
jkmyoung
2,057 Recognized Expert Top Contributor
Expand|Select|Wrap|Line Numbers
  1. <xsl:if test="location != preceding-sibling::tid[1]/location">
  2.   <xsl:call-template name="blah">
  3.   ..
  4.  
Mar 28 '08 #2
apurvaG
14 New Member
Expand|Select|Wrap|Line Numbers
  1. <xsl:if test="location != preceding-sibling::tid[1]/location">
  2.   <xsl:call-template name="blah">
  3.   ..
  4.  


Will "preceding-sibling::tid[1]/location" refer to 2nd <document> node's locaton ? Another thing is location node is not child of <tid>. It is child of <document> node.
Mar 31 '08 #3
jkmyoung
2,057 Recognized Expert Top Contributor
sorry, must have been a brain fart:
Expand|Select|Wrap|Line Numbers
  1. <xsl:if test="location != preceding-sibling::document[1]/location">
  2.   <xsl:call-template name="blah">
  3.   ..
  4.  
Apr 1 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
1679
by: Jeb Hunter | last post by:
Seems to be arbitrarily specified or omitted in various documents. Maybe this is a PHP element that I've not encountered yet, being new to it. Or is there some XSLT-specific reason for this? Can someone tell me what it means to have it, or omit it? Naturally, you can't search Google for the "@" character. :-( I'm lost. thanks...
3
11312
by: Peter Rohleder | last post by:
Hi, I'm using a style-sheet where I make use of the XPATH-"following-sibling"-expression. The part which makes problems looks similar to the following code: --------------------------- <xsl:for-each select="headdata/extension/person">
2
5169
by: Mark Bordner | last post by:
Hi All, Given the following XML, I've been trying to figure out what XPATH expression will give me the "position" of a <lineitem> within the <shipto> that is its grandparent. To give you an idea of what I'm trying to do...I'm transforming this XML into XSL-FO; which I will process with FOP to produce a PDF file. Each <shipto> element with the XML correlates to a new "section"
1
2611
by: Niall Smart | last post by:
Hi I'm trying to emulate a "following-sibling-or-self" XPath axis without using the union operator. The XML looks like this: <deeply-nested> <select> <option value="1">One</option> <option value="2" selected="selected">Two</option> <option value="3">Three</option>
11
2162
by: localpricemaps | last post by:
i have some html which looks like this where i want to scrape out the href stuff (the www.cnn.com part) <div class="noFood">Cheese</div> <div class="food">Blue</div> <a class="btn" href = "http://www.cnn.com"> so i wrote this code which scrapes it perfectly:
1
2042
by: arnold | last post by:
Hi, I've been knocking my head against the wall trying to create an XSL transform to perform "normalizations" of a set of XML files that have a common structure. % XML file before transform
1
1794
by: Sion Arrowsmith | last post by:
I have a module which needs to know what directory it's in, and to refer to files in a sibling directory, something like App/src/foo.py wants to read App/data/conf.xml . But I have no idea in what context foo.py is going to be run -- it could be being run as a script, it could be being imported as a module by another script from anywhere in the directory structure, it's even possible someone will have called execfile on it. The following...
9
2390
by: Anil Gupte | last post by:
I have a MDI Parent Child set of forms FormContainer --MDIParent FormStart --MDIChild FormMain-->MDIChild FormSliceInfo-->MDIChild I use the following in the beginning of FomrContainer Public Class FormContainer Inherits System.Windows.Forms.Form
5
13383
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL http://mghospedagem.com/images/controlpanel.jpg instead of http://mghospedagem.comhttp://mghospedagem.com/images/controlpanel.jpg As u see, there's the website URL before the image URL.
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10419
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10201
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9987
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9023
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6770
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5424
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2910
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.