Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8717173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:15:03+00:00 2026-06-13T06:15:03+00:00

I am beginner in XSLT. My Source XML is as below <Options> <Option> <Data>Data1</Data>

  • 0

I am beginner in XSLT.

My Source XML is as below

<Options>
    <Option>
        <Data>Data1</Data>
        <Type>A</Type>
    </Option>
    <Option>
        <Data>Data2</Data>
        <Type>B</Type>
    </Option>
    <Option>
        <Data>Data3</Data>
        <Type>C</Type>
    </Option>
    <Option>
        <Data>Data4</Data>
        <Type>D</Type>
    </Option>
    ...
</Options>

I have parameter which is used to filter the result from above method and it is as below

<xsl:param name="filterType" select="'A,C'"/>

The output should be as below:

<Result>
     <Data Type="A">Data1<Data>
     <Data Type="C">Data3<Data>
</Result>

Below is the XSLT i have created:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">

    <xsl:param name="filterType" select="'A,C'"/>
    <xsl:template match="Options">
       <xsl:element name="Result">
         <xsl:apply-templates select="Option"/>
       </xsl:element>
    </xsl:template?

    <xsl:template match="Option">
       <xsl:element name="Data">
           <xsl:attribute name="Type">
               <xsl:value-of select="Type"/>
           </xsl:attribute>
           <xsl:value-of select="Data"/>
       </xsl:element>
    </xsl:template?
</xsl:stylesheet>

While applying template for 'Option' tag i need to use filterType.
How can i do that? Please Help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:15:04+00:00Added an answer on June 13, 2026 at 6:15 am

    I think you simply want

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        version="1.0">
    
        <xsl:param name="filterType" select="'A,C'"/>
    
        <xsl:variable name="filter" select="concat(',', $filterType, ',')"/>
    
        <xsl:template match="Options">
           <Result>
             <xsl:apply-templates select="Option[contains($filter, concat(',', Type, ','))]"/>
           </Result>
        </xsl:template>
    
        <xsl:template match="Option">
           <Data Type="{Type}">
             <xsl:value-of select="Data"/>
           </Data>
        </xsl:template>
    
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a beginner to XSLT. My Source XML is as below: <Passengers> <Passenger
I'm a beginner at XSL FO. I have a very simple XML document :
I have JDK6 and using JAXP for the transformation. I am beginner to XSLT.
Total beginner with PHP: I have an form based on table data that the
Possible Duplicate: Add an attribute with static value with xslt I have an XML
I am a beginner and want to learn XSLT. I came upon an issue
Beginner iOS dev here. I have a problem in my array. Im making an
Beginner in Android development. My code crashes. I have made a simple Java method
Beginner level question Scenario: Have simple string cocantation tool, that I might expand later
Beginner question: I have a dictionary where the values are lists of (a variable

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.