[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Writing array elements based on a an evaluation of

Subject: Re: Writing array elements based on a an evaluation of one of the child elements
From: neil cave <coraltrees@xxxxxxxxxxx>
Date: Wed, 24 May 2006 13:00:02 +0000 (GMT)
array based list
There are several occurences of ACCOUNT-LIST each with the same 3 child elements.
The first child element in any occurence of ACCOUNT-LIST is ACCOUNT-NO
Should this ACCOUNT-NO element have no value (which I am trying to determine by assesing the string-length of ACCOUNT-NO/text()) then I do not want to write the entire ACCOUNT-LIST element for the specific occurence.
 
therefore looking at the example below, I want to only have the first 2 occurences of the ACCOUNT-LIST appear in my result
 
XML I Get ...
 
<?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>
 
XML I WANT...
 
<?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>
</Get_AccountNumber_List>


----- Original Message ----
From: Jon Gorman <jonathan.gorman@xxxxxxxxx>
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Sent: Wednesday, 24 May, 2006 2:50:41 PM
Subject: Re:  Writing array elements based on a an evaluation of one of the child elements


> 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


Accck.  It does evaluate the string-length test, as I've already
mentioned.  It includes at least once character (newline).  And every
account-list does have tags in your example.  (They're empty elements
though).

Ok, what are you asking?  I'm getting a little confused looking at all
your emails.

1) Do you want to eleminate Account-Lists that don't have elements
that have any value?

solution:

<xsl:template match="ACCOUNT_LISTS">
<xsl:if test="normalize-space(.)">
<xsl:copy>
<xsl:apply-templates />
</xsl:copy>
</xsl:if>


2) Or is it the case that the Account-No might be empty even with
other data in the Account-Lists field?  Because we can't tell from
your example

<xsl:template match="ACCOUNT_LISTS">
<xsl:if test="normalize-space(ACCOUNT_NO)">
<xsl:copy>
<xsl:apply-templates />
</xsl:copy>
</xsl:if>

Jon Gorman

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.