我有包含 xml 的肥皂信封。我想删除该标签值。我正在使用 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>
我的 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>
在 xml 标记之后,它会选择我不想要的所有属性标记值。