2

我正在使用 Mule 3.3.1 CE。

如果 XSL 位于文件外部,我无法让 XSLT 转换器工作。

以下配置有效——它编译并产生预期的单行输出。

<mulexml:xslt-transformer maxIdleTransformers="2" maxActiveTransformers="5" outputEncoding="UTF-8">
    <mulexml:xslt-text>
        <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
            <xsl:output method="xml"/>
            <xsl:template match="/">
                <xsl:element name="pocRequest"/>
            </xsl:template>
        </xsl:stylesheet>
    </mulexml:xslt-text>                
</mulexml:xslt-transformer>

如果我采用相同的 XSL 并将其移到类路径中的文件 Test.xsl 中,则该文件如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml"/>
    <xsl:template match="/">
        <xsl:element name="pocRequest"/>
    </xsl:template>
</xsl:stylesheet>

Mule 配置现在如下所示:

<mulexml:xslt-transformer maxIdleTransformers="2" maxActiveTransformers="5" outputEncoding="UTF-8"
    xsl-file="Test.xsl"/> 

结果是无法编译样式表的异常:

javax.xml.transform.TransformerConfigurationException: Failed to compile stylesheet. 1 error detected.
    at net.sf.saxon.PreparedStylesheet.prepare(PreparedStylesheet.java:153)
    at net.sf.saxon.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:137)
    at net.sf.saxon.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:88)
    at org.mule.module.xml.transformer.XsltTransformer$PooledXsltTransformerFactory.makeObject(XsltTransformer.java:363)
    at org.apache.commons.pool.impl.GenericObjectPool.addObject(GenericObjectPool.java:1615)
    at org.mule.module.xml.transformer.XsltTransformer.initialise(XsltTransformer.java:138)
    at org.mule.processor.chain.AbstractMessageProcessorChain.initialise(AbstractMessageProcessorChain.java:79)
    at org.mule.api.processor.MessageProcessors$LifecyleAwareMessageProcessorWrapper.initialise(MessageProcessors.java:62)
    at org.mule.processor.chain.AbstractMessageProcessorChain.initialise(AbstractMessageProcessorChain.java:79)
    at org.mule.api.processor.MessageProcessors$LifecyleAwareMessageProcessorWrapper.initialise(MessageProcessors.java:62)
    at org.mule.processor.chain.AbstractMessageProcessorChain.initialise(AbstractMessageProcessorChain.java:79)
    at org.mule.routing.MessageProcessorFilterPair.initialise(MessageProcessorFilterPair.java:93)
    at org.mule.routing.AbstractSelectiveRouter.initialise(AbstractSelectiveRouter.java:94)
    at org.mule.processor.chain.AbstractMessageProcessorChain.initialise(AbstractMessageProcessorChain.java:79)
    at org.mule.construct.AbstractFlowConstruct.initialiseIfInitialisable(AbstractFlowConstruct.java:309)
    at org.mule.construct.AbstractPipeline.doInitialise(AbstractPipeline.java:202)
    at org.mule.construct.AbstractFlowConstruct$1.onTransition(AbstractFlowConstruct.java:111)
    at org.mule.construct.AbstractFlowConstruct$1.onTransition(AbstractFlowConstruct.java:105)
    at org.mule.lifecycle.AbstractLifecycleManager.invokePhase(AbstractLifecycleManager.java:141)
    at org.mule.construct.FlowConstructLifecycleManager.fireInitialisePhase(FlowConstructLifecycleManager.java:81)
    at org.mule.construct.AbstractFlowConstruct.initialise(AbstractFlowConstruct.java:104)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1581)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1522)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
    at org.mule.config.spring.SpringRegistry.doInitialise(SpringRegistry.java:89)
    at org.mule.registry.AbstractRegistry.initialise(AbstractRegistry.java:109)
    at org.mule.config.spring.SpringXmlConfigurationBuilder.createSpringRegistry(SpringXmlConfigurationBuilder.java:116)
    at org.mule.config.spring.SpringXmlConfigurationBuilder.doConfigure(SpringXmlConfigurationBuilder.java:73)
    at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:46)
    at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:78)
    at org.mule.config.builders.AutoConfigurationBuilder.autoConfigure(AutoConfigurationBuilder.java:101)
    at org.mule.config.builders.AutoConfigurationBuilder.doConfigure(AutoConfigurationBuilder.java:57)
    at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:46)
    at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:78)
    at org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:80)
    at org.mule.module.launcher.application.DefaultMuleApplication.init(DefaultMuleApplication.java:208)
    at org.mule.module.launcher.application.ApplicationWrapper.init(ApplicationWrapper.java:64)
    at org.mule.module.launcher.DefaultMuleDeployer.deploy(DefaultMuleDeployer.java:46)
    at org.mule.tooling.server.application.ApplicationDeployer.run(ApplicationDeployer.java:56)
    at org.mule.tooling.server.application.ApplicationDeployer.main(ApplicationDeployer.java:88)

我不明白我做错了什么。

4

2 回答 2

2

您的第一个问题是您没有看到真正的错误消息来告诉您样式表出了什么问题。异常堆栈跟踪只告诉你有错误,它不会告诉你它们是什么。我不知道 Mule,但堆栈跟踪显示它在下面调用 Saxon。Saxon 会将错误消息写入 System.err;您需要找到某种方法来确保您看到 System.err 中的内容,或者将错误重定向到其他地方。在不了解 Mule 的情况下,我无法告诉您如何实现。

样式表没有明显的问题,所以我猜你正在编译的代码不是你想象的那样。解决第一个问题(以便您可以看到错误消息)将帮助您解决第二个问题。

于 2013-10-30T00:00:08.350 回答
0

您的代码在我的机器上编译得很好..Mule3.3.2Java 1.6_37. 在失败之前,流程中是否有任何内容。尝试隔离您的流程xslt-transformer,看看它是否有帮助

于 2013-10-30T13:51:50.160 回答