Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9229435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:34:16+00:00 2026-06-18T05:34:16+00:00

I would like 1 output returned for two types cases. The first case must

  • 0

I would like 1 output returned for two types cases. The first case must loop thru nodes to determine if it’s met. Here is the XML:

<in:inputs 
  xmlns:in="http://www.composite.net/ns/transformation/input/1.0">
   <in:result name="GetCart">
      <root xmlns="">
        <USC_Purchase ProductPrice="95.0000" 
                      PriceRuleID="1810" 
                      PurchaseQuantity="-1.00" 
                      PaymentNotRequiredQuantity="0.00" 
                      PaymentRequiredQuantity="-1.00" 
                      PaymentRequiredTotal="-95.000000" 
                      PurchaseStatus="R" 
                      RefundTotalAllowed="0.00">
          <USC_Product_PriceRule 
            PriceRuleID="1810" 
            PriceRuleName="Full Attendee" 
            PriceRulePriority="1" 
            PriceRuleStatus="A" 
            WebUserGroups="13CONF-M001" 
            ExcludeWebUserGroups="" 
            ProductPrice="95.0000" 
            ExternalCode="" 
            PercentOfProductCode="" 
            OptionID="0" 
            FriendlyName="Discounted Rate" 
            StartEndRestrictionID="0" 
            ClassID="0" 
            IsHidden="0"/>
        </USC_Purchase>
        <USC_Purchase ProductPrice="55.0000" 
                      PurchaseQuantity="-4.00" 
                      PaymentNotRequiredQuantity="0.00" 
                      PaymentRequiredQuantity="-4.00" 
                      PaymentRequiredTotal="-220.000000" 
                      PurchaseStatus="R" 
                      RefundTotalAllowed="568.00">
          <USC_Product_PriceRule/>
        </USC_Purchase>

Here is my unfinished XSLT, which starts at the first USC_Purchase node:

    <xsl:choose>
      <xsl:when test="@PurchaseStatus='R' 
        and ($purchase_total*($purchase_total >=0)
           - $purchase_total*($purchase_total &lt; 0)) 
           > @RefundTotalAllowed">
       We are having issues processing your refund online. 
       Please contact us for assistance.
      </xsl:when>
      <xsl:otherwise>
        <!-- insert credit card form here -->
      </xsl:otherwise>

This works great…only if the first product met those conditions. The other products go unchecked. A for-each loop at the top of the xsl:choose statement would return multiple messages, and also the credit card form if any of the products were passed fine. (grr!)

My question is – is it possible to loop multiple purchase nodes and stop once a single case is met?

Here are the steps (in case my explanation is throwing anyone off):

  1. Choose between two outputs (error message and credit card form).

  2. For each USC_Purchase node, if ‘X’ condition(s) are met on any node, display the single error message.

  3. Otherwise, display credit card form.

If more information is needed please let me know.

edit

sure, purchase_total is determined by the sum of all paymentrequiredtotals, so:

<xsl:variable 
  name="purchase_total" 
  select="sum(USC_Purchase/@PaymentRequiredTotal)" />
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:34:17+00:00Added an answer on June 18, 2026 at 5:34 am

    Ok, I think I finally understand your requirements. Due to its functional nature, XSLTs do not tend to employ “loop until” logic (it can be done, but is generally not employed when another approach is available). Instead, tests are generally applied across all possible targets at once to see if a condition is met for any of them. I believe the following should do what you are looking to do:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="xml" indent="yes"/>
    
      <xsl:template match="root">
        <xsl:variable
          name="purchase_total"
          select="sum(USC_Purchase/@PaymentRequiredTotal)" />
        <xsl:variable
          name="purchase_total_abs"
          select="$purchase_total * (1 - 2 * ($purchase_total &lt; 0))" />
    
        <xsl:choose>
          <xsl:when test="USC_Purchase[@PurchaseStatus  ='R' and
                                       $purchase_total_abs > @RefundTotalAllowed]">
            We are having issues processing your refund online. Please contact us for assistance.
          </xsl:when>
          <xsl:otherwise>
            <xsl:call-template name="CreditCardForm" />
          </xsl:otherwise>
        </xsl:choose>
      </xsl:template>
    
      <xsl:template name="CreditCardForm">
        <!-- Credit form-->
      </xsl:template>
    </xsl:stylesheet>
    

    To keep the formulas short, first purchase_total, then its absolute value are determined, and then a test is done to see if any of the USC_Purchases match the error condition. If so, the error message is shown, and if not, the credit card form is shown.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that generates/'rolls' two dice. I would like to output these
Given a string '1.2.3.4.5' I would like to get this output '1.2345' (In case
I would like to output debug messages in my django app at different points
I would like to output in this format: e.EE_id e.FNAME e.LNAME SUPer_id s.FNAME s.LNAME
background: i am using javascript templates, which i would like to output raw, without
I am using Ruby on Rails 3.2.2 and rspec-rails-2.8.1. I would like to output
I would like to suppress output in R when I run my R script
I would like my nmake output to go to a particular directory.
Ive a HABTM relationship where the output is like below, what i would like
I would like to append the output JAR filename of a Netbeans project with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.