Subject: [xsl] How do I set up a counter or sequence number variable From: "Catherine Wilbur cwilbur@xxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Mon, 3 Nov 2014 21:56:06 -0000 |
Looked on the archive and did not see anything similar to what I am doing. I am trying to put a sequence number for each output line. Each time I output a line I want to increment the counter by one. Noticed on internet once you change a variable in XSLT you cannot change the value. How do I set up a sequence number. This is how my output is coming out. Had to change order of my output and add few more output fields. so resent my question. 1, LIBPROD, 201411031640LUSD, 99999, 18105.8820, PO-305, 20140724, 20141103, USD, 1.0742, 22, 20, , , ABE/2014082450002181 1, LIBPROD, 201411031640LUSD, 99999, 18105.8430, PO-305, 20140724, 20141103, USD, 1.0742, 22, 2, , , ABE/2014082450002181 Want the output to come out as follows (first field is my sequence number) 1, LIBPROD, 201411031640LUSD, 99999, 18105.8820, PO-305, 20140724, 20141103, USD, 1.0742, 22, 20, , , ABE/2014082450002181 2, LIBPROD, 201411031640LUSD, 99999, 18105.8430, PO-305, 20140724, 20141103, USD, 1.0742, 22, 2, , , ABE/2014082450002181 Here is my XSLT code (copied some code off the web with an interate so put template in code - not sure how to use this code for counter or sequencing <?xml version="1.0" encoding="UTF-8" ?> <!-- New document created with EditiX at Thu Oct 23 16:28:34 EDT 2014 --> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xdt="http://www.w3.org/2005/xpath-datatypes" xmlns:err="http://www.w3.org/2005/xqt-errors" exclude-result-prefixes="xs xdt err fn" xmlns:date="http://exslt.org/dates-and-times" extension-element-prefixes="date"> <xsl:output method="text" indent="no"/> <xsl:variable name="GLDateValue" select="format-date(current-date(),'[Y0001][M01][D01]')"/> <xsl:variable name="CurrDateTimeValue" select="format-dateTime(current-dateTime(),'[Y0001][M01][D01][H01][m01]')"/> <!-- OUSTANDING OUTPUT DATA ISSUES --> <!-- xsl:value-of select="../../../../../hardcode_RemarkString" />, derived field --> <!-- xsl:value-of select="../../../../../hardcode_PayTerms" />, derived from part of invoice/invoice_number --> <!-- xsl:value-of select="../../../../../hardcode_Attachments" />, derived from part of invoice/invoice_number --> <xsl:template name="iterate"> <xsl:param name="length" select="8"/> <xsl:param name="i" select="1"/> <pos><xsl:value-of select="$i"/></pos> <xsl:if test="$length > 1"> <xsl:call-template name="iterate"> <xsl:with-param name="length" select="$length - 1"/> <xsl:with-param name="i" select="$i + 1"/> </xsl:call-template> </xsl:if> </xsl:template> <xsl:template match="/"> <xsl:for-each select="payment_data/invoice_list/invoice/invoice_line_list/invoice_line/fund_info_list/fund_info/amount"> <xsl:variable name="inv" select="../../../../.."/> <xsl:variable name="InvoiceDateValue" select="translate($inv/invoice_date,'/','')"/> <xsl:variable name="InvoiceVendorCode" select="$inv/vendor_code"/> <xsl:variable name="InvoiceVendorNo" select="$inv/vendor_FinancialSys_Code"/> <xsl:variable name="InvoiceCurrency" select="$inv/invoice_amount/currency"/> <xsl:variable name="InvoicePOLineOwner" select="../../../../invoice_line/po_line_info/po_line_owner"/> <xsl:variable name="InvoiceNumber" select="$inv/invoice_number"/> <xsl:variable name="FISVendorNo"> <xsl:choose> <xsl:when test="string-length($InvoiceVendorNo)!=0"> <xsl:value-of select="number($InvoiceVendorNo)"/> </xsl:when> <xsl:otherwise>99999</xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="PaymentAttachment"> <xsl:choose> <xsl:when test="contains($InvoiceNumber, '(ATC)') or starts-with($InvoiceNumber, 'PPD')"> <xsl:value-of select="'A'"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="' '"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="PaymentTerms"> <xsl:choose> <xsl:when test="contains($InvoiceNumber, '(PPD)') or contains($InvoiceNumber, '(RSH)') or starts-with($InvoiceNumber, 'CM') or contains($InvoiceVendorCode, 'OCL C')"> <xsl:value-of select="'U'"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="' '"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="POOwnerType"> <xsl:choose> <xsl:when test="contains($InvoicePOLineOwner, 'Law') or contains($InvoicePOLineOwner, 'LAW') "> <xsl:value-of select="'W'"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="'L'"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:value-of select="count(sum), 'LIBPROD', concat($CurrDateTimeValue,$ POOwnerType,$InvoiceCurrency), $FISVendorNo, ../external_id, $inv/invoice_number, concat(substring($InvoiceDateValue,5,4),substring($InvoiceDateValue,1,2),substring($InvoiceDateValue,3,2)), $GLDateValue, $inv/invoice_amount/currency, $inv/invoice_exchange_rate_list/exchange_rate/rate, $inv/invoice_amount/sum, sum, $PaymentAttachment, $PaymentTerms, concat($inv/vendor_code,'/',$inv/unique_identifier) " separator=", "/> <xsl:text>
</xsl:text> </xsl:for-each> </xsl:template> </xsl:stylesheet> _____________________________________________________________________ Catherine Wilbur | Senior Application Programmer | IT Services 401 Sunset Avenue, Windsor ON Canada N9B 3P4 (T) 519.253.3000 Ext. 2745 | (F) 519.973.7083 | (E) cwilbur@xxxxxxxxxxx www.uwindsor.ca/its
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How do I set up a counter, Martin Honnen martin | Thread | Re: [xsl] How do I set up a counter, Wolfgang Laun wolfga |
Re: [xsl] How do I set up a counter, G. Ken Holman g.ken. | Date | Re: [xsl] How do I set up a counter, Wolfgang Laun wolfga |
Month |