Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

xml and stylesheet Loop Command

Posted on 2013-06-23
7
Medium Priority
?
215 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
  • 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
Technology Partners: 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 1240 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

Technology Partners: 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!

Question has a verified solution.

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

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
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.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Screencast - Getting to Know the Pipeline
Suggested Courses

916 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