如何使用XSLT转换删除不需要的soap信封属性标记值

如何使用XSLT转换删除不需要的soap信封属性标记值,xslt,xslt-2.0,Xslt,Xslt 2.0,我有一个包含xml的soap信封。我想删除该标记值。我使用的是saxon9解析器。我的输入xml是: <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org /soap/envelope/" xmlns:xsd="

我有一个包含xml的soap信封。我想删除该标记值。我使用的是saxon9解析器。我的输入xml是:

             <?xml version="1.0" encoding="UTF-8"?>
             <soapenv:Envelope  xmlns:soapenv="http://schemas.xmlsoap.org  /soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
             <soapenv:Body><ns1:getDocumentByKeyResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://www.taleo.com/ws/integration/toolkit/2005/07">
                  <Document xmlns="http://www.taleo.com/ws/integration/toolkit/2005/07">
              <Attributes><Attribute name="duration">0:00:13.629</Attribute><Attribute name="count">121</Attribute><Attribute name="entity">Requisition</Attribute>
             <Attribute name="mode">XML</Attribute>
            <Attribute name="version">http://www.taleo.com/ws/tee800/2009/01</Attribute>
            </Attributes><Content>
            <ExportXML xmlns="http://www.taleo.com/ws/integration/toolkit/2005/07">
           <record>
    <field name="JobAction">2</field>
    <field name="JobType">false</field>
    <field name="JobPositionPostingID">000065</field>
    <field name="JobFunctionCode">ADMINISTRATION</field>
    </record>
      </ExportXML></Content></Document></ns1:getDocumentByKeyResponse>   
      </soapenv:Body>    </soapenv:Envelope>

0:00:13.629121请购单
XML
http://www.taleo.com/ws/tee800/2009/01
2.
假的
000065
管理
我的xsl文件是这样的

               <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
           <xsl:output  indent="yes" encoding="utf-8"/>
           <xsl:strip-space elements="*"/>

          <xsl:template match="*:field">
          <xsl:element name="{lower-case(@name)}">
          <xsl:apply-templates/>     
          </xsl:element>
          </xsl:template>
          <xsl:template match="*:ExportXML">
           <JobPositionPostings>
                <xsl:apply-templates/>
           </JobPositionPostings>
        </xsl:template>
      <xsl:template match="*:record">
     <JobPositionPosting>
      <xsl:apply-templates select="*:field[starts-with(@name,'JobAction')]"/>
       <HiringOrg>
      <xsl:apply-templates select="*:field[starts-with(@name,'JobType')]"/>
     <Industry>
      <xsl:apply-templates select="*:field[starts-with(@name,'JobPositionPostingID')]"/>
        </Industry>
       </HiringOrg>
       </JobPositionPosting>
     <xsl:apply-templates select="*:field[starts-with(@name,'JobFeedResponseEmail')]"/>
      </xsl:template>
       <xsl:template match="*:field[@name='TypeName']"/>
      <xsl:template match="*:field[@name='TypeName']" mode="title">
      <xsl:apply-templates/>
     </xsl:template>  
     </xsl:stylesheet>
<?xml version="1.0" encoding="utf-8"?>**0:00:13.629121RequisitionXMLhttp://www.taleo.com/ws/tee800/2009/01**<JobPositionPostings xmlns:soap="http://www.taleo.com/ws/integration/toolkit/2005/07">
    <JobPositionPosting>
  <jobaction>2</jobaction>
  <jobtype>false</jobtype>
  <jobpositionpostingid>000065</jobpositionpostingid>
  <HiringOrg>

我得到这样的输出

               <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
           <xsl:output  indent="yes" encoding="utf-8"/>
           <xsl:strip-space elements="*"/>

          <xsl:template match="*:field">
          <xsl:element name="{lower-case(@name)}">
          <xsl:apply-templates/>     
          </xsl:element>
          </xsl:template>
          <xsl:template match="*:ExportXML">
           <JobPositionPostings>
                <xsl:apply-templates/>
           </JobPositionPostings>
        </xsl:template>
      <xsl:template match="*:record">
     <JobPositionPosting>
      <xsl:apply-templates select="*:field[starts-with(@name,'JobAction')]"/>
       <HiringOrg>
      <xsl:apply-templates select="*:field[starts-with(@name,'JobType')]"/>
     <Industry>
      <xsl:apply-templates select="*:field[starts-with(@name,'JobPositionPostingID')]"/>
        </Industry>
       </HiringOrg>
       </JobPositionPosting>
     <xsl:apply-templates select="*:field[starts-with(@name,'JobFeedResponseEmail')]"/>
      </xsl:template>
       <xsl:template match="*:field[@name='TypeName']"/>
      <xsl:template match="*:field[@name='TypeName']" mode="title">
      <xsl:apply-templates/>
     </xsl:template>  
     </xsl:stylesheet>
<?xml version="1.0" encoding="utf-8"?>**0:00:13.629121RequisitionXMLhttp://www.taleo.com/ws/tee800/2009/01**<JobPositionPostings xmlns:soap="http://www.taleo.com/ws/integration/toolkit/2005/07">
    <JobPositionPosting>
  <jobaction>2</jobaction>
  <jobtype>false</jobtype>
  <jobpositionpostingid>000065</jobpositionpostingid>
  <HiringOrg>
**0:00:13.629121requisionxmlhttp://www.taleo.com/ws/tee800/2009/01**
2.
假的
000065

在xml标记之后,它将拾取我不想要的所有属性标记值。

因为您似乎不关心
之外的任何内容,所以可以添加一个额外的模板直接跳到该模板,而忽略其余部分:

<xsl:template match="/">
  <xsl:apply-templates select="descendant::*:Content[1]" />
</xsl:template>

如果您添加像这样的空模板

 <xsl:template match="*:Attributes"/>

(注意末尾的斜线)


所有属性元素都将被忽略。

非常感谢。我得到了正确的输出。我已经搜索了很多次了。真的谢谢