0

我想在我的 XML (WSDL) 文件中删除标签之间的 s:element:

<wsdl:types>
  <s:schema elementFormDefault="qualified" targetNamespace="http://ws.cdyne.com/WeatherWS/">
  <s:element name="GetWeatherInformation">
  <s:complexType/>
   </s:element>
   <s:element name="GetWeatherInformationResponse">
   <s:complexType>
     <s:sequence>
       <s:element minOccurs="0" maxOccurs="1" name="GetWeatherInformationResult"    type="tns:ArrayOfWeatherDescription"/>
     </s:sequence>
     </s:complexType>
    </s:element>

        <s:complexType name="ArrayOfWeatherDescription">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="unbounded" name="WeatherDescription"  type="tns:WeatherDescription"/>
        </s:sequence>
        </s:complexType>
        <s:complexType name="WeatherDescription">
        <s:sequence>
           <s:element minOccurs="1" maxOccurs="1" name="WeatherID" type="s:short"/>
           <s:element minOccurs="0" maxOccurs="1" name="Description" type="s:string"/>
           <s:element minOccurs="0" maxOccurs="1" name="PictureURL" type="s:string"/>
       </s:sequence>
      </s:complexType>

       <s:element name="GetCityForecastByZIP">
        <s:complexType>
        <s:sequence>
           <s:element minOccurs="0" maxOccurs="1" name="ZIP" type="s:string"/>
        </s:sequence>
        </s:complexType>
        </s:element>

现在我想删除<s:element name="GetCityForecastByZIP"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="ZIP" type="s:string"/> </s:sequence> </s:complexType> </s:element>

当我在运行后在我的 .xslt 文件中使用此结构时,<xsl:template match="s:element[@name = 'GetCityForecastByZIP']" />我的控制台中出现错误,我该如何删除它?

我在我的 Mule-Console 中看到了这个错误

Exception in thread "main" org.mule.module.launcher.DeploymentInitException: TransformerConfigurationException: Failed to compile stylesheet. 1 error detected.
at org.mule.module.launcher.application.DefaultMuleApplication.init(DefaultMuleApplication.java:220)
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)
Caused by: org.mule.api.config.ConfigurationException: Error creating bean with name '_muleNotificationManager': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceName': Invocation of init method failed; nested exception is org.mule.api.lifecycle.InitialisationException: Failed to compile stylesheet. 1 error detected. (org.mule.api.lifecycle.InitialisationException) (org.mule.api.config.ConfigurationException)
    at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:52)
    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)
    ... 4 more
Caused by: org.mule.api.config.ConfigurationException: Error creating bean with name '_muleNotificationManager': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceName': Invocation of init method failed; nested exception is org.mule.api.lifecycle.InitialisationException: Failed to compile stylesheet. 1 error detected. (org.mule.api.lifecycle.InitialisationException)
    at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:52)
    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)
    ... 7 more
Caused by: org.mule.api.lifecycle.InitialisationException: Error creating bean with name '_muleNotificationManager': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceName': Invocation of init method failed; nested exception is org.mule.api.lifecycle.InitialisationException: Failed to compile stylesheet. 1 error detected.
    at org.mule.registry.AbstractRegistry.initialise(AbstractRegistry.java:117)
    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)
    ... 11 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_muleNotificationManager': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceName': Invocation of init method failed; nested exception is org.mule.api.lifecycle.InitialisationException: Failed to compile stylesheet. 1 error detected.
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1442)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:248)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:581)
    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)
    ... 14 more
        Caused by: org.springframework.beans.factory.BeanCreationException: Error creating                   bean with name 'serviceName': Invocation of init method failed; nested exception is org.mule.api.lifecycle.InitialisationException: Failed to compile stylesheet. 1 error detected.
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
    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.AbstractBeanFactory.isSingleton(AbstractBeanFactory.java:408)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:319)
    at org.springframework.context.support.AbstractApplicationContext.getBeanNamesForType(AbstractApplicationContext.java:1154)
    at org.mule.config.spring.ServerNotificationManagerConfigurator.getMergedListeners(ServerNotificationManagerConfigurator.java:83)
    at org.mule.config.spring.ServerNotificationManagerConfigurator.getObject(ServerNotificationManagerConfigurator.java:65)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
    ... 23 more
Caused by: org.mule.api.lifecycle.InitialisationException: Failed to compile stylesheet. 1 error detected.
    at org.mule.module.xml.transformer.XsltTransformer.initialise(XsltTransformer.java:142)
    at org.mule.processor.chain.AbstractMessageProcessorChain.initialise(AbstractMessageProcessorChain.java:79)
    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:161)
    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 org.mule.config.spring.factories.AbstractFlowConstructFactoryBean.initialise(AbstractFlowConstructFactoryBean.java:115)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    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)
    ... 35 more
Caused by: 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)
    ... 52 more

这是我的 .xslt 文件:

<?xml version='1.0' ?>
    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">

 <xsl:output method="xml" version="1.0" encoding="UTF-8" omit-xml-declaration="yes"  indent="yes" />

   <xsl:template match="@*|node()"> 
        <xsl:copy copy-namespaces="yes">
          <xsl:apply-templates select="@*|node()"/>
        </xsl:copy> 
   </xsl:template>


      <xsl:template match="wsdl:operation[@name = 'GetCityWeatherByZIP']" />  
      <xsl:template match="wsdl:message[@name = 'GetCityWeatherByZIPSoapIn']" /> 
      <xsl:template match="wsdl:message[@name = 'GetCityWeatherByZIPSoapOut']" /> 

      <xsl:template match="wsdl:message[@name = 'GetCityWeatherByZIPHttpGetIn']" /> 
      <xsl:template match="wsdl:message[@name = 'GetCityWeatherByZIPHttpGetOut']" /> 

      <xsl:template match="wsdl:message[@name = 'GetCityWeatherByZIPHttpPostIn']" /> 
      <xsl:template match="wsdl:message[@name = 'GetCityWeatherByZIPHttpPostOut']" /> 

      <xsl:template match="s:element[@name = 'GetCityWeatherByZIP']" /> 


 </xsl:stylesheet>
4

2 回答 2

0

为了使用s:命名空间,您必须在 XSLT 中声明它:

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:s="http://www.w3.org/2001/XMLSchema">

这很可能是您的问题的原因。

于 2013-01-28T06:45:38.990 回答
0

JLRishe 已经很好地猜测了您的样式表出了什么问题,但没有必要猜测。您已经向我们展示了堆栈跟踪,它显示 XSLT 处理器报告了编译时错误,但您没有向我们展示这些错误,这可能意味着您没有看到它们。默认情况下,它们将转到标准错误输出,如果您从 Java 应用程序编译,则需要确保将诊断结果定向到可以看到它们的位置。修复样式表中的当前编码错误,而不修复运行编译器的问题,以便您将来看到诊断,不会让您走得更远。

您当然可以尝试在 IDE 中开发样式表,以便在部署代码之前检测到此类错误。但即便如此,您也应该投资创建一个健壮的日志框架,您可以在其中找到错误消息。

于 2013-01-28T09:17:32.430 回答