- Where Developers Learn, Share, & Build Careers
I am trying to call a static Java method from my XSLT stylesheet:
< Code> & lt; ? XML version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Xsl: stylesheet version = "2.0" xmlns: xsl = "http://www.w3.org/1999/XSL/Transform" xmlns: digest = "java: org.apache.commons.codec.digest.DigestUtils" & gt; ; & Lt; Xsl: output method = "xml" encoding = "UTF-8" indent = "yes" /> & Lt; Xsl: template match = "user" & gt; & Lt; Users & gt; & Lt; Firstname & gt; & Lt; Xsl: Select value = "value [@ type = 'first name'] [/ 1]" /> & Lt; / Firstname & gt; & Lt; Lastname & gt; & Lt; Xsl: Select value = "value [@ type = 'name'] [1]" /> & lt; / Lastname & gt; & Lt; Password & gt; & Lt; Xsl: variable name = "password" = "string (value [@ type = 'password'] [1])" /> & Lt; Xsl: Select value = "Digest: MD5 hacks ($ password)" disable-output-escaping = "yes" /> & Lt; / Password & gt; & Lt; / User & gt; & Lt; / XSL: Templates & gt;Digest Youths is found in the class and also as a static MD5-Hawk-method [1]. The problem is, there are three possible ways to implement the method, i.e. with a byte [], an inputstream or string. Given that the type of "password" variable is xs: string, I assumed that suction would automatically choose the last option. But instead, this emphasizes the byte [] - method and fails accordingly:
[...] loading org.apache.commons.codec.digest.DigestUtils in Java class Method of searching for md5hex org.apache.commons.codec.digest.DigestUtils the number of real arguments = 1 [...] The method is trying MD5Hex: Name matching method is static argument 1; Hopefully 1 one candidate method was found: Try the static java.lang.String org.apache.commons.codec.digest.DigestUtils.md5Hex (byte []) method Md5Hex: The name matching method is static method 1 argument; Hopefully 1 candidate candidate found: Public static java.lang.String org.apache.commons.codec.digest.DigestUtils.md5Hex (java.io.InputStream) java.io.IOException throws the method trying to md5hex : The name matching method is the 1st way argument; Method of 1st candidate found: The best method for logging the public static java.lang.String org.apache.commons.codec.digest.DigestUtils.md5Hex (java.lang.String) [...] option. Finding 0: Public static java.lang.String org.apache.commons.codec.digest.DigestUtils.md5Hex (Byte []) are Conversion Preferences [24] Try Option 1: public static java.lang.String org.apache. Commons.codec.digest .DigestUtils.md5Hex (java.io.InputStream) java.io.IOEEXception throws conversion preferences [80] Trying Option 2: Public static java.lang.St Ring org.apache.commons.codec.digest.DigestUtils.md5Hex (Java.Lang.String) Conversion Preferences [80] Eliminating Options 1 Eliminating Option 2 The remaining candidate number of methods: 1 Error on XSL: Migrate_users.xl line 14 Template at column 30: Can not be changed from XS: Failed to compile the string style stylesheet byte. 1 error detected
Is there any way to force Saxon to use string-method?
[1]) Update: A partner only found the company's license key for Saxon 9.4 PE. Unfortunately this error persists, the only thing that changed was that the conversion preference for byte [] went from 24 to 31.
You will need to type your variable:
& lt; Xsl: variable as = "xs: string" name = "password" select = "string (value [@type = 'password'] [1])" />
Or enter in the call:
& lt; Xsl: select value = "digest: MD5 hacks (xs: string ($ password))" disabled-output-escape = "yes" />
defined with Xs namespace :
xmlns: xs = "http://www.w3.org/2001/XMLSchema"
Comments
Post a Comment