Mule XSLT没有编译

时间:2013-10-29 20:11:38

标签: xslt mule

我正在使用Mule 3.3.1 CE。

如果XSL位于文件的外部,我无法使XSLT Transformer工作。

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

<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)

我不明白我做错了什么。

2 个答案:

答案 0 :(得分:2)

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

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

答案 1 :(得分:0)

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