how to call external java function in xslt file?

后端 未结 3 718
一整个雨季
一整个雨季 2021-01-07 05:21

I have this xslt file that I need to call a java function placed somewhere else in the same application. In the xslt file I have



        
相关标签:
3条回答
  • 2021-01-07 06:11

    It depends on what XSLT transformation processor you are using. Saxon uses urn:java:; Xalan uses xalan://.

    0 讨论(0)
  • 2021-01-07 06:19

    I had exactly the same problem and this solved it for me where urn:java: and java: both failed.

    Assuming you're using Xalan to do the transformation, you should change xmlns:test_my="vobs.plugins.WikiParser.WikiParser" to xmlns:test_my="xalan://vobs.plugins.WikiParser.WikiParser".

    0 讨论(0)
  • 2021-01-07 06:25

    You need to change the namespace declaration (at the xsl:stylesheet element) from xmlns:test_my="vobs.plugins.WikiParser.WikiParser" to xmlns:test_my="urn:java:vobs.plugins.WikiParser.WikiParser"

    The rationale is as follows: In order to use a class C from package a.b you need to define a namespace prefix and associate it with the urn:java:a.b.C.

    If I understand XSL correctly the urn: prefix is needed when importing Java code that is not part of the standard library (as in your case). If you only need to import standard library classes then "java:" will do.

    (Further details: http://cafeconleche.org/books/xmljava/chapters/ch17s03.html)

    [EDIT: change "java:" -> "urn:java:"]

    0 讨论(0)
提交回复
热议问题