XSLT to remove empty nodes

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi. I was wondering if someone could help me with a stylesheet.
Source XML:

<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; SupplyWeb_Data<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; PurchaseOrder<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; PO_Header<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; some_field <span style="color:Red; value<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 00<span style="color:Black; "<span style="color:Blue; ><span style="color:Blue; </<span style="color:#A31515; some_field<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; PO_Header<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; PO_Detail<span style="color:Blue; >
<some_field2 value=" <span style="color:Blue; </<span style="color:#A31515; some_field2<span style="color:Blue; >
...
<span style="color:Blue; </<span style="color:#A31515; PO_Detail<span style="color:Blue; >
[PO_Detail can repeat]
<span style="color:Blue; </<span style="color:#A31515; PurchaseOrder<span style="color:Blue; >
[PurchaseOrder can repeat]
<span style="color:Blue; </<span style="color:#A31515; SupplyWeb_Data<span style="color:Blue; >
[/code]

Output, removed some_field2 element because value attribute was empty.

<pre><SupplyWeb_Data>
<PurchaseOrder>
<PO_Header>
<some_field value="00 </some_field>
</PO_Header>
<PO_Detail>
...
</PO_Detail>
[PO_Detail can repeat]
</PurchaseOrder>
[PurchaseOrder can repeat]
</SupplyWeb_Data>[/code]
<br/>
Thanks for any pointers.


View the full article
 
Back
Top