gpt4 book ai didi

XSLT 链接或组合 xsl :copy-of and xsl:copy

转载 作者:行者123 更新时间:2023-12-01 15:55:03 26 4
gpt4 key购买 nike

我有以下两个 XSL 转换,我希望将它们链接到一个 XSL 文件中。

第一次转换:

<xsl:stylesheet 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:s0="http://schemas.xmlsoap.org/wsdl/">
<xsl:template match="/">
<xsl:copy-of select="/s0:definitions/s0:types/xs:schema"/>
</xsl:template>
</xsl:stylesheet>

第二个转换(使用第一个转换的输出作为输入):

<xsl:stylesheet 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:s0="http://schemas.xmlsoap.org/wsdl/">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/xs:schema/xs:element[@name='ServiceAuth']"/>
<xsl:template match="/xs:schema/xs:import[@namespace='http://www.somecompany.com/serviceAuth/ ']"/>
</xsl:stylesheet>

我的目标是从 WSDL 中仅复制 xs:schema 节点(及其所有子节点),同时从 xs:schema 节点内部删除两个节点。

如何将这两者链接到一个 XSL 中,或者是否有更好的方法来实现上述目标?

下面是应作为第一个转换的输入的 WSDL 输入文件:

<s0:definitions name="CBS_GetUpgradeEligibility" targetNamespace="http://www.somecompany.com/" xmlns:s0="http://schemas.xmlsoap.org/wsdl/" xmlns:s1="http://www.somecompany.com/CBS_GetUpgradeEligibility/" xmlns:s2="http://www.somecompany.com/" xmlns:s3="http://schemas.xmlsoap.org/wsdl/soap/">
<s0:types>
<xs:schema targetNamespace="http://www.somecompany.com/CBS_GetUpgradeEligibility/" xmlns:auth="http://www.somecompany.com/serviceAuth/" xmlns:cbs="http://www.somecompany.com/CBS_GetUpgradeEligibility/" xmlns:esb="http://www.somecompany.com/esbTypes/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.somecompany.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://www.somecompany.com/esbTypes/" schemaLocation="http://127.0.0.1:5000/CBS_GetUpgradeEligibility?SCHEMA%2FVodacom+Services%2FInfrastructure+Services%2FSchemas%2FXSD_ESBTypes"/>
<xs:import namespace="http://www.somecompany.com/serviceAuth/ " schemaLocation="http://127.0.0.1:5000/CBS_GetUpgradeEligibility?SCHEMA%2FVodacom+Services%2FInfrastructure+Services%2FSchemas%2FXSD_ServiceAuth"/>
<xs:simpleType name="DESTINATION_MSISDN">
<xs:restriction base="xs:string">
<xs:maxLength value="11"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="STRING_13">
<xs:restriction base="xs:string">
<xs:maxLength value="13"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="STRING_20">
<xs:restriction base="xs:string">
<xs:maxLength value="20"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="UPGRADE_TYPE_DETAILS">
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="isber" type="cbs:STRING_13"/>
<xs:element maxOccurs="1" minOccurs="1" name="isreward" type="cbs:STRING_13"/>
<xs:element maxOccurs="1" minOccurs="1" name="code" type="cbs:STRING_20"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="QUALIFIES_FOR_UPGRADE_DETAILS">
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="isaveragespentmet" type="cbs:STRING_13"/>
<xs:element maxOccurs="1" minOccurs="1" name="is7daypremature" type="cbs:STRING_13"/>
<xs:element maxOccurs="1" minOccurs="1" name="upgradepossible" type="cbs:STRING_13"/>
<xs:element maxOccurs="1" minOccurs="1" name="upgradeduedate" type="cbs:STRING_13"/>
<xs:element maxOccurs="1" minOccurs="0" name="UpgradeType" type="cbs:UPGRADE_TYPE_DETAILS"/>
</xs:sequence>
</xs:complexType>
<xs:element name="ServiceAuth">
<xs:complexType>
<xs:sequence>
<xs:element name="Username" type="auth:Username"/>
<xs:element name="Password" type="auth:Password"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetUpgradeEligibilityRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="TSORequest" type="cbs:getUpgradeEligibilityRequestElement"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetUpgradeEligibilityResponse">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="TSOID" type="esb:TSOID"/>
<xs:element name="TSOResponse" type="cbs:getUpgradeEligibilityResponseElement"/>
<xs:element maxOccurs="1" minOccurs="1" name="TSOResult" type="esb:TSOResult"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="getUpgradeEligibilityRequestElement">
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="MSISDN" type="cbs:DESTINATION_MSISDN"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="getUpgradeEligibilityResponseElement">
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="MSISDN" type="cbs:DESTINATION_MSISDN"/>
<xs:element maxOccurs="1" minOccurs="1" name="QualifiesForUpgrade" type="cbs:QUALIFIES_FOR_UPGRADE_DETAILS"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</s0:types>
<s0:message name="GetUpgradeEligibilityRequestMessage">
<s0:part element="s1:ServiceAuth" name="ServiceAuth"/>
<s0:part element="s1:GetUpgradeEligibilityRequest" name="GetUpgradeEligibilityRequest"/>
</s0:message>
<s0:message name="GetUpgradeEligibilityResponseMessage">
<s0:part element="s1:GetUpgradeEligibilityResponse" name="GetUpgradeEligibilityResponse"/>
</s0:message>
<s0:portType name="esbTransactionPort">
<s0:operation name="getUpgradeEligibility">
<s0:input message="s2:GetUpgradeEligibilityRequestMessage"/>
<s0:output message="s2:GetUpgradeEligibilityResponseMessage"/>
</s0:operation>
</s0:portType>
<s0:binding name="getUpgradeEligibilityEsbTransactionBinding" type="s2:esbTransactionPort">
<s3:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<s0:operation name="getUpgradeEligibility">
<s3:operation soapAction="" style="document"/>
<s0:input>
<s3:header message="s2:GetUpgradeEligibilityRequestMessage" part="ServiceAuth" use="literal"/>
<s3:body parts="GetUpgradeEligibilityRequest" use="literal"/>
</s0:input>
<s0:output>
<s3:body parts="GetUpgradeEligibilityResponse" use="literal"/>
</s0:output>
</s0:operation>
</s0:binding>
<s0:service name="getUpgradeEligibilityEsbTransactionBindingQSService">
<s0:port binding="s2:getUpgradeEligibilityEsbTransactionBinding" name="getUpgradeEligibilityEsbTransactionBindingQSPort">
<s3:address location="http://VESB14-PRD:7701/CBS_GetUpgradeEligibility"/>
</s0:port>
</s0:service>
</s0:definitions>

