This will do it.
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*" />
<xsl:output method="xml" indent="yes" encoding="UTF-8" />
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="Get_AccountNumber_List">
<xsl:apply-templates select="ACCOUNT-LIST" />
</xsl:template>
<xsl:template match="ACCOUNT-LIST">
<xsl:if test="string-length(ACCOUNT-NO) >0">
<xsl:copy-of select="." />
</xsl:if>
</xsl:template>
</xsl:stylesheet>
--
Charles Knell
cknell(_at_)onebox(_dot_)com - email
-----Original Message-----
From: neil cave <coraltrees(_at_)yahoo(_dot_)co(_dot_)uk>
Sent: Wed, 24 May 2006 12:35:20 +0000 (GMT)
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Writing array elements based on a an evaluation of one of
the child elements
In the example I want the result XML to write the first 2 occurences of
ACCOUNT-LIST because the have values in teh ACCOUNT-NO element.
Whereas occurence 3 of ACCOUNT-LIST has no ACCOUNT-NO and I don't want that
occurence in teh result doc.
----- Original Message ----
From: neil cave <coraltrees(_at_)yahoo(_dot_)co(_dot_)uk>
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Sent: Wednesday, 24 May, 2006 2:21:05 PM
Subject: Re: [xsl] Writing array elements based on a an evaluation of one of
the child elements
<?xml version="1.0" encoding="UTF-8"?>
<Get_AccountNumber_List>
<CLIENT_CODE6>BABICK 001</CLIENT_CODE6>
<ACCOUNT-LIST>
<ACCOUNT-NO>0000000054840004</ACCOUNT-NO>
<SBU-CODE>2</SBU-CODE>
<RISK_TYPE>CUR</RISK_TYPE>
</ACCOUNT-LIST>
<ACCOUNT-LIST>
<ACCOUNT-NO>0000000710207909</ACCOUNT-NO>
<SBU-CODE>2</SBU-CODE>
<RISK_TYPE>CMS</RISK_TYPE>
</ACCOUNT-LIST>
<ACCOUNT-LIST>
<ACCOUNT-NO></ACCOUNT-NO>
<SBU-CODE></SBU-CODE>
<RISK_TYPE></RISK_TYPE>
</ACCOUNT-LIST>
</Get_AccountNumber_List>
With XSL now =
<xsl:template match = "ACCOUNT-LIST">
<xsl:for-each select="." >
<xsl:if test="string-length(ACCOUNT-NO/text() > 0)">
<xsl:element name="ACCOUNT-LIST">
<xsl:value-of select="." />
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:template>
The result I get is that it writes all the data for all account-LIST elements
with no tages (excepts the ACCOUNT-LIST parent element tag) and it does not
evaluate the string-length test
----- Original Message ----
From: Florent Georges <darkman_spam(_at_)yahoo(_dot_)fr>
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Sent: Wednesday, 24 May, 2006 2:06:33 PM
Subject: Re: [xsl] Writing array elements based on a an evaluation of one of
the child elements
neil cave wrote:
<xsl:template match = "ACCOUNT-LIST">
<xsl:if test="string-length(ACCOUNT-NO/text() > 0)">
<xsl:element name = "ACCOUNT-LIST">
<xsl:for-each select="."/>
</xsl:element>
</xsl:if>
</xsl:template>
and this writes a whole bunch of empty <ACCOUNT-LIST> elements
Which I guess is happening because somehow I'm not refering to the
correct occurence of the ACCOUNT-NO child node I'm dealing with? And
I'll need some xsl:for-each logic
Could you please provide a minimal example of an input tree that
reproduce the problem with that template rule?
Regards,
--drkm
___________________________________________________________________________
Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son
interface révolutionnaire.
http://fr.mail.yahoo.com
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--