That works great. Thanks
"Dimitre Novatchev" <dnovatchev@cnntp.org> wrote in message
news:Omnqi%23TRJHA.4512@TK2MSFTNGP02.phx.gbl...
>
> "Gan Kol" <gankol@gmail.com> wrote in message
> news:uYgPV9PRJHA.5080@TK2MSFTNGP05.phx.gbl...
>> Hi,
>>
>> I have an xml something like this.
>> <Test>
>> <Type>New</Type>
>> <Lang>
>> <English>
>> <Screenplay>test11</Screenplay>
>> <Script>script11</Script>
>> </English>
>> <ExpiryDate>2009-10-10</ExpiryDate>
>> </Lang>
>> <StudentNumber>1234333</StudentNumber>
>> <RequestDate>2008-10-10</RequestDate>
>> <FirstName>David</FirstName>
>> <MiddleName>-</MiddleName>
>> <LastName>Burges</LastName>
>> <Qualifier>-</Qualifier>
>> <Status></Status>
>> </Test>
>>
>> I would like to have an output xml as the same structure as above, but
>> Omit the elements if a "-" is the only data in the element (for eg.
>> should keep the date element expiry date, but omit MiddleName, Qualifier)
>> Since i dont know about the xml data and structure inside the xml when
>> doing the xsl transformation, i tried using xsl copy instead of select,
>> but didnt know how to check for the conditions.
>
>
> The following override of the identity transformation is a natural
> solution:
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl
utput 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=
> "*[text() and not(node()[not(self::text())])]
> [normalize-space() = '-']"/>
> </xsl:stylesheet>
>
> When applied on the originally specified xml document:
>
> <Test>
> <Type>New</Type>
> <Lang>
> <English>
> <Screenplay>test11</Screenplay>
> <Script>script11</Script>
> </English>
> <ExpiryDate>2009-10-10</ExpiryDate>
> </Lang>
> <StudentNumber>1234333</StudentNumber>
> <RequestDate>2008-10-10</RequestDate>
> <FirstName>David</FirstName>
> <MiddleName>-</MiddleName>
> <LastName>Burges</LastName>
> <Qualifier>-</Qualifier>
> <Status></Status>
> </Test>
>
> the wanted result is produced:
>
> <Test>
> <Type>New</Type>
> <Lang>
> <English>
> <Screenplay>test11</Screenplay>
> <Script>script11</Script>
> </English>
> <ExpiryDate>2009-10-10</ExpiryDate>
> </Lang>
> <StudentNumber>1234333</StudentNumber>
> <RequestDate>2008-10-10</RequestDate>
> <FirstName>David</FirstName>
> <LastName>Burges</LastName>
> <Status/>
> </Test>
>
> Hope this helped.
>
> Cheers,
> Dimitre Novatchev
>