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

  • Home
  • SEARCH
  • 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 6659567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:02:58+00:00 2026-05-26T02:02:58+00:00

How to split one lineitem depends on its fields?

  • 0

How to split one lineitem depends on its fields?

  • 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-05-26T02:02:58+00:00Added an answer on May 26, 2026 at 2:02 am

    To do this, you could create an xsl:key to match non-Split elements (such as Cash and CreditCard), and using the most preceding Split element as the look-up.

    <xsl:key name="Acc" 
     match="AccCode[AccCodeType != 'Split']" 
     use="generate-id(preceding-sibling::AccCode
       [AccCodeType = 'Split']
       [SuppDocNo/RefNo = current()/SuppDocNo/RefNo][1])" />
    

    Then, when you match on an AccCode of split you can get all the associated elements by looking them up in the key

    <xsl:apply-templates select="key('Acc', generate-id())" />
    

    Thus with the following XSLT

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       <xsl:output method="xml" indent="yes"/>
       <xsl:key name="Acc" match="AccCode[AccCodeType != 'Split']" use="generate-id(preceding-sibling::AccCode[AccCodeType = 'Split'][SuppDocNo/RefNo = current()/SuppDocNo/RefNo][1])"/>
    
       <xsl:template match="/">
          <xsl:apply-templates select="//AccCode[AccCodeType = 'Split']"/>
       </xsl:template>
    
       <xsl:template match="AccCode[AccCodeType = 'Split']">
          <ITEM>
             <LineItemNo>
                <xsl:value-of select="../LineNo"/>
             </LineItemNo>
             <SplitPercentage>
                <xsl:value-of select="PrimDocNo/RefNo"/>
             </SplitPercentage>
             <SplitNo>
                <xsl:value-of select="SuppDocNo/RefNo"/>
             </SplitNo>
             <xsl:apply-templates select="key('Acc', generate-id())"/>
          </ITEM>
       </xsl:template>
    
       <xsl:template match="AccCode[AccCodeType != 'Split']">
          <xsl:element name="{AccCodeType}">
             <xsl:value-of select="PrimDocNo/RefNo"/>
          </xsl:element>
       </xsl:template>
    </xsl:stylesheet>
    

    When this is applied to your sample XML, the following is output:

    <ITEM>
       <LineItemNo>01</LineItemNo>
       <SplitPercentage>100.00</SplitPercentage>
       <SplitNo>01</SplitNo>
       <Cash>100</Cash>
       <CreditCard>200</CreditCard>
    </ITEM>
    <ITEM>
       <LineItemNo>02</LineItemNo>
       <SplitPercentage>50.00</SplitPercentage>
       <SplitNo>02</SplitNo>
       <Cash>300</Cash>
       <CreditCard>400</CreditCard>
    </ITEM>
    <ITEM>
       <LineItemNo>02</LineItemNo>
       <SplitPercentage>50.00</SplitPercentage>
       <SplitNo>01</SplitNo>
       <Cash>500</Cash>
       <CreditCard>600</CreditCard>
    </ITEM>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to upgrade one existing application and neeed to split its existing UI
How should one split up the controllers in an ASP.NET MVC site? For example,
Some information on A/B split-testing: http://startuplessonslearned.blogspot.com/2008/09/one-line-split-test-or-how-to-ab-all.html http://www.37signals.com/svn/posts/1525-writing-decisions-headline-tests-on-the-highrise-signup-page I could do this in a Rails
I'd like to split a string using one or more separator characters. E.g. a
How to split an IEnumerable of IEnumerables to one flat IEnumerable using LINQ (or
How would one write a regular expression to use in Python to split paragraphs?
I want to split a file containg HTTP response into two files: one containing
Is it possible to split the information in a .csproj across more than one
I have a class split across two files. One of these is generated, the
I have a form split apart throughout 4 tabs. One of the tabs contains

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.