[xsl] Empty nodes AND attributes stripping - I'm so lost

Subject: [xsl] Empty nodes AND attributes stripping - I'm so lost
From: "Kevinjohn Gallagher" <web_design_guru@xxxxxxxxxxx>
Date: Thu, 02 Sep 2004 16:25:52 +0100
ORIGINAL :

<?xml version="1.0" encoding="UTF-16"?>
<parent>
	<myContent>
		<url></url>
		<headline>This is a test.</headline>
		<abstract>An Abstract.</abstract>
		<media src="a.gif" caption="" />
	</myContent>
	<myContent>
		<url></url>
		<headline></headline>
		<abstract></abstract>
	</myContent>

<myContent>
<something attr="" attribute="data" anotherattribute="data"> SomeData</something>
<somethingElse>
<emptychild />
</somethingElse>
<somethingElse>
<child> With Data </child>
</somethingElse>
</myContent>
</parent>




SHOULD BECOME :

<?xml version="1.0" encoding="UTF-16"?>
<parent>

	<myContent>
		<headline>This is a test.</headline>
		<abstract>An Abstract.</abstract>
		<media src="a.gif" />
	</myContent>


<myContent />



<myContent> <something attribute="data" anotherattribute="data"> SomeData</something> <somethingElse> <child> With Data </child> </somethingElse> </myContent>

</parent>








Ok, so I have an XML file, where I can have any number of myContent's, which can have any number of Children (and they can have children).


Basically, I want to strip all EMPTY nodes and EMPTY attributes.

I've got the empty node stipping fine, but the attributes is an issue (i don't know the names or how many there will be).

Especially as a node can hold no data or children, but can have an attribute with data, so I need to keep it.

Also, the myContent tags need to stay.

I'm really really lost. This seems to be like it should be simple. :(

Can anyone help?


Thanks ALot


Bryan.

Current Thread