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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:35:41+00:00 2026-06-07T14:35:41+00:00

I am trying to call a static Java method from my XSLT stylesheet: <?xml

  • 0

I am trying to call a static Java method from my XSLT stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                              xmlns:digest="java:org.apache.commons.codec.digest.DigestUtils">
<xsl:output method="xml" encoding="utf-8" indent="yes"/>

<xsl:template match="user">
  <user>
    <firstname>
      <xsl:value-of select="value[@type='firstname'][1]" />
    </firstname>
    <lastname>
      <xsl:value-of select="value[@type='name'][1]" />
    </lastname>
    <password>
      <xsl:variable name="password" select="string(value[@type='password'][1])" />
      <xsl:value-of select="digest:md5Hex($password)"
                    disable-output-escaping="yes" />
    </password>
  </user>
</xsl:template>

The DigestUtils class is found and the static md5Hex-method [1] as well. The problem is, that there are three possible ways to invoke the method, namely with a byte[], an InputStream or a String. Given that the “password” variable is of type xs:string, I assumed that Saxon would automatically choose the last option. But instead, it insists on the byte[]-method and fails accordingly:

[...]
Loading org.apache.commons.codec.digest.DigestUtils
Looking for method md5Hex in Java class class org.apache.commons.codec.digest.DigestUtils
Number of actual arguments = 1
[...]
Trying method md5Hex: name matches
Method is static
Method has 1 argument; expecting 1
Found a candidate method:
    public static java.lang.String org.apache.commons.codec.digest.DigestUtils.md5Hex(byte[])
Trying method md5Hex: name matches
Method is static
Method has 1 argument; expecting 1
Found a candidate method:
    public static java.lang.String org.apache.commons.codec.digest.DigestUtils.md5Hex(java.io.InputStream) throws java.io.IOException
Trying method md5Hex: name matches
Method is static
Method has 1 argument; expecting 1
Found a candidate method:
    public static java.lang.String org.apache.commons.codec.digest.DigestUtils.md5Hex(java.lang.String)
[...]
Finding best fit method for arguments
Trying option 0: public static java.lang.String org.apache.commons.codec.digest.DigestUtils.md5Hex(byte[])
Conversion preferences are [24]
Trying option 1: public static java.lang.String    org.apache.commons.codec.digest.DigestUtils.md5Hex(java.io.InputStream) throws java.io.IOException
Conversion preferences are [80]
Trying option 2: public static java.lang.String org.apache.commons.codec.digest.DigestUtils.md5Hex(java.lang.String)
Conversion preferences are [80]
Eliminating option 1
Eliminating option 2
Number of candidate methods remaining: 1
Error at xsl:template on line 14 column 30 of migrate_users.xsl:
  Cannot convert from xs:string to byte
Failed to compile stylesheet. 1 error detected.

Is there a way to force Saxon to use the String-method?

[1] http://commons.apache.org/codec/api-release/org/apache/commons/codec/digest/DigestUtils.html#md5Hex(java.lang.String)

—
update: A colleague just found the company’s license key for Saxon 9.4PE. Unfortunately the error persists, the only thing that changed was that the conversion preference for the byte[]-method went from 24 to 31.

  • 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-07T14:35:44+00:00Added an answer on June 7, 2026 at 2:35 pm

    You need to type your variable:

    <xsl:variable as="xs:string" name="password" select="string(value[@type='password'][1])" />
    

    or cast it in the call:

    <xsl:value-of select="digest:md5Hex(xs:string($password))"
                    disable-output-escaping="yes" />
    

    With the xs namespace defined as:

    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to call a static method from another activity to find a
I'm trying to get a simple Java method call from C++ while Java calls
I'm trying to call the java code from S. This method call: cls =
I am trying to call a C# method from java script ,I am new
Im trying to call a method that will add or subtract 1 from a
I'm trying to call a method from another class with a simple button in
I trying to call some ejb bean method from tread. and getting error :
When trying to call on a method from another class my method as a
I'm trying to use the example taken from the http://java.sun.com/products/jfc/tsc/articles/treetable2/index.html , in which I've
Trying to call a SAP SOAP Web Service from a generated sudzc app shows

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.