如果子元素为空,我在使用XSLT转换文件以删除父节点时遇到问题。我尝试使用不同的值,但它们都按原样保留输出。任何人都可以让我知道处理这个问题的方法。
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 xmlns:ns1="http://www.taleo.com/ws/integration/toolkit/2005/07" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<Document xmlns="http://www.taleo.com/ws/integration/toolkit/2005/07">
<Attributes>
<Attribute name="count">89</Attribute>
<Attribute name="duration">0:00:00.088</Attribute>
<Attribute name="entity">Candidate</Attribute>
<Attribute name="mode">XML</Attribute>
<Attribute name="version">http://www.taleo.com/ws/tee800/2009/01</Attribute>
</Attributes>
<Content>
<ExportXML>
<record>
<field name="Identifier">2341905</field>
<field name="CandidateNumber">2341905</field>
<field name="RequisitionNumber">AUS053476</field>
<field name="Sequence" />
<field name="EmploymentCheckDue">Pre-start date,Requested,28. Directorship,2016-07-29</field>
</record>
<record>
<field name="Identifier">2341905</field>
<field name="CandidateNumber">2341905</field>
<field name="RequisitionNumber">AUS053476</field>
<field name="Sequence" />
<field name="EmploymentCheckDue">Pre-start date,Requested,28. Directorship,2016-07-29</field>
</record>
<record>
<field name="Identifier">2341905</field>
<field name="CandidateNumber">2341905</field>
<field name="RequisitionNumber">AUS053476</field>
<field name="Sequence" />
<field name="EmploymentCheckDue">Pre-start date,Requested,26. Dodd-Frank Check,2016-07-29</field>
</record>
<record>
<field name="Identifier">2341905</field>
<field name="CandidateNumber">2341905</field>
<field name="RequisitionNumber">AUS053476</field>
<field name="Sequence" />
<field name="EmploymentCheckDue">Pre-start date,Requested,22. Credit / Bankruptcy / ASIC / APRA,2016-07-29</field>
</record>
<record>
<field name="Identifier">2341905</field>
<field name="CandidateNumber">2341905</field>
<field name="RequisitionNumber">AUS053476</field>
<field name="Sequence" />
<field name="EmploymentCheckDue" />
</record>
<record>
<field name="Identifier">2341905</field>
<field name="CandidateNumber">2341905</field>
<field name="RequisitionNumber">AUS053476</field>
<field name="Sequence" />
<field name="EmploymentCheckDue">Pre-start date,Requested,16. Education / professional,2016-07-29</field>
</record>
<record>
<field name="Identifier">2341905</field>
<field name="CandidateNumber">2341905</field>
<field name="RequisitionNumber">AUS053476</field>
<field name="Sequence" />
<field name="EmploymentCheckDue" />
</record>
<record>
<field name="Identifier">2341905</field>
<field name="CandidateNumber">2341905</field>
<field name="RequisitionNumber">AUS053476</field>
<field name="Sequence" />
<field name="EmploymentCheckDue" />
</record>
</ExportXML>
</Content>
</Document>
</ns1:getDocumentByKeyResponse>
</soapenv:Body>
</soapenv:Envelope>
XSL:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="record[not(field = '')]"/>
</xsl:stylesheet>