473,378 Members | 1,493 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,378 software developers and data experts.

select attributes in for-each problem

Hi,

I just would like to iterate through some attributes of a tag
(Section). Sometimes I only need one attribute and sometimes I need
all attributes.
In a xsl:param I declare the attribute name for the selection. So it's
no problem if I only search for one attribute. But what can I declare
in the same parameter when I need all attributes? As an expression I
could write @* for all attributes. But I can't put that sign as value
in the parameter -> Path Error.

I appreciate any help!
XML-File:
----------
<Main>
<Section id='basic'/>
<Section id='test'/>
<Section id='test2'/>
</Main>


XSL-File:
----------
<xsl:template match="Main">
<xsl:param name="searchID" select="'basic'"/>

<!-- For all attributes -> I can't set @* as parameter value
<xsl:for-each select="Section[@id=@*]">
-->

<!-- For only one attribute -->
<xsl:for-each select="Section[@id=$searchID]">
<b>
<xsl:value-of select="@id" />
</b>
<br/>
</xsl:for-each>

</xsl:template>
Jul 20 '05 #1
1 1301

in the same parameter when I need all attributes? As an expression I
could write @* for all attributes. But I can't put that sign as value
in the parameter -> Path Error.

the select attribute of with-param takes an arbitrary XPath expression
so you can use @* here.

However your posting didn't suggest using @* in with-param but in teh
expression

xsl:for-each select="Section[@id=@*]

That's legal but not what you meant as the [@id=@*] predicate is the
same as the predicate [@id] and just tests if there is an id attribute.
If there is one then it will be selected by both @id and @* so
the test will be true as one value of the nodes selected by @id will be
equal to one value of the nodes selected by @*.

David

Jul 20 '05 #2

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

Similar topics

9
by: aragon | last post by:
Hi all, is it legal to use a fully-numeric string as "name" attribute for the <select> tag in the XHTML standard? E.g.: <form action="action.php" method="get"> <select name="12345"> <option...
9
by: Kelvin | last post by:
Okay so this is baking my noodle. I want to select all the attritbutes/fields from a table but then to excluded any row in which a single attributes data has been duplicated. I.E. Here's my...
2
by: George Durzi | last post by:
This is more of a design/philosophical question :) I have a page in which the user sets attributes for a project. There are 8 attributes, e.g. Project Type, Country, etc. The number of options...
4
by: sakieboy | last post by:
I currently have a datagrid with several columns. The first column in the DataGrid is a HyperLinkColumn. When I select a row, I would like for this HyperlinkColumn to fire. I have the mouseover...
1
by: puneet.bansal | last post by:
Hi, I want to know the index of the option that a user clicks on in a multiple-select object (regardless of whether he selected or deselected it). This seems fairly simple but I can't seem to...
5
by: ad | last post by:
I have a Textbox (Text) in a web form. I use this.SetFocus(Text1); to set the focus on Text1. How can I let the text in Text1 selected when the Text1 get focus?
4
by: Dabbler | last post by:
Is there a way to mark the text in a TextBox control as selected so when the user types a new value the existing text is replaced? Thanks
5
by: Dinu | last post by:
hi how can we select a row in a gridview with out select column and get events fired thanks
4
by: Mystagogue | last post by:
Given XML like this... <stuff> <thing id="1" result="true"/> <thing id="2" result="true"/> <thing id="3" result="false"/> <thing id="4" result="false"/> <thing id="5" result="error"/>...
5
by: Andy Chambers | last post by:
Hi, On both Opera and Firefox, getElementsByTagName doesn't find anything apart from <optionelements inside a select element. Why is this? Here's a page that demonstrates this behaviour. I'd...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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...

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.