2013-09-25 46 views
0

如果从xslt中删除对Java类的引用,它将正常工作。
XSLTXSLT:无法找到Java类异常

<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:for-each select="Client"> 
      <xsl:variable name="uid" select="uuid:randomUUID()"/> 

的Groovy

import java.util.UUID 

TransformerFactory.newInstance() 
        .newTransformer(new StreamSource(new StringReader(xslt))) 
        .transform(new StreamSource(new StringReader(xmlAsString)), 
           new StreamResult(w)) 

异常

ERROR: 'Cannot find class 'java:java.util.UUID'.' 
FATAL ERROR: 'Could not compile stylesheet' 
Caught: javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet 

回答

0

问题是与xmlns:uuid="java:java.util.UUID"我从博客文章的一个了。
更新为xmlns:uuid="java.util.UUID",它工作正常。

1

我相信它应该是:

xmlns:uuid="java://java.util.UUID"