Solved

xml and stylesheet Loop Command

Posted on 2013-06-23
7
210 Views
Last Modified: 2013-07-04
I am brand new to xml and am making slow progress.

I have the attached xml Invoice and Stylesheet that I am trying to marry up.  It is now at the stage where is is bringing back most of the details, however it is only returning the first line of the invoice.

In the attached example there are 2 lines, but only detail of the first is being displayed.  I have tried using the </xsl:for-each> command but all I am getting is a blank screen.

Is this the right command to use?  Where should I be placing it?
2406001.XML
CBS.XSL
0
Comment
Question by:sochionnaitj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 39270408
you had an issue with the prefixes, use si: allover
CBS-fixed2.xsl
0
 

Author Comment

by:sochionnaitj
ID: 39273153
Thanks, but still only 1 Invoice detail line is appearing.  Is it the </xsl:for-each> command that I need to use to get the second detail line to appear (from the xml example)?  I have tried adding it in to no avail
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 39273187
You need a for-each there indeed...
(around line 200)

Note that also the context then changes
Here is how that wtr> construct should be

            <xsl:for-each select="si:Details/si:Detail">
            <tr>
              <td><xsl:value-of select='si:LineNo'/></td>
              <td><xsl:value-of select='si:Products/si:Quantity'/></td>
              <td>F12406</td>
              <td><xsl:value-of select='si:Products/si:SellerProductDescr'/></td>
              <td></td>
              <xsl:choose>
		    <xsl:when test="/si:ABWInvoice/si:Invoice/si:Header/si:InvoiceType/@Code='INV'">
                </xsl:when>
                <xsl:otherwise><td></td></xsl:otherwise>
	        </xsl:choose>
              <td class='sectTitle'>Total Tax</td>
              <td>&#160;</td>
              <td class='summary'>
                <xsl:value-of select='si:Summary/si:TotalTax' />
                <xsl:if test='not(string-length(si:Summary/si:TotalTax))'>
                  <div class='warn'>Missing</div>
                </xsl:if>
              </td>
            </tr>
            </xsl:for-each>

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:sochionnaitj
ID: 39273223
I have added it it as below, the third tdL <td>F12406</td>, appears twice, once for each line.  but the Line No, Quantity and Product Description are now blank.  What could be causing these to be omitted?

<xsl:for-each select="si:Details/si:Detail">
            <tr>
              <td><xsl:value-of select='si:Details/si:Detail/si:LineNo'/></td>
              <td><xsl:value-of select='si:Details/si:Detail/si:Products/si:Quantity'/></td>
              <td>F12406</td>
              <td><xsl:value-of select='si:Details/si:Detail/si:Products/si:SellerProductDescr'/></td>
              <td></td>
              <xsl:choose>
                <xsl:when test="/si:ABWInvoice/si:Invoice/si:Header/si:InvoiceType/@Code='INV'">
                </xsl:when>
                <xsl:otherwise><td></td></xsl:otherwise>
              </xsl:choose>
              <td class='sectTitle'>Total Tax</td>
              <td>&#160;</td>
              <td class='summary'>
                <xsl:value-of select='si:Summary/si:TotalTax' />
                <xsl:if test='not(string-length(si:Summary/si:TotalTax))'>
                  <div class='warn'>Missing</div>
                </xsl:if>
              </td>
            </tr>
                  </xsl:for-each>
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 310 total points
ID: 39273474
You should have pasted the lines I copied...

The error is here
             <td><xsl:value-of select='si:Details/si:Detail/si:LineNo'/></td>

The for-each brings you in context of the node it visits
<xsl:for-each select="si:Details/si:Detail">
inside the for each your context is the si:Detail element

so you should not do
             <td><xsl:value-of select='si:Details/si:Detail/si:LineNo'/></td>
but
             <td><xsl:value-of select='si:LineNo'/></td>

as I did in the code snippet you should have used

I hope this helps
0
 

Author Closing Comment

by:sochionnaitj
ID: 39298858
Thank You
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 39299246
welcome
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question