最佳答案

如果您想要第三个样式表来组成这两个样式表,执行相同的转换:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:s0="http://schemas.xmlsoap.org/wsdl/">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/">
<xsl:apply-templates select="s0:definitions/s0:types/xs:schema"/>
</xsl:template>
<xsl:template match="xs:schema/xs:element[@name='ServiceAuth']"/>
<xsl:template match="xs:schema/xs:import[@namespace='http://www.somecompany.com/serviceAuth/']"/>
</xsl:stylesheet>

那么你需要:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:import href="stylesheet2.xsl"/>
<xsl:import href="stylesheet1.xsl"/>
<xsl:template match="/">
<xsl:variable name="vFirst">
<xsl:apply-imports/>
</xsl:variable>
<xsl:apply-templates select="msxsl:node-set($vFirst)/node()"/>
</xsl:template>
</xsl:stylesheet>

输出:

<xs:schema targetNamespace="http://www.somecompany.com/CBS_GetUpgradeEligibility/" xmlns:s0="http://schemas.xmlsoap.org/wsdl/" xmlns:s1="http://www.somecompany.com/CBS_GetUpgradeEligibility/" xmlns:s2="http://www.somecompany.com/" xmlns:s3="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:auth="http://www.somecompany.com/serviceAuth/" xmlns:cbs="http://www.somecompany.com/CBS_GetUpgradeEligibility/" xmlns:esb="http://www.somecompany.com/esbTypes/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.somecompany.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://www.somecompany.com/esbTypes/" schemaLocation="http://127.0.0.1:5000/CBS_GetUpgradeEligibility?SCHEMA%2FVodacom+Services%2FInfrastructure+Services%2FSchemas%2FXSD_ESBTypes"></xs:import>
<xs:simpleType name="DESTINATION_MSISDN">
<xs:restriction base="xs:string">
<xs:maxLength value="11"></xs:maxLength>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="STRING_13">
<xs:restriction base="xs:string">
<xs:maxLength value="13"></xs:maxLength>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="STRING_20">
<xs:restriction base="xs:string">
<xs:maxLength value="20"></xs:maxLength>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="UPGRADE_TYPE_DETAILS">
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="isber" type="cbs:STRING_13"></xs:element>
<xs:element maxOccurs="1" minOccurs="1" name="isreward" type="cbs:STRING_13"></xs:element>
<xs:element maxOccurs="1" minOccurs="1" name="code" type="cbs:STRING_20"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="QUALIFIES_FOR_UPGRADE_DETAILS">
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="isaveragespentmet" type="cbs:STRING_13"></xs:element>
<xs:element maxOccurs="1" minOccurs="1" name="is7daypremature" type="cbs:STRING_13"></xs:element>
<xs:element maxOccurs="1" minOccurs="1" name="upgradepossible" type="cbs:STRING_13"></xs:element>
<xs:element maxOccurs="1" minOccurs="1" name="upgradeduedate" type="cbs:STRING_13"></xs:element>
<xs:element maxOccurs="1" minOccurs="0" name="UpgradeType" type="cbs:UPGRADE_TYPE_DETAILS"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="GetUpgradeEligibilityRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="TSORequest" type="cbs:getUpgradeEligibilityRequestElement"></xs:element>
</xs:sequence>
</xs:complexType></xs:element>
<xs:element name="GetUpgradeEligibilityResponse">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="TSOID" type="esb:TSOID"></xs:element>
<xs:element name="TSOResponse" type="cbs:getUpgradeEligibilityResponseElement"></xs:element>
<xs:element maxOccurs="1" minOccurs="1" name="TSOResult" type="esb:TSOResult"></xs:element>
</xs:sequence>
</xs:complexType></xs:element>
<xs:complexType name="getUpgradeEligibilityRequestElement">
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="MSISDN" type="cbs:DESTINATION_MSISDN"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="getUpgradeEligibilityResponseElement">
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="MSISDN" type="cbs:DESTINATION_MSISDN"></xs:element>
<xs:element maxOccurs="1" minOccurs="1" name="QualifiesForUpgrade" type="cbs:QUALIFIES_FOR_UPGRADE_DETAILS"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>

关于XSLT 链接或组合 xsl :copy-of and xsl:copy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5639095/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com