Solved

xml and stylesheet Loop Command

Posted on 2013-06-23
7
202 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
Comment Utility
you had an issue with the prefixes, use si: allover
CBS-fixed2.xsl
0
 

Author Comment

by:sochionnaitj
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:sochionnaitj
Comment Utility
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
Comment Utility
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
Comment Utility
Thank You
0
 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
welcome
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Importing QRDA file 2 45
c# & linq 7 86
XML Parsing Classic ASP 5 42
XSL - change date format 3 26
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…
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, …
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now