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 8425203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:12:23+00:00 2026-06-10T04:12:23+00:00

I’m rather new to XSL Stylesheets, so bear with me here. I’ve got an

  • 0

I’m rather new to XSL Stylesheets, so bear with me here.

I’ve got an embedded C# block in my .xsl. It’s there because I need something that will take a string of numbers (Ex: “1,3,5”). I want it to the numbers on the ‘,’. The code block is part of an XSL loop, so it passes in which iteration it’s on and compares that number to the list that came in via the string. If the iteration-count is in the list, return true. If it’s not, return False. The string can also come in as “all”, in which case just return true.

This is what I came up with:

<msxsl:script language="c#" implements-prefix="user">
    <![CDATA[

        public bool showStoryImg(string desiredImgs, int currentNum){
            bool rtnVal = false;
            try
            {
                if (desiredImgs == "all")
                {
                    rtnVal = true;
                }
                else
                {
                    string[] numStrArr = desiredImgs.Split(',');
                    int[] values = new int[numStrArr.Length];
                    for(int x = 0; x < numStrArr.Length; x++)
                    {
                       values[x] = Convert.ToInt32(numStrArr[x].ToString());
                    }

                    foreach(int y in values)
                    {
                        if(currentNum == y){
                            return true;
                        }
                        else
                        {
                            rtnVal = false;
                        }
                    }
                }
            }
            catch(Exception e)
            {
                rtnVal = false;
            }
            return rtnVal;
        }
    ]]>
</msxsl:script>

However I fear my problem is that XSL has no way of using .NET Libraries, hence why this code doesn’t work. Are there any suggestions as to how I should go about this?

  • 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-10T04:12:25+00:00Added an answer on June 10, 2026 at 4:12 am

    No extension function is needed at all!

    This transformation:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="text"/>
    
     <xsl:param name="pImages" select="'1,3,5'"/>
    
     <xsl:variable name="vImages" select="concat(',',$pImages, ',')"/>
    
     <xsl:template match="/*">
         <xsl:apply-templates select=
         "img[contains($vImages, concat(',',position(),','))]/@src"/>
     </xsl:template>
    </xsl:stylesheet>
    

    when applied on the following XML document (none provided in the question!):

    <images>
      <img src="Image1.jpg"/>
      <img src="Image2.jpg"/>
      <img src="Image3.jpg"/>
      <img src="Image4.jpg"/>
      <img src="Image5.jpg"/>
    </images>
    

    processes only the elements with position that is specified in the $pImages parameter — in this case just outputs their src attributes:

    Image1.jpgImage3.jpgImage5.jpg
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters

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.