Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Home » Tip Bank » XML » XSLT
Language: XSLT
Expertise: Beginner
Aug 9, 2000

Using Parameters in XSL Select Statements

Question:
Given the XML file:

 
Sometimes we want to display name1 and sometimes name2. We figured that perhaps we could set a parameter.
Then we could pass in the name of the attribute as the value using the addparameter method on the processor object. Then maybe we'd access the required attribute like this:

  
or "@$temp" but you get the idea)

Answer:
You've got the right idea, though it's not quite that simple. What you need to do is pass the name of the parameter, then compare against the name:





By including the select statement in the parameter, you guarantee that if no parameter is passed that the first name will always be used.
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap