Solved

xml and stylesheet Loop Command

Posted on 2013-06-23
7
207 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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

840 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