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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:56:29+00:00 2026-05-28T19:56:29+00:00

I am attempting to transpose a java function to an xsl:function spec. The function

  • 0

I am attempting to transpose a java function to an xsl:function spec.
The function basically places html tags around substrings.
I now bump into difficulties: using the java inline code this works perfectly, but I am unable to figure out how to prevent output escaping when using the xsl:function.
How can I achieve the output to contain the wanted html tags?

A simplified example of what I am trying to achieve is the following:
input parameter value “AB” should lead to a string A<b>B</b>, shown in html browser as AB of course.

Example function I tried is the below; but then the resulting string is A&lt ;b&gt ;B&lt ;/b&gt ; (note that I had to add blanks to prevent the entities from getting interpreted in this editor), which of course shows up in browers as A<b>B</b>.

Note that xsl:element cannot be used in the xsl:function code, because that has no effect; I want the string result of the function call to contain < and > characters, and then add the string result to the output result file.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
    version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:custom="http://localhost:8080/customFunctions">

    <xsl:output method="html" version="4.0" encoding="UTF-8" indent="yes"/>

    <xsl:function name="custom:test">
        <xsl:param name="str"/> 

        <xsl:value-of select="substring($str,1,1)"/>
        <xsl:text disable-output-escaping="yes"><![CDATA[<b>]]></xsl:text>
        <xsl:value-of select="substring($str,2)"/>
        <xsl:text disable-output-escaping="yes"><![CDATA[</b>]]></xsl:text>
    </xsl:function>

    <xsl:template match="/">
        <xsl:element name="html">
            <xsl:element name="body">
                <xsl:value-of select="custom:test('AB')"/>
            </xsl:element>
        </xsl:element>
    </xsl:template>

</xsl:stylesheet>
  • 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-28T19:56:30+00:00Added an answer on May 28, 2026 at 7:56 pm

    Here is an example, use sequence instead value-of and make sure your function returns nodes (which is usually simply done by writing literal result elements):

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet
        version="2.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:custom="http://localhost:8080/customFunctions"
        exclude-result-prefixes="custom">
    
        <xsl:output method="html" version="4.0" encoding="UTF-8" indent="yes"/>
    
        <xsl:function name="custom:test">
            <xsl:param name="str"/> 
    
            <xsl:value-of select="substring($str,1,1)"/>
            <b>
              <xsl:value-of select="substring($str,2)"/>
            </b>
        </xsl:function>
    
        <xsl:template match="/">
            <xsl:element name="html">
                <xsl:element name="body">
                    <xsl:sequence select="custom:test('AB')"/>
                </xsl:element>
            </xsl:element>
        </xsl:template>
    
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Attempting to insert an escape character into a table results in a warning. For
Attempting to use XStream's JavaBeanConverter and running into an issue. Most likely I'm missng
Attempting to run a MIB based SNMP script and I running into an issue.
Attempting to cutover our EF4 solution to EF CTP5, and ran into a problem.
while attempting to run rake, I run into the following error: heroku rake db:migrate
I'm running into the following error when attempting to initialize a JMS connection between
I am attempting to host a service that serves up basic web content (HTML,
Attempting the most basic example of Knockout.js possible on their documentation page: http://knockoutjs.com/documentation/observables.html Looks
Attempting to print out a list of values from 2 different variables that are
Attempting to deploy a MOSS solution to a UAT server from dev server for

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.