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

RE: Output based on the existence of a particular piec

Subject: RE: Output based on the existence of a particular piece of data in a list
From: "Lars Huttar" <lars_huttar@xxxxxxx>
Date: Mon, 7 Apr 2003 12:29:59 -0500
martin tripp
> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of 
> Martin, Tripp
> Sent: Monday, April 07, 2003 10:39 AM
> To: 'XSL-List@xxxxxxxxxxxxxxxxxxxxxx'
> Subject:  Output based on the existence of a particular piece of
> data in a list
> 
> 
> I've got the following incoming XML:
> 
> <AC:validateAcctngCodeResponse xmlns:AC="AcctngActivityWS">
>   <UserId>U712345</UserId>
>   <AcctngCodeOut>
> 	<Type>CC</Type>
> 	<Identifier>1234</Identifier>
> 	<Status>OK</Status>
> 	<StatusText>Document has no errors.</StatusText>
>   </AcctngCodeOut>
>   <AcctngCodeOut>
> 	<Type>P</Type>
> 	<Identifier>54321</Identifier>
> 	<Status>OK</Status>
> 	<StatusText>Document has no errors.</StatusText>
>   </AcctngCodeOut>
>   <AcctngCodeOut>
> 	<Type>O</Type>
> 	<Identifier>78960</Identifier>
> 	<Status>Error</Status>
> 	<StatusText>Order 78960 does not exist</StatusText>
>   </AcctngCodeOut>
> </AC:validateAcctngCodeResponse>
> 
> I need to make my output based on the existence of a <Status> tag with
> "Error".  So, in the case above I want to have:
> <accountcheckreply>
>       <success>false</success>
>       <message type="error">
>          <code>1</code>
>          <description>Order 78960 does not exist</description>
>       </message>
> </accountcheckreply>
> 
> Whereas if there were no errors in the incoming document, I would have
> simply:
> <accountcheckreply>
>       <success>true</success>
> </accountcheckreply>
> 
> I haven't been able to figure out what I need to use to make 
> this happen.
> Can anyone offer a suggestion of where to start?
> 
> Thanks,
> Tripp

I would start by using a test within the match="/" template
such as
  <xsl:choose>
    <xsl:when test="AC:validateAcctngCodeResponse/AcctngCodeOut/Status = 'Error'">
which will be true if any of the Status nodes in your structure have
the value 'Error'.  In that case, apply a template matching the first
AcctngCodeOut node whose Status child has the value 'Error':
      <xsl:apply-templates select="(AC:validateAcctngCodeResponse/AcctngCodeOut
             [Status = 'Error'])[1]" />
and in that template, create your output <accountcheckreply> element giving
the failure details.

Otherwise, create a successful <accountcheckreply> element.

Lars


lars_huttar@xxxxxxx			"He is not here!  He is risen!"


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.