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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:49:15+00:00 2026-05-15T22:49:15+00:00

I found solution for subj related to the Visual Studio XSLT processor: public class

  • 0

I found solution for subj related to the Visual Studio XSLT processor:

   public class XsltListFilesExtension
    {
        public XPathNodeIterator ListFiles(string directoryPath)
        {
            XmlDocument doc = new XmlDocument();
            doc.AppendChild(doc.CreateElement("files"));

            DirectoryInfo di = new DirectoryInfo(directoryPath);
            foreach (FileInfo fi in di.GetFiles())
            {
                XmlElement file = doc.CreateElement("file");
                file.SetAttribute("name", fi.Name);
                file.SetAttribute("size", fi.Length.ToString());
                doc.DocumentElement.AppendChild(file);
            }
            return doc.DocumentElement.CreateNavigator().SelectChildren("file", "");
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            XslTransform t = new XslTransform();
            t.Load("transform.xslt");

            XsltArgumentList xsltArgs = new XsltArgumentList();
            xsltArgs.AddExtensionObject("urn:list-files-extension", new XsltListFilesExtension());

            XPathDocument input = new XPathDocument("input.xml");
            using (FileStream output = new FileStream("output.txt", FileMode.Create))
            {
                t.Transform(input, xsltArgs, output);
            }
        }
    }

The XSLT trasform.xslt:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
    xmlns:lfe="urn:list-files-extension">
    <xsl:output method="text" indent="yes"/>

    <xsl:template match="/">
        <xsl:for-each select="lfe:ListFiles('D:\temp')">
            <xsl:value-of select="@name"/>
            <xsl:text> - </xsl:text>
            <xsl:value-of select="@size"/>
            <xsl:text>bytes
</xsl:text>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

Can I to do solution like this but for common scope, for instance: the same xslt file can execute using java xslt processor, C# and etc. ?
Thanks.

  • 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-05-15T22:49:16+00:00Added an answer on May 15, 2026 at 10:49 pm

    The extension mechanism is general and part of the xslt specification.

    You will need to find out with any xsl processor you are using what the exact mechanism is and how to import it into the xslt sheet, but in general the approach is similar.

    This is possible with java, and the example you posted is already in C#. This should be possible with any xslt processor that supports xslt extensions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible? I have found solution for Visual Studio Print n levels of
I found this solution AutoMapper - setting destination string to null actually makes it
Seems, it's common task, but I haven't found solution. I need to calculate number
Edited: SOLUTION FOUND. This is strange and not the best solution, but I just
Update Solution Found See Bottom of post if interested Seems simple enough and for
I found the solution for this question in C# , but I can't translate
[edit] Found the solution. Reinstall EVERYTHING - xcode, mono, monodevelop and monotouch. Now it
Following the solution found at Can I access session state from an HTTPModule? ,
Edited to Add * I haven't found a solution for this one yet, can
I edited this question after i found a solution... i need to understand why

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.