Calling Java Methods in XSLT

2019-07-17 18:50发布

问题:

Trying to generat a random number with the help of Java UUID class.

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"
  exclude-result-prefixes="xs" xmlns:uuid="java:java.util.UUID">
<xsl:template match="/">
<xsl:variable name="uid" select="uuid:randomUUID()"/>
<ClientPK><xsl:value-of select="$uid"/></ClientPK>

Error

Cannot find a matching 0-argument function named {java:java.util.UUID}randomUUID().
  Note that direct calls to Java methods are not available under Saxon-HE

回答1:

See http://saxonica.com/documentation/index.html#!extensibility, if you want to use Saxon 9 and have that feature (called reflexive extension functions) you need a license for PE or EE.



标签: java xslt saxon