0

我有下一个 WSDL 文件

    <definitions targetNamespace="http://soft.com/" name="LoggingWebService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://ws.config.softid.softcomputer.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
      <types>
        <xsd:schema>
          <xsd:import namespace="http://soft.com/" schemaLocation="my.xsd"/>
        </xsd:schema>
      </types>
      <message name="log">
        <part name="parameters" element="tns:log"/>
      </message>
      <message name="getLogs">
        <part name="parameters" element="tns:getLogs"/>
      </message>
   <portType name="LoggingWebService">
       <operation name="log">
           <input message="tns:log"/>
       </operation>
       <operation name="getLogs">
           <input message="tns:getLogs"/>
           <output message="tns:getLogsResponse"/>
      </operation>
  </portType>
</definitions>  

我想将此文件转换javax.transformation为另一个文件,该文件messages将按字母排序(使用“名称”中的字符串)。

<definitions targetNamespace="http://soft.com/" name="LoggingWebService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://ws.config.softid.softcomputer.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
  <types>
    <xsd:schema>
      <xsd:import namespace="http://soft.com/" schemaLocation="my.xsd"/>
    </xsd:schema>
  </types>
  <message name="getLogs">
    <part name="parameters" element="tns:getLogs"/>
  </message>
    <message name="log">
    <part name="parameters" element="tns:log"/>
  </message>
   <portType name="LoggingWebService">
       <operation name="getLogs">
            <input message="tns:getLogs"/>
            <output message="tns:getLogsResponse"/>
       </operation>
       <operation name="log">
           <input message="tns:log"/>
       </operation>

   </portType>

</definitions>  

为此我需要什么 XSLT 文件?请帮帮我

4

1 回答 1

1

此样式表也适用于您上一个问题中的文件。

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

  <xsl:output method="xml" indent="yes" />
  <xsl:strip-space elements="*"/> 

  <xsl:template match="/wsdl:definitions" >

    <xsl:copy>

      <xsl:copy-of select="wsdl:types" />

      <xsl:apply-templates select="wsdl:message" >
        <xsl:sort select="@name" />
      </xsl:apply-templates>

      <xsl:apply-templates select="wsdl:portType" />

    </xsl:copy>

  </xsl:template>

  <xsl:template match="wsdl:message">
    <xsl:copy-of select="current()"/>
  </xsl:template>

  <xsl:template match="wsdl:portType">
    <xsl:copy>
      <xsl:apply-templates select="wsdl:operation">
        <xsl:sort select="@name"/>
      </xsl:apply-templates>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="wsdl:operation">
    <xsl:copy-of select="current()"/>
  </xsl:template>

</xsl:stylesheet>

输出

<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/">
   <types>
      <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
         <xsd:import namespace="http://soft.com/" schemaLocation="my.xsd"/>
      </xsd:schema>
   </types>
   <message name="getLogs">
      <part element="tns:getLogs" name="parameters"/>
   </message>
   <message name="log">
      <part element="tns:log" name="parameters"/>
   </message>
   <portType>
      <operation name="getLogs">
         <input message="tns:getLogs"/>
         <output message="tns:getLogsResponse"/>
      </operation>
      <operation name="log">
         <input message="tns:log"/>
      </operation>
   </portType>
</definitions>
于 2012-05-25T15:33:13.653 回答