473,396 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

problem @idType = ./@idType

Xh
Hi all,

I have a problem with generating legend for my data.

I have types and theirs names given like this:
<types>
<type idType="1"><name>Description of type 1</name></type>
<!-- and so on... -->
</types>

And I have my data:

<units>
<unit idUnit="148" idType="1"><!-- stuff here... --></unit>
</units>

I use the for-each loop to iterate through all units, I don't want to
display unit XYZ is of type 1 or 2 or 3...

I wan to use theirs names instead of numbers

I wrote this:
<xsl:for-each select="units/unit">
<xsl:sort select="code"/>
<xsl:value-of select="//types/type[@idType = ./@idType]/name"/>
</xsl:for-each>

but this is wrong since all types have the same <namevalue

inside for-each loop current node is ".", but in value-of the same
thing applies and "." becomes the first <typesince all attributes of
types/type are equal to themselves

maybe someone knows how can it be done?

I can not change the names of the attributes I must use them "as
is" (or "as are")

thanks in advance for any help
best regards
Łukasz

Mar 27 '07 #1
3 1266
Xh
On Mar 27, 1:53 pm, "Xh" <lukasz.bud...@komputery-internet.netwrote:
I wrote this:
<xsl:for-each select="units/unit">
<xsl:sort select="code"/>
<xsl:value-of select="//types/type[@idType = ./@idType]/name"/>
</xsl:for-each>
Hi all,

It has just crossed my mind ;)

<xsl:for-each select="units/medicalUnit">
<xsl:sort select="code"/>
<xsl:variable name="node" select="." />
<xsl:value-of select="//types/type[@idType = $node/@idType]/name"/>
</xsl:for-each>

sorry ;)

best regards
Łukasz

Mar 27 '07 #2
"Xh" <lu***********@komputery-internet.netwrites:
<types>
<type idType="1"><name>Description of type 1</name></type>
<!-- and so on... -->
</types>
<units>
<unit idUnit="148" idType="1"><!-- stuff here... --></unit>
</units>
<xsl:for-each select="units/unit">
<xsl:sort select="code"/>
<xsl:value-of select="//types/type[@idType = ./@idType]/name"/>
</xsl:for-each>
Use current() to get the... current node (as apposed to the context
node). So [@idType=current()/@idType] should do what you want.

-- Alain.
Mar 27 '07 #3
In article <11**********************@n76g2000hsh.googlegroups .com>,
Xh <lu***********@komputery-internet.netwrote:
><xsl:for-each select="units/medicalUnit">
<xsl:sort select="code"/>
<xsl:variable name="node" select="." />
<xsl:value-of select="//types/type[@idType = $node/@idType]/name"/>
</xsl:for-each>
Yes, variables are the general solution to problems of this type. But
using current() is a simpler solution for the common case where the
variable would be set to ".".

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Mar 27 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
0
by: mjcsfo | last post by:
I can't seem to find a reference nor any helpful threads on this topic. I've gotten the following error in two circumstances: 1. A complex type has nested within it another complex type, in the...
117
by: Peter Olcott | last post by:
www.halting-problem.com
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
10
by: Nikolay Petrov | last post by:
The following code doesn't produse the expected effect to only allow the members of Administrators group to access the web method, it stops everyone. ========= <WebMethod(), _...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
19
by: k.karthikit | last post by:
Hello all, In some hidden variable (<input type="hidden" name="hiddenId" value="test" /> ,i stored some value.I accessed the value "test" using var id = document.getElementById( 'hiddenId' );...
1
by: reyesvsn | last post by:
Hello everybody, I have a question concerning XPath expressions and namespaces. Consider this XML: <?xml version="1.0" encoding="UTF-8"?> <newsMessage ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...

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.