Using Parameters in XSL Select Statements

Using Parameters in XSL Select Statements

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)

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.

See also  How to Block Websites During Certain Hours on a Mac Computer

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist