简体   繁体   中英

How to remove all empty tags from xml using xslt

my xml is :

    <content type="text/html" title="flow-active-timeout">
<body>    
    <dl>
    </dl>
    <p>&#160;</p>

    <div mt-section-origin="Product_Documentation/Command_Reference/Configuration_Commands/flow-active-timeout" class="mt-section" id="section_1"><span id="vManage_Feature_Template"></span><h2 class="editable">vManage Feature Template</h2>

    <p>For vSmart controllers:</p>

    <p>Configuration &#9658; Policies&#160;&#9658; Centralized Policy</p>

    </div>
</body>

and my xslt code is :

<xsl:template match="*[not(normalize-space(translate(., '&#160;', ' ')))]"/>

but it removes only empty <p> tag not <dl> tag

Output using above xslt:

<body>
<dl/>
<div mt-section-origin="Product_Documentation/Command_Reference/Configuration_Commands/flow-active-timeout" class="mt-section" id="section_1"><span id="vManage_Feature_Template"></span><h2 class="editable">vManage Feature Template</h2>

    <p>For vSmart controllers:</p>

    <p>Configuration &#9658; Policies&#160;&#9658; Centralized Policy</p>

    </div>
</body>

expected output is :

    <body>
<div mt-section-origin="Product_Documentation/Command_Reference/Configuration_Commands/flow-active-timeout" class="mt-section" id="section_1"><span id="vManage_Feature_Template"></span><h2 class="editable">vManage Feature Template</h2>

    <p>For vSmart controllers:</p>

    <p>Configuration &#9658; Policies&#160;&#9658; Centralized Policy</p>

    </div>
</body>

Please provide some statement to achieve the expected output

<xsl:template match="*[text()='&#160;' or  normalize-space(.)='']"/>
You may also use like this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM