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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:30:20+00:00 2026-06-02T02:30:20+00:00

Is there a simple way to have an extension function in XSLT 1.0 written

  • 0

Is there a simple way to have an extension function in XSLT 1.0 written in javascript return a node-set?
I could create a new java class for this, but I would rather just put some code in the script itself.
When this can be done in another scripting language supported by all or most XSLT processors (VB script? Groovy? C#?), then that’s OK too of course.

I have the following simple script:

<msxsl:script language="JScript" implements-prefix="custom">
    function xml (input) {
        var x = input.split(";");
        return x.toString();
    }
</msxsl:script>

which returns a string, and hence no problem calling the function in Xpath expressions.
What I would like to have, is a node-set result. But when I change my script to

<msxsl:script language="JScript" implements-prefix="custom">
    function xml (input) {
        var x = input.split(";");
        return x;
    }
</msxsl:script>

then calling the function gives an error because the array is not automatically converted to a node-set.

I looked at arrays-with-java-xslt-extensions but that’s more in the line of creating a new class for this, which I wish to avoid for now.

So which statements should be added to the script in order to transform the array into a node-set, allowing the function call to be used in Xpath expressions?

  • 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-02T02:30:22+00:00Added an answer on June 2, 2026 at 2:30 am

    Here is an example that should work with MSXML 6 as long as run in a mode allowing script in XSLT to implement extension functions.
    The stylesheet code is as follows:

    <xsl:stylesheet
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      version="1.0"
      xmlns:ms="urn:schemas-microsoft-com:xslt"
      xmlns:my="http://example.com/my"
      exclude-result-prefixes="ms my">
    
      <xsl:output method="html" version="5.0"/>
    
      <ms:script language="JScript" implements-prefix="my">
      <![CDATA[
      function tokenize (input) {
        var doc = new ActiveXObject('Msxml2.DOMDocument.6.0');
        var fragment = doc.createDocumentFragment();
        var tokens = input.split(';');
        for (var i = 0, l = tokens.length; i < l; i++)
        {
          var item = doc.createElement('item');
          item.text = tokens[i];
          fragment.appendChild(item);
        }
        return fragment.selectNodes('item');
      }
      ]]>
      </ms:script>
    
      <xsl:template match="/">
        <html>
          <head>
            <title>Example</title>
          </head>
          <body>
            <h1>Example</h1>
            <ul>
              <xsl:apply-templates select="my:tokenize('Kibology;for;all')"/>
            </ul>
          </body>
        </html>
       </xsl:template>
    
       <xsl:template match="item">
         <li>
           <xsl:value-of select="."/>
         </li>
       </xsl:template>
    
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a simple way to have isometric projection? I mean the true isometric
I have a String Object in format yyyyMMdd .Is there a simple way to
I have a simple question. I have this bitmap Is there a way with
I've written this very simple function to replace a file extension using LINQ in
Is there a simples way to do this? I have 2 TextBox, for email
Is there a simple way to see assigned shortcuts with given prefix? Something similar
Is there a simple way to work with C++ objects directly from C? I
Is there a simple way to convert MP3 to WAV in vb2005? what i
Is there a simple way or method to convert a Stream into a byte[]
Is there a simple way of redirecting serial port output to a file, that

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.