如何通过xsd从xml中删除空标记或空标记
下面是我的xml;我使用datastage ETL工具通过xsd生成这个xml,现在我的需求在下面的xml中,我没有Notes标记的数据,尽管我在xml中得到了Notes标记,但我不想在我的xml中显示;你能建议我如何去掉那个标签吗如何通过xsd从xml中删除空标记或空标记,xml,xsd,Xml,Xsd,下面是我的xml;我使用datastage ETL工具通过xsd生成这个xml,现在我的需求在下面的xml中,我没有Notes标记的数据,尽管我在xml中得到了Notes标记,但我不想在我的xml中显示;你能建议我如何去掉那个标签吗 <term rid="6662c0f2.e1b1ec6c.a1fk8pal9.8hqrjus.6af65b.8lr7d8vtg6ibohsre1bni" name="Test Term" longDesc
<term
rid="6662c0f2.e1b1ec6c.a1fk8pal9.8hqrjus.6af65b.8lr7d8vtg6ibohsre1bni"
name="Test Term" longDescription=" " status="CANDIDATE"
example=" " type="NONE" isModifier="false" workflowStatus="Published">
<parentCategory identity="Test Category_Edit" rid="6662c0f2.ee6a64fe.a1fk62v4g.c0kd2bc.0rjqdm.feik8m3int29gfigeshsp"/>
<replacedByTerm identity="Test Category_Edit::TestTerm 6" rid="6662c0f2.e1b1ec6c.a1fka7kac.1khu23o.2u72oe.bhpdj3dkdshb026mkdqks"/>
<referencedByCategories>
<categoryRef identity="Test RuleBook Category"
rid="6662c0f2.ee6a64fe.a1fkahnel.nso45vp.cns86c.758gjtic3rakunadr1v1k"
xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<categoryRef identity="Test ACE Category"
rid="6662c0f2.ee6a64fe.a1fkahnel.nso4pkh.3pmfh7.ccc8kcdsml2s8hdhtld7k"
xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</referencedByCategories>
<assignedAssets>
<BIReportMemberRef
reportModel="GAS Reporting - Detail"
reportModelNameSpace="sat1msmap054.nao.global.gmacfs.com\Public Folders\Auto Finance Packages\GAS Reporting - Detail\GAS Reporting - Detail\"
reportCollection="DIM_CONTRACT_ORA"
reportCollectionNameSpace="GAS Reporting - Detail/GAS - Database View"
reportMember="TERM"
nameSpace="[GAS - Database View].[DIM_CONTRACT_ORA]"
xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</assignedAssets>
<customAttributes>
<customAttributeValue
customAttribute="ERM - General Process Category"
value="Advertising and Marketing"
xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<customAttributeValue customAttribute="Changecode"
value="Y" xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<customAttributeValue
customAttribute="Test Attribute 1" value="2"
xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<customAttributeValue
customAttribute="03. Is Reference Data?"
value="Yes" xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<customAttributeValue
customAttribute="06. Data Quality Performed?"
value="No" xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</customAttributes>
<relatedTerms>
<termRef identity="Test Category_Edit::Test Term5"
rid="6662c0f2.e1b1ec6c.a1fka7kac.1khv5h5.dmdrre.h0dusknvjnvdde1osbv1s"
xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<termRef identity="Test Category_Edit::TestTerm 7"
rid="6662c0f2.e1b1ec6c.a1fka7kac.1khuk2l.erslsg.shh1dj9auomm9p97vr5us"
xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</relatedTerms>
<note/>
<labels>
<label name="DFS Rulebook" xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<label name="FR Y-9C H1-B Retail" xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<label name="DFS - Servicing" xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</labels>
<steward userName="M7HA75" type="USER"/>
</term>
正如@potame所说,方法是XSL-T。。您可以使用以下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="*[not(@*|*|comment()|processing-instruction()) and normalize-space()='']"/>
</xsl:stylesheet>
上述XSL删除所有空标记。XSD的目的不是修改XML文档,而是验证它们。你的意思是XSL-T XSL转换吗?但我只通过xsd生成这个xml;下面是xsd@123srinu。您解决了这个问题吗?如果你已经解决了,你是怎么做的?