Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xslt - using a parameter in a select?

Status
Not open for further replies.

smsinger3

Programmer
Oct 5, 2000
192
US
Hello.
I am trying to use a parameter to filter on an attribute in a select, but it does not work. I can't figure out why... This one does NOT work:

Code:
select="Search/TypesOfSearches/TypeOfSearch[@Name=$SearchName]/Category[@Id=$Category]/*/FieldDefinition"

However, when I take out the parameter, then it seems to work..like this:

Code:
select="Search/TypesOfSearches/TypeOfSearch[@Name='MySearchName']/Category[@Id='1']/*/FieldDefinition"

I don't know if this helps, but I can use a parameter for a xml node name, but not an attribute. That code looks like this:

Code:
select="/Search/FieldDefinitions/*[name() =  $xmlNodeName]/FromTo/@ViewType"


Do you have any ideas??? It is greatly appreciated!

Steve
 
You syntax is fine. Make sure the parameters both have the value you are expecting.

Jon

"Asteroids do not concern me, Admiral. I want that ship, not excuses.
 
Jon, you were absolutely right. I was not passing in the parameters as I thought I was. I am using XmlSpy and it doesn't seem to be passing my parameters through the IDE.

But, here's another error related to the first. I get an error on the match=".." statement. I don't know why. It's weird that I get the error in Xml Spy 2005, but when I run it using ASP.Net, it works, but the template never runs. Does anyone have any ideas how to correct this?

Here is the error:

Variables may not be used within this expression.


Here is the line of code.
Code:
<xsl:template match="Search/TypesOfSearches/TypeOfSearch[@Name=$SearchName]/Category[@Id=$Category]/*/FieldDefinition" >


Thank you very much for your help!

Steve
 
Use the template like this:
Code:
<xsl:template match="/">
    <xsl:apply-templates select="Search/TypesOfSearches/TypeOfSearch[@Name=$SearchName]/Category[@Id=$Category]/*/FieldDefinition"/>
</xsl:template>
<xsl:template match="FieldDefinition">
..........
</xsl:template>

Jon

"Asteroids do not concern me, Admiral. I want that ship, not excuses.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top