Hi,
I have the following: -
<start>
-
<segment Id="AAA">
-
<element Id="id">1</element>
-
<element Id="seq">122</element>
-
<element Id="seq2" Composite="yes">
-
<subelement Sequence="1">57002122338772</subelement>
-
</element>
-
</segment>
-
<segment Id="BBB">
-
<element Id="id">5</element>
-
<element Id="BBB02" Composite="yes">
-
<subelement Sequence="1">AS12121212</subelement>
-
<subelement Sequence="2">SA</subelement>
-
</element>
-
</segment>
-
<segment Id="BBB">
-
<element Id="id">1</element>
-
<element Id="BBB02" Composite="yes">
-
<subelement Sequence="1">12121212</subelement>
-
<subelement Sequence="2">HS</subelement>
-
</element>
-
</segment>
-
<segment Id="XXX">
-
<element Id="XXX01">C</element>
-
<element Id="XXX02">35</element>
-
<element Id="XXX03" Composite="yes">
-
<subelement Sequence="1">090</subelement>
-
<subelement Sequence="3">91</subelement>
-
</element>
-
</segment>
-
<segment Id="XXX">
-
<element Id="XXX01">C</element>
-
<element Id="XXX02">98</element>
-
<element Id="XXX03" Composite="yes">
-
<subelement Sequence="1">36</subelement>
-
<subelement Sequence="3">91</subelement>
-
</element>
-
</segment>
-
...
-
</start>
-
This code is repeated maybe 10 times and is defined by the id in element 'id' in segment 'AAA'. So the next lines of code will be
[code] -
<segment Id="AAA">
-
<element Id="id">2</element>
-
...
-
Now I have the Id, and I need to get a value from the proceeding XXX-segment, i.e. if my id is 4, I need to find the AAA-segment with id=4 and then a value in the following XXX-segment. But I'm wondering how I do this most correctly. I can probably use the position-function, but I'm thinking there must be a better way. Unfortunately my xpath skills are pretty limited. Can someone give me a hint?
3 2155 jkmyoung 2,057
Recognized Expert Top Contributor
When you say following, you mean the Id of that segment is 1 + the value of this id? eg id=5 in your example?
Assuming you're in a segment node: -
<xsl:variable name="segid" select="@Id"/>
-
<xsl:variable name="elid" select="element[@Id='id']+1"/>
-
<xsl:for-each select="../segment[@id = $segid][element[@Id='id'][.=$elid]]">
-
...
-
Even if this isn't it, it should give you some sort of clue.
Ok. I mean if I have id=4, I first find the AAA-segment with id=4. Then my job will be to find the first XXX-segment with element id=XXX02's value set to 98 beneath it.
Imagine that the block I have shown in the thread is repeated within the start-tags, and only the values change. Ex. the id of the AAA-segment is incremented.
Hope I make myself clear :)
jkmyoung 2,057
Recognized Expert Top Contributor
I think I know what you mean now.
<xsl:for-each select="followi ng-sibling::segmen t[@Id='XXX'][1]">
I don't understand why you wouldn't get the segment with value 35 though.
Another possibility: -
<xsl:key name="previousAAA" match="segment" use="preceding-sibling::segment[@Id='AAA'][1]"/>
-
...
-
while in aaa Segment:
-
-
<xsl:for-each select="key('previousAAA', .)[@Id='XXX']">
-
maybe add [1] or [position()=last ()].
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Stephen S M WONG |
last post by:
As C++ program supports objects with
constructors/destructors/methods and data items, I'll assume
C++ implementation on segment model computer, like a 80286
with different access restrictions on code segment / data
segment / etc., will force all objects to be resided in a
code segment, so that executable code can be there as well
as data. And effectively bypassing all segment model.
Any comments on the above?
|
by: Skybuck Flying |
last post by:
Hi,
I needed a method to determine if a point was on a line segment in 2D. So I
googled for some help and so far I have evaluated two methods.
The first method was only a formula, the second method was a piece of C code
which turned out to be incorrect and incomplete but by modifieing it would
still be usuable.
The first method was this piece of text:
|
by: Dr. Zharkov |
last post by:
Hello. A problem in the following.
In VB .NET 2003 I create the project and in file Form1.vb is written down
the following code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Create the data:
CreateData() 'Error
End Sub
|
by: druberego |
last post by:
I read google and tried to find the solution myself. YES I do know that
you can get undefined references if you:
a) forget to implement the code for a prototype/header file item, or
b) you forget to pass all the necessary object files to the linker.
Neither of those are my problem. Please bear with me as the question
I ask is rather long and I think it's beyond a CS101 level of linker
stupidity. If it is a stupid CS101 mistake I'm making...
|
by: Jeff |
last post by:
Hi all,
I'm wondering if there is a function that will return the xpath to a
specific node given its context node. Essentially, I want the reverse
of the document.evaluate functionality. I've seen examples where
people build up the xpath themselves by walking the DOM, but I thought
there has to be a better way. I've included a simple example of this,
based on code from the Solvent project at MIT. This code works
reasonably well, but...
| |
by: jesjak |
last post by:
hi all,
can any one give me some explanation of "wat is .bss segment in object
file" and what it will contain and difference between data segment
and .bss segment....
help me....
thanks,
jes
|
by: axlq |
last post by:
Does anyone have a favored way of finding the geographic location
of a user's IP address, so that a php script can include content
relevant to that location?
Reverse-lookup of the hostname isn't reliable and often doesn't
work, especially if the returned hostname ends with .com, .net,
..info, .biz or other tld that doesn't reveal geographic location.
I also see a bunch of commercial services that offer a "country
whois" function for a...
|
by: abhimanyu.v |
last post by:
Hi Guys,
I have one doubt. The test program is given below. It uses two way of
finding out the offset of a variable in structure. I executed the
program and found the same result.
My question is what is difference between
1) (unsigned long) &((struct foobar *)0)->foo
and
|
by: biplab |
last post by:
for(i=0;i<256;i++)
{
hist=0;
}
for(i=0;i<height;i++)
{
for(j=0;j<width;j++)
{
k=(long int)rgb1;
hist=hist+1;
|
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...
|
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...
| |
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |