Counter In XSLT

Hi,
Can somebody please let me know how I can create counter in XSLT. When I have multiple line item of certain segment in an idoc, I want to put the counter on the segment attribute as shown below.
The scenario should be,
Field                      Value
Acc_Document02
  Idoc
     Begin (attr)          1        
     E1BPACPA09
        Segment(attr)      1
     E1BPACPA09
        Segment             2
     E1BPACPA09
        Segment             3
If somebody has XSLT code, can you please send.
TIA.
Warm Regards,
Ranjan

Hi Ranjan,
have you tried with the number function?
http://www.w3.org/TR/xslt#number
Regards,
michal

Similar Messages

  • Increment counter in XSLT mapping

    Hi Experts,
    I am creating xslt mapping by using mapforce tool. I am trying to get increment counter variable in xslt mapping. can you please tell me what would be the code for getting sequence number.
    Thanks for your help.
    Thanks,
    Hari

    yes, there is a global variable concept in XI which u can use for your Sequence Number concept.
    If you are on SP14 and above, just take a lookat this blog and the GLOBAL Variables Section
    XI: New features in SP14
    check this thread
    Re: Need Help in XSLT Mapping
    Re: Sequence Number in XI Mapping

  • Counter in XSLT processing

    Is there anyway to keep an incremental counter in an XSLT stylesheet? I would like to append this counter to several element names to maintain uniqueness.
    Thanks
    Kathy

    I can generated the number I want using xsl:number. However, I don't know how to include it as part of the element name I am trying to generate.
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    For example:
    <xsl:template match="DownlinkCellID_member">
    <xsl:number level="single" count="DownlinkCellID_member"/>
    <xsl:element name="DownlinkCellID{@index}">
    <xsl:value-of select="@value"/>
    </xsl:element >
    </xsl:template>
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    "index" is an attribute I included in the original XML file that I read and append to the element name. I would like to remove "index" from the original XML file and replace it's using in the xslt template with the output from xsl:number. How can I do this? Will it work if I create a variable?
    Thanks :-)

  • Counter increment using XSLT

    Hello Guys,
    I am finding it difficult to increase my counter in XSLT program.
    The counter is being calculated inside the template POHeader inside the PART Node set.I would like to increase this counter for
    each every haeder as expained in the example.
    Can someone suggest how to increase my counter?
    For Eg :
    Expected output:
    850HD20102010122100000001 0095AAF52C, , * // 00001  before 009
    850H1000115 1012210095A AS
    850H4
    850H7
    850N1 0095A
    850N2AFL HUNGARY D02RG
    850D1 00000100000000015EA 96FG 10374 AA
    850D6Seal
    850HD20102010122100000002 0095AAF52C, , * // 00002 
    850H1000115 1012210095A SS
    850H4
    850H7
    850N1 0095A
    850N2VALEO AUTOSYSTEMY SP.Z.O.O. EBECA
    850D1 00000100000001202EA DSFSDF SDF
    850D6WIRE ASSY
    850D1 00000200000002118EA TEST
    850D6ARM-WIPER
    850HD20102010122100000003  0160AAF52C, , * // 00003
    850H1000115 1012210160A SS
    850H4
    850H7
    850N1 0160A
    850N2VALEO AUTOSYSTEMY SP.Z.O.O. EBECA
    850D1 00000100000000016EA V97FB 17526 BD
    850D6Arm Assy - Wiper
    But i am getting it as :
    850HD201020101221000000010095AAF52C, , *
    850H1000115 1012210095A AS
    850H4
    850H7
    850N1 0095A
    850N2AFL HUNGARY D02RG
    850D1 00000100000000015EA 96FG 10374 AA
    850D6Seal
    850HD201020101221000000010095AAF52C, , *
    850H1000115 1012210095A SS
    850H4
    850H7
    850N1 0095A
    850N2VALEO AUTOSYSTEMY SP.Z.O.O. EBECA
    850D1 00000100000001202EA DSFSDF SDF
    850D6WIRE ASSY
    850D1 00000200000002118EA TEST
    850D6ARM-WIPER
    850HD201020101221000000010160AAF52C, , *
    850H1000115 1012210160A SS
    850H4
    850H7
    850N1 0160A
    850N2VALEO AUTOSYSTEMY SP.Z.O.O. EBECA
    850D1 00000100000000016EA V97FB 17526 BD
    850D6Arm Assy - Wiper
    The below is the XSLTcode:
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <!--Correction V2.0  23.11.2010 -->
    <!-- POtype added-->
    <!DOCTYPE xsl:stylesheet [
    <!ENTITY linefeed "<xsl:text>
    </xsl:text>">
    <!ENTITY tab "<xsl:text>     </xsl:text>">
    <!ENTITY space "<xsl:text> </xsl:text>">
    <!ENTITY space5 "<xsl:text>     </xsl:text>">
    <!ENTITY space10 "<xsl:text>          </xsl:text>">
    ]>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:n0="urn:-com:fcsd:btr:eu:sapscm:schedAgrRels">
        <xsl:output method="text"/>
        <xsl:param name="inputparam"/>
        <xsl:template match="n0:COMMONFORMAT_MT">   
               <xsl:variable name="SHIPFROM" select="//Entity/ShipFrom"/>
                   <xsl:for-each select="//Entity">
                        <xsl:for-each select="Part">
                                      <xsl:if test="SupplierCode = 'Y'">
                        <xsl:call-template name="RoutingHeader"/>
                        <xsl:call-template name="POHeader"/>
                        <xsl:call-template name="PODetails"/>
                                       </xsl:if>
                                <xsl:apply-templates select="."/>
                        </xsl:for-each>
                    </xsl:for-each>
        </xsl:template>
    <!-- Stock Order Header Record-->
    <xsl:template name="RoutingHeader">
            <xsl:variable name="SHIPFROM" select="../ShipFrom"/>
            <xsl:variable name="SHIPTO" select="../ShipTo"/>
            <!-- HD Primary Routing Record-->
            <xsl:text>850HD2010</xsl:text>
            <xsl:value-of select="/n0:COMMONFORMAT_MT/Header/CreationYear"/>
            <xsl:value-of select="format-number(/n0:COMMONFORMAT_MT/Header/CreationMonth,'00')"/>
            <xsl:value-of select="format-number(/n0:COMMONFORMAT_MT/Header/CreationDay,'00')"/>   
            <xsl:text>0000</xsl:text> <!-- TIME ZERO-->
                  <xsl:value-of select="format-number(position(),'0000')"/>
            <xsl:value-of select="substring($SHIPTO,1,5)"/>
            <xsl:text>AF52C</xsl:text>
            <xsl:text>,</xsl:text>
            &space5;
            <xsl:text>,</xsl:text>
            &space5;
            <xsl:text>*</xsl:text>
            &linefeed;
    </xsl:template>
    <xsl:template name="PODetails">
    <xsl:variable name="SHIPFROM" select="../ShipFrom"/>
    <xsl:variable name="SHIPTO" select="../ShipTo"/>
    <!-- H4 Contacts-->
        <xsl:text>850H4</xsl:text>
        &linefeed;
    <!-- H7 FoB Other Items-->
        <xsl:text>850H7</xsl:text>
        &linefeed;
    <!-- N1 Buying name address-->
        <xsl:text>850N1</xsl:text>
        <xsl:value-of select="substring(../ShipToName,1,30)"/>
         <xsl:variable name="LEN1" select="string-length(../ShipToName)"/>
        <xsl:value-of select="substring('                              ',1,30-$LEN1)"/>
        <xsl:value-of select="substring($SHIPTO,1,5)"/>
        &linefeed;
    <!-- N2 Supplier Name address-->
        <xsl:text>850N2</xsl:text>
        <xsl:value-of select="substring(../ShipFromName,1,30)"/>
        <xsl:variable name="LEN2" select="string-length(../ShipFromName)"/>
        <xsl:value-of select="substring('                              ',1,30-$LEN2)"/>
        <xsl:value-of select="substring($SHIPFROM,1,5)"/>
       &linefeed;
    <!-- N3 Ship-To addresses-->
        <xsl:choose>
            <xsl:when test="$SHIPFROM = 'AF52M'">
                <xsl:text>850N3                              59791</xsl:text>
               &linefeed;
            </xsl:when>
        </xsl:choose>
        </xsl:template>
    <xsl:template name="POHeader">
            <xsl:variable name="SHIPFROM" select="../ShipFrom"/>
            <xsl:variable name="SHIPTO" select="../ShipTo"/>
            <xsl:variable name="POTYPE" select="POType"/>   
    <!Primary Contorl Record>
            <xsl:text>850H1</xsl:text>
            <xsl:variable name="PONR" select="../ReleaseNumberPrimary"/>
            <xsl:variable name="LEN" select="string-length($PONR)"/>
            <xsl:value-of select="$PONR"/>
            <xsl:value-of select="substring('                  ',1,18-$LEN)"/>
            &space10;&space5;&space;&space;&space;
            <xsl:value-of select="substring(/n0:COMMONFORMAT_MT/Header/CreationYear,3,2)"/>
            <xsl:value-of select="format-number(/n0:COMMONFORMAT_MT/Header/CreationMonth,'00')"/>
            <xsl:value-of select="format-number(/n0:COMMONFORMAT_MT/Header/CreationDay,'00')"/>       
            <xsl:value-of select="$SHIPTO"/>
            &space10;&space10;&space10;&space5;
    <!<xsl:text>SS</xsl:text>>
            <xsl:value-of select="$POTYPE"/>
            &linefeed;
    </xsl:template>
        <xsl:template match="Part">
        <!-- D1 Part Record-->
                <xsl:text>850D1</xsl:text>
                &space5;&space;
                <xsl:variable name="POS" select="position()"/>
                <xsl:value-of select="format-number(count(preceding-sibling::Part) + 1,'000000')"/>
                <xsl:variable name="QTY" select="ScheduleLines[1]/Quantity"/>
                <xsl:value-of select="format-number($QTY,'00000000000')"/>
                <xsl:text>EA</xsl:text>
                &space10;&space5;&space;
                <xsl:call-template name="FormatPartNumber"/>
                <xsl:if test="string-length(VendorPart/VendorPartID) > 0">
                        &space10;&space10;&space10;
                        <xsl:value-of select="VendorPart/VendorPartID"/>
                </xsl:if>
                &linefeed;
      <!-- D6 Part Description -->
                <xsl:text>850D6</xsl:text>
                <xsl:value-of select="substring(Description,1,80)"/>
                &linefeed;
        </xsl:template>
    <!Formatting PartNumber>
        <xsl:template name="FormatPartNumber">
            <xsl:if test="../ShipFrom = 'FI05M'">
                <xsl:variable name="T1" select="substring-before(EPNCode,' ')"/>
                <xsl:variable name="T2T"  select="substring-after(EPNCode,' ')"/>
                <xsl:variable name="T2" select="substring-before($T2T,' ')"/>
                <xsl:variable name="T3" select="substring-after($T2T,' ')"/>
                <xsl:if test="$T3 != ''">
                    <xsl:choose>
                        <xsl:when test="$T3 != '-'">
                           <xsl:variable name="PN" select="concat($T1,'/',$T2,'/',substring($T3,1,2),'/',substring($T3,3))"/>
                        </xsl:when>
                        <xsl:otherwise>
                           <xsl:variable name="PN" select="concat($T1,'/',$T2,'/','/')"/>   
                        </xsl:otherwise>
                    </xsl:choose>
                           <xsl:variable name="LEN" select="string-length($PN)"/>
                           <xsl:value-of select="$PN"/>
                            <xsl:value-of select="substring('                              ',1,30-$LEN)"/>
                </xsl:if>
                <xsl:if test="$T3= ''">
                    <xsl:choose>
                        <xsl:when test="$T2T != '-'">                                            <xsl:variable name="PN" select="concat(substring($T1,1,1),'/',substring($T1,2),'/',substring($T2T,1,2),'/',substring
    ($T2T,3))"/>
                        </xsl:when>
                        <xsl:otherwise>
                        <xsl:variable name="PN" select="concat(substring($T1,1,1),'/',substring($T1,2),'/','/')"/>   
                        </xsl:otherwise>
                    </xsl:choose>
                         <xsl:variable name="LEN" select="string-length($PN)"/>
                          <xsl:value-of select="$PN"/>
                           <xsl:value-of select="substring('                              ',1,30-$LEN)"/>
                          </xsl:if>
            </xsl:if>
            <xsl:if test="../ShipFrom != 'FI05M'">
                <xsl:value-of select="substring(concat(EPNCode,'                              '),1,30)"/>
            </xsl:if>
        </xsl:template>
    </xsl:stylesheet>
    My input XML data :
    <?xml version="1.0" encoding="utf-8"?>
    <n0:COMMONFORMAT_MT xmlns:n0="urn:nord-com:fcsd:btr:eu:sapscm:schedAgrRels" xmlns:prx="urn:sap.com:proxy:A8D:/1SAI/TAS00000000000000000025:700:2009/02/10">
    <Header>
    <EDIFormat>CIF850</EDIFormat>
    <CreationYear>2010</CreationYear>
    <CreationMonth>12</CreationMonth>
    <CreationDay>21</CreationDay>
    </Header>
    <Details>
    <Entity>
    <ShipFrom>D02RG</ShipFrom>
    <ShipTo>0095A</ShipTo>
    <BillTo>0095A</BillTo>
    <ReleaseNumberPrimary>000115</ReleaseNumberPrimary>
    <ShipToInternal>PLDE11</ShipToInternal>
    <ShipToName>nord-Werke GmbH</ShipToName>
    <ShipFromName>AFL HUNGARY</ShipFromName>
    <Part>
    <FinisCode>TST_1004285</FinisCode>
    <EPNCode> 96FG 10374 AA </EPNCode>
    <SupplierCode>Y</SupplierCode>
    <Description>Seal</Description>
    <APNType>EN</APNType>
    <CumQuanRec>60.000 </CumQuanRec>
    <PurchasingUOM>EA</PurchasingUOM>
    <PartHorizons>
    <ProductGoAheadQty>0 </ProductGoAheadQty>
    <MaterialGoAheadQty>0 </MaterialGoAheadQty>
    <MaterialEndDate>101220</MaterialEndDate>
    <FabEndDate>101220</FabEndDate>
    <LastASNNo>KRISHNA</LastASNNo>
    <LastASNDate>100929</LastASNDate>
    <LastASNQty>20 </LastASNQty>
    <LastASNCumQty>0 </LastASNCumQty>
    </PartHorizons>
    <PurchasingInformation>
    <ReleaseID>JGxc9pCi0QhX08004sv34m</ReleaseID>
    <PurchasingNumber>5500000039</PurchasingNumber>
    <ReleaseNumber>0000018</ReleaseNumber>
    <ReleaseIssueDate>101220</ReleaseIssueDate>
    <HorizonEndDate>111220</HorizonEndDate>
    <ReconciliationDate>100101</ReconciliationDate>
    <BookNumber>180</BookNumber>
    </PurchasingInformation>
    <ScheduleLines>
    <Quantity>15 </Quantity>
    <Date>101220</Date>
    <Time>0007</Time>
    <TransportMethod>0001</TransportMethod>
    </ScheduleLines>
    <ShipCode>XX</ShipCode>
    <POType>AS</POType>
    </Part>
    </Entity>
    </Details>
    <Details>
    <Entity>
    <ShipFrom>EBECA</ShipFrom>
    <ShipTo>0095A</ShipTo>
    <BillTo>0095A</BillTo>
    <ReceivingDock>12</ReceivingDock>
    <ReleaseNumberPrimary>000115</ReleaseNumberPrimary>
    <ShipToInternal>PLDE11</ShipToInternal>
    <ShipToName>nord-Werke GmbH</ShipToName>
    <ShipFromName>VALEO AUTOSYSTEMY SP.Z.O.O.</ShipFromName>
    <Part>
    <FinisCode>1007257</FinisCode>
    <EPNCode>DSFSDF SDF </EPNCode>
    <SupplierCode>Y</SupplierCode>
    <Description>WIRE ASSY</Description>
    <APNType>EN</APNType>
    <CumQuanRec>0.000 </CumQuanRec>
    <PurchasingUOM>EA</PurchasingUOM>
    <PartHorizons>
    <ProductGoAheadQty>0 </ProductGoAheadQty>
    <MaterialGoAheadQty>0 </MaterialGoAheadQty>
    <MaterialEndDate>101221</MaterialEndDate>
    <FabEndDate>101221</FabEndDate>
    <LastASNNo>00000000000</LastASNNo>
    <LastASNDate>000000</LastASNDate>
    <LastASNQty>0 </LastASNQty>
    <LastASNCumQty>0 </LastASNCumQty>
    </PartHorizons>
    <PurchasingInformation>
    <ReleaseID>JGyw4Tf30QhX08004sv34m</ReleaseID>
    <PurchasingNumber>5500023416</PurchasingNumber>
    <ReleaseNumber>0000002</ReleaseNumber>
    <ReleaseIssueDate>101221</ReleaseIssueDate>
    <HorizonEndDate>111221</HorizonEndDate>
    <ReconciliationDate>091005</ReconciliationDate>
    <BookNumber>730</BookNumber>
    </PurchasingInformation>
    <ScheduleLines>
    <Quantity>1202 </Quantity>
    <Date>101220</Date>
    <Time>0007</Time>
    </ScheduleLines>
    <ShipCode>11</ShipCode>
    <POType>SS</POType>
    </Part>
    <Part>
    <FinisCode>1008781</FinisCode>
    <EPNCode> TEST </EPNCode>
    <Description>ARM-WIPER</Description>
    <APNType>EN</APNType>
    <CumQuanRec>0.000 </CumQuanRec>
    <PurchasingUOM>EA</PurchasingUOM>
    <PartHorizons>
    <ProductGoAheadQty>0 </ProductGoAheadQty>
    <MaterialGoAheadQty>0 </MaterialGoAheadQty>
    <MaterialEndDate>101217</MaterialEndDate>
    <FabEndDate>101217</FabEndDate>
    <LastASNNo>00000000000</LastASNNo>
    <LastASNDate>000000</LastASNDate>
    <LastASNQty>0 </LastASNQty>
    <LastASNCumQty>0 </LastASNCumQty>
    </PartHorizons>
    <PurchasingInformation>
    <ReleaseID>JGkW33ND0PxX08004sv34m</ReleaseID>
    <PurchasingNumber>5500023075</PurchasingNumber>
    <ReleaseNumber>0000001</ReleaseNumber>
    <ReleaseIssueDate>101217</ReleaseIssueDate>
    <HorizonEndDate>111217</HorizonEndDate>
    <ReconciliationDate>100101</ReconciliationDate>
    <BookNumber>180</BookNumber>
    </PurchasingInformation>
    <ScheduleLines>
    <Quantity>2118 </Quantity>
    <Date>101213</Date>
    <Time>0007</Time>
    </ScheduleLines>
    <ShipCode>XX</ShipCode>
    <POType>SS</POType>
    </Part>
    </Entity>
    </Details>
    <Details>
    <Part>
    <FinisCode>1049328</FinisCode>
    <EPNCode>V97FB 17526 BD</EPNCode>
    <SupplierCode>Y</SupplierCode>
    <Description>Arm Assy - Wiper</Description>
    <APNType>EN</APNType>
    <CumQuanRec>11183.000 </CumQuanRec>
    <PurchasingUOM>EA</PurchasingUOM>
    <PartHorizons>
    <ProductGoAheadQty>0 </ProductGoAheadQty>
    <MaterialGoAheadQty>0 </MaterialGoAheadQty>
    <MaterialEndDate>110201</MaterialEndDate>
    <FabEndDate>110102</FabEndDate>
    <LastASNNo>ADRIAN 17.1</LastASNNo>
    <LastASNDate>091117</LastASNDate>
    <LastASNQty>133 </LastASNQty>
    <LastASNCumQty>0 </LastASNCumQty>
    </PartHorizons>
    <PurchasingInformation>
    </PurchasingInformation>
    <ScheduleLines>
    <Quantity>16 </Quantity>
    <Date>101129</Date>
    <Time>0007</Time>
    </ScheduleLines>
    <ShipCode>XX</ShipCode>
    <POType>SS</POType>
    </Part>
    </Entity>
    </Details>
    </n0:COMMONFORMAT_MT>

    Don't see an attachment.
    You could use a shift register to store an array.
    Each button would map to an array index. For each button pushed you would index the array, +1 the value, replace the array element and pass back out to the shift register.
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness

  • How to use Counter and variable in xslt

    All,
    How to use Counter in XSLT, and How to do a increament for a count variable?
    How to use a Variable in xslt? and How to define variable inbetween XSLT
    If I am using
    Count=Count+1, its throwin an error ...
    Error: Text is not Supported Under a XSLT Element: $count=$count+1
    Regards
    Francis
    Edited by: Francis on Aug 23, 2012 9:33 AM
    Edited by: Francis on Aug 23, 2012 11:23 AM

    How to use a Variable in xslt? and How to define variable inbetween XSLT
    <xsl:variable name="VariableName">
    <xsl:value-of select='/ns0:SyncItemListEBM/ns0:DataArea/ns0:SyncItemList/corecomEBO:ItemSpecificationGroup/corecom:SpecificationGroup[corecom:Name = "GROUP_NAME"]/corecom:Specification[corecom:Name = "SPECIFICATION_NAME"]/corecom:ValueText'/>
    </xsl:variable>
    How to use Counter in XSLT, and How to do a increament for a count variable?
    You can make use of for-each tag, its simplified in XSLT where you dont need counter if at all needed then you can use of position() to identify the loop counter.
    Thanks,
    Vijay

  • How to use sequence in BPEL transformation

    Hi All,
    I want to use some kind of random unique number in my xsl mapping. I Thought to use a sequence which I generated in database, but in xsl mapping I didn't get a way to use database functions. Can anyone suggest something.
    Thanks in Advance.

    Hi Roshni,
    You seems to use an external parameter inside the XSLT. you can you it as <param> defined in xslt. and call that external parameter with the same name inside the xslt to use.
    suppose you need a count variable inside xslt which comes from external service as DB using Adapter to fetch the value. Now inside xslt:
    and then define
    +<xsl:param name="Count"/>+
    and assign value to your
    +<xsl:variable name="CountDetails" select="integer($Count)"/>+
    before xslt call the variable which needs to be populated and assign it to param defined in xslt
    i.e.
    +<assign name="Assign_XSLParams">
    <copy>
    <from expression="'Count'"/>
    <to variable="SMS_int"
    query="/ns3:parameters/ns3:item/ns3:name"/>
    </copy>
    </assign>+
    Hope this helps !!
    Reg,
    MS

  • How to Count schedule lines in IDoc ORDERS05 using XSLT Mapping

    Hi Experts,
    In a Scenario where we are sending Purchase order (ORDERS05) to SAP SNC using XSLT Mapping,
    where in we need to count the no. of schedule lines against the Purchase Order line.
    As in Schedule line segment there is no such provision, so it needs to be handle in XSLT mapping to count the schedule lines.
    Can you all please guide me how to go about the same.
    Regards,
    Nitin P

    Hi Satish,
    Thank you very much for the reply,
    as there is only Quantity and other information is maintained against schedule lines how we can count the schedule line repeatation against PO line ? Is that very simple as you suggested or some other consideration also needs to be taken.
    Please clarify the same and let me also know if there are some standard documents also for the same.
    Regards,
    Nitin P

  • Need help for Count function in XSLT Mapping

    Hi All,
    We have a requirement in our project,to do the xslt mapping from OAGIS 9.0 to EDI XML.In the EDI XML we have a SE tag whose value is the count of the no. of complex elements that will be generated in the EDIXML file( which is the target).
    Please do let me know if anybody has done this functionality in the xslt mapping.
    Thanks in Advance.
    Regards,
    Kaavya

    Hi,
    for the Hex-Number-conversion see:
    [url http://psoug.org/snippet/Convert-Hex-to-Decimal-Decimal-to-Hex_78.htm] self-defined Conversion-Functions
    What number format do you have? YYYMMDD
    Or is there a Date corresponding to 1 and a number n represent the date n-1 days after day 1?
    Please describe further.
    Bye
    stratmo

  • XSLT mapping - getting node count

    I'm mapping a flat file to an 835, and on the advice of Boatseller I've dove into XSLT in order to finish the map and it has been the best thing I've ever done. However, not being a real pro at XSLT I am stuck on one thing I hope you guys can help me on.
    I'm dealing with transactions whose lines have tags. One transaction can looks like this:
    0001(header)
    0002(EOB)
    0003(service lines)
    0004(Totals)
    0005(comments)
    0007(footer)
    lines 0002-0004 make up one record and there can be multiple records per transaction. I've got that all figured out. What is killing me is that there can be multiple 0003(EOB) lines per record, like this:
    0001
    0002
    0003
    0003
    0003
    0004
    0002
    0003
    0003
    0004
    0005
    0007
    So in the above transaction I've actually got two records. One with three 0003 lines and another with two 0003 lines. As I'm processing each record (0002-0004) I need to be able to loop through the 0003 lines. When I start looking at the 0003 lines my XSLT
    is actually grabbing ALL 0003 lines in the entire transaction. In the case above, it is grabbing five each time instead of three the first time and two the second time. I have a counter variable that tells me which EOB(0002) section I'm on:
    <xsl:variable name="var:ClaimSequence" select="position()" /> 
    When I try the following code it gives me ALL the service lines(0003) instead of just the ones I need:
    <xsl:variable name="SVCcount" select="count(//ServiceLines)" /> 
    When I try the following code it only gives me the first ServiceLine(0003) line:
    <xsl:variable name="SVCcount" select="count(../ServiceLines[number($var:ClaimSequence)])" />
    What I'm trying to do is determine how many Service lines(0003) I have in the current record and I can create a counter in a for loop and access each service line like this:
    EOB(counter)
    I just can't seem to reach, via XSLT, the correct count.
    Any ideas?
    Thanks.

    You don't need to determine the count, you can use a for-each loop to iterate over the Service lines belonging to each 0002 (EOB) record.
    Here is an example.
    Input:
    <Root>
    <Header/>
    <EOB/>
    <ServiceLine>1</ServiceLine>
    <ServiceLine>2</ServiceLine>
    <ServiceLine>3</ServiceLine>
    <Totals/>
    <EOB/>
    <ServiceLine>4</ServiceLine>
    <ServiceLine>5</ServiceLine>
    <Totals/>
    <Comments/>
    <Footer/>
    </Root>
    XSLT:
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
    <xsl:output method="xml" indent="yes"/>
    <xsl:template match="Root">
    <Root>
    <xsl:for-each select="EOB">
    <EOB>
    <xsl:for-each select="following-sibling::ServiceLine[count(preceding-sibling::EOB[1] | current()) = 1]">
    <xsl:copy-of select="." />
    </xsl:for-each>
    </EOB>
    </xsl:for-each>
    </Root>
    </xsl:template>
    </xsl:stylesheet>
    Output:
    <Root>
    <EOB>
    <ServiceLine>1</ServiceLine>
    <ServiceLine>2</ServiceLine>
    <ServiceLine>3</ServiceLine>
    </EOB>
    <EOB>
    <ServiceLine>4</ServiceLine>
    <ServiceLine>5</ServiceLine>
    </EOB>
    </Root>

  • XSLT: how to increment a counter

    How do I increment a counter defined in XSLT?
    i.e
    <xsl:variable name="counter"/> //global var?
    <xsl:for-each select="....">
    <!--How do I assign $counter+1 to the variable counter defined above??? -->
    <xsl:assign???? name="counter">
    <xsl:value-of select="$counter+1"/>
    </xsl:assign> //?????
    </xsl:for-each>
    <!-- expect a result of total $counter here-->

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by hsiuhsien:
    How do I increment a counter defined in XSLT?
    i.e
    <xsl:variable name="counter"/> //global var?
    <xsl:for-each select="....">
    <!--How do I assign $counter+1 to the variable counter defined above??? -->
    <xsl:assign???? name="counter">
    <xsl:value-of select="$counter+1"/>
    </xsl:assign> //?????
    </xsl:for-each>
    <!-- expect a result of total $counter here--><HR></BLOCKQUOTE>
    http://technet.oracle.com:89/ubb/Forum11/HTML/005426.html
    Malik Graves-Pryor

  • DVWP XSLT count number of column having Yes/No values for each row

    I have a Data View Web Part .Now I have a column that contains either 'Yes' or 'No'
    and i want to count the number of 'Yes' for the rows and column  .
    below image will help to understand better what i am tying to achieve.  

    Here is XSLT code , you may find this usefull
    Row View Template :
    <xsl:template name="dvt_1.rowview">
          <xsl:param name="Rows"/>
          <xsl:variable name="CountYesForAll" select="number((. = contains(@Richard,'Yes')))
           +number((. = contains(@AndrewP,'Yes')))
           +number((. = contains(@Damien,'Yes')))
           +number((. = contains(@AndrewC,'Yes')))
           +number((. = contains(@Tiffany,'Yes')))
           +number((. = contains(@David,'Yes')))
           +number((. = contains(@Tony,'Yes')))
           +number((. = contains(@Saj,'Yes')))
           +number((. = contains(@Miguel,'Yes')))
           +number((. = contains(@Viv,'Yes')))
           +number((. = contains(@Paula,'Yes')))
           +number((. = contains(@Helen,'Yes')))
           +number((. = contains(@Matthew,'Yes')))"/>
          <xsl:variable name="RichardsCount" select="count($Rows[(@Richard)='Yes'])"></xsl:variable>
          <xsl:variable name="AndrewPsCount" select="count($Rows[(@AndrewP)='Yes'])"></xsl:variable>
          <xsl:variable name="DamiensCount" select="count($Rows[(@Damien)='Yes'])"></xsl:variable>
          <xsl:variable name="AndrewCsCount" select="count($Rows[(@AndrewC)='Yes'])"></xsl:variable>
          <xsl:variable name="TiffanysCount" select="count($Rows[(@Tiffany)='Yes'])"></xsl:variable>
          <xsl:variable name="DavidsCount" select="count($Rows[(@David)='Yes'])"></xsl:variable>
          <xsl:variable name="TonysCount" select="count($Rows[(@Tony)='Yes'])"></xsl:variable>
          <xsl:variable name="SajsCount" select="count($Rows[(@Saj)='Yes'])"></xsl:variable>
          <xsl:variable name="MiguelsCount" select="count($Rows[(@Miguel)='Yes'])"></xsl:variable>
          <xsl:variable name="VivsCount" select="count($Rows[(@Viv)='Yes'])"></xsl:variable>
          <xsl:variable name="PaulasCount" select="count($Rows[(@Paula)='Yes'])"></xsl:variable>
          <xsl:variable name="HelensCount" select="count($Rows[(@Helen)='Yes'])"></xsl:variable>
          <xsl:variable name="MatthewsCount" select="count($Rows[(@Matthew)='Yes'])"></xsl:variable>
      <tr>
       <xsl:if test="position() mod 2 = 1">
        <xsl:attribute name="class">ms-alternating</xsl:attribute>
       </xsl:if>
       <xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
        <td class="ms-vb" width="1%" nowrap="nowrap">
         <span ddwrt:amkeyfield="ID" ddwrt:amkeyvalue="ddwrt:EscapeDelims(string(@ID))" ddwrt:ammode="view"></span>
        </td>
       </xsl:if>
       <td class="ms-vb">
        <xsl:value-of select="@Title"/>
       </td>
       <td class="ms-vb">
        <xsl:attribute name="style">
         <xsl:if test="normalize-space(@Richard) = 'NA'">background-color: #000000;</xsl:if>
        </xsl:attribute>
        <xsl:value-of select="@Richard"/>
       </td>
       <td class="ms-vb">
        <xsl:attribute name="style">
         <xsl:if test="normalize-space(@AndrewP) = 'NA'">background-color: #000000;</xsl:if>
        </xsl:attribute>
        <xsl:value-of select="@AndrewP"/>
       </td>
       <td class="ms-vb">
        <xsl:attribute name="style">
         <xsl:if test="normalize-space(@Damien) = 'NA'">background-color: #000000;</xsl:if>
        </xsl:attribute>
        <xsl:value-of select="@Damien"/>
       </td>
       <td class="ms-vb">
        <xsl:attribute name="style">
         <xsl:if test="normalize-space(@AndrewC) = 'NA'">background-color: #000000;</xsl:if>
        </xsl:attribute>
        <xsl:value-of select="@AndrewC"/>
       </td>
       <td class="ms-vb">
        <xsl:attribute name="style">
         <xsl:if test="normalize-space(@Tiffany) = 'NA'">background-color: #000000;</xsl:if>
        </xsl:attribute>
        <xsl:value-of select="@Tiffany"/>
       </td>
       <td class="ms-vb">
        <xsl:attribute name="style">
         <xsl:if test="normalize-space(@David) = 'NA'">background-color: #000000;</xsl:if>
        </xsl:attribute>
        <xsl:value-of select="@David"/>
       </td>
       <td class="ms-vb">
        <xsl:attribute name="style">
         <xsl:if test="normalize-space(@Tony) = 'NA'">background-color: #000000;</xsl:if>
        </xsl:attribute>
        <xsl:value-of select="@Tony"/>
       </td>
       <td class="ms-vb">
        <xsl:attribute name="style">
         <xsl:if test="normalize-space(@Saj) = 'NA'">background-color: #000000;</xsl:if>
        </xsl:attribute>
        <xsl:value-of select="@Saj"/>
       </td>
       <td class="ms-vb">
        <xsl:attribute name="style">
         <xsl:if test="normalize-space(@Miguel) = 'NA'">background-color: #000000;</xsl:if>
        </xsl:attribute>
        <xsl:value-of select="@Miguel"/>
       </td>
       <td class="ms-vb">
        <xsl:attribute name="style">
         <xsl:if test="normalize-space(@Viv) = 'NA'">background-color: #000000;</xsl:if>
        </xsl:attribute>
        <xsl:value-of select="@Viv"/>
       </td>
       <td class="ms-vb">
        <xsl:attribute name="style">
         <xsl:if test="normalize-space(@Paula) = 'NA'">background-color: #000000;</xsl:if>
        </xsl:attribute>
        <xsl:value-of select="@Paula"/>
       </td>
       <td class="ms-vb">
        <xsl:attribute name="style">
         <xsl:if test="normalize-space(@Helen) = 'NA'">background-color: #000000;</xsl:if>
        </xsl:attribute>
        <xsl:value-of select="@Helen"/>
       </td>
       <td class="ms-vb">
        <xsl:attribute name="style">
         <xsl:if test="normalize-space(@Matthew) = 'NA'">background-color: #000000;</xsl:if>
        </xsl:attribute>
        <xsl:value-of select="@Matthew"/>
       </td>
       <td>
       <xsl:value-of select="$CountYesForAll"/>
       </td>
       <td>
        <xsl:if test="normalize-space(@Title) = 'Richard'">
         <xsl:value-of select="$CountYesForAll + $RichardsCount"/>
        </xsl:if>
        <xsl:if test="normalize-space(@Title) = 'Andrew P'">
         <xsl:value-of select="$CountYesForAll + $AndrewPsCount"/>
        </xsl:if>
        <xsl:if test="normalize-space(@Title) = 'Damien'">
         <xsl:value-of select="$CountYesForAll + $DamiensCount"/>
        </xsl:if>
        <xsl:if test="normalize-space(@Title) = 'Andrew C'">
         <xsl:value-of select="$CountYesForAll + $AndrewCsCount"/>
        </xsl:if>
        <xsl:if test="normalize-space(@Title) = 'Tiffany'">
         <xsl:value-of select="$CountYesForAll + $TiffanysCount"/>
        </xsl:if>
        <xsl:if test="normalize-space(@Title) = 'David'">
         <xsl:value-of select="$CountYesForAll + $DavidsCount"/>
        </xsl:if>
        <xsl:if test="normalize-space(@Title) = 'Tony'">
         <xsl:value-of select="$CountYesForAll + $TonysCount"/>
        </xsl:if>
        <xsl:if test="normalize-space(@Title) = 'Saj'">
         <xsl:value-of select="$CountYesForAll + $SajsCount"/>
        </xsl:if>
        <xsl:if test="normalize-space(@Title) = 'Miguel'">
         <xsl:value-of select="$CountYesForAll + $MiguelsCount"/>
        </xsl:if>
        <xsl:if test="normalize-space(@Title) = 'Viv'">
         <xsl:value-of select="$CountYesForAll + $VivsCount"/>
        </xsl:if>
        <xsl:if test="normalize-space(@Title) = 'Paula'">
         <xsl:value-of select="$CountYesForAll + $PaulasCount"/>
        </xsl:if>
        <xsl:if test="normalize-space(@Title) = 'Helen'">
         <xsl:value-of select="$CountYesForAll + $HelensCount"/>
        </xsl:if>
        <xsl:if test="normalize-space(@Title) = 'Matthew'">
         <xsl:value-of select="$CountYesForAll + $MatthewsCount"/>
        </xsl:if>
       </td>
      </tr>
     </xsl:template>
    Footer template to show sub total :
    <xsl:template name="dvt_1.footer">
      <xsl:param name="Rows" />
      <div class="bupareport">    
        <table border="0" width="100%" cellpadding="2" cellspacing="0">
       <tr>
        <td width="8%">Sub Total :</td>
        <td width="6%"> <xsl:value-of select="count($Rows[(@Richard)='Yes'])" /></td>
        <td width="6%"> <xsl:value-of select="count($Rows[(@AndrewP)='Yes'])" /></td>
        <td width="6%"> <xsl:value-of select="count($Rows[(@Damien)='Yes'])" /></td>
        <td width="6%"> <xsl:value-of select="count($Rows[(@AndrewC)='Yes'])" /></td>
        <td width="6%"> <xsl:value-of select="count($Rows[(@Tiffany)='Yes'])" /></td>
        <td width="6%"> <xsl:value-of select="count($Rows[(@David)='Yes'])" /></td>
        <td width="6%"> <xsl:value-of select="count($Rows[(@Tony)='Yes'])" /></td>
        <td width="6%"> <xsl:value-of select="count($Rows[(@Saj)='Yes'])" /></td>
        <td width="6%"> <xsl:value-of select="count($Rows[(@Miguel)='Yes'])" /></td>
        <td width="6%"> <xsl:value-of select="count($Rows[(@Viv)='Yes'])" /></td>
        <td width="6%"> <xsl:value-of select="count($Rows[(@Paula)='Yes'])" /></td>
        <td width="6%"> <xsl:value-of select="count($Rows[(@Helen)='Yes'])" /></td>
        <td width="6%"> <xsl:value-of select="count($Rows[(@Matthew)='Yes'])" /></td>
        <td width="6%"> </td>
        <td width="8%"> <xsl:value-of select="@AndrewP"> </xsl:value-of></td>
       </tr>
      </table>
      </div>
     </xsl:template>

  • XSLT counting error?

    I'm an absolute beginner with XSLT, and as a first test I'm trying to convert XML output from an SQL query to HTML. I've made it work, but I don't find it 100% logical. Here it is:
    The XML output from the SQL query:
    <ROWSET>
      <ROW>
        <customer_id>10000000 </customer_id>
        <last_name>NILSON                       </last_name>
        <first_name>JAN                          </first_name>
      </ROW>
      <ROW>
        <customer_id>90000000 </customer_id>
        <last_name>CHARLES                    </last_name>
        <first_name>RAYMOND                               </first_name>
      </ROW>
      <ROW>
        <customer_id>01379047 </customer_id>
        <last_name>LUNDSTROM                         </last_name>
        <first_name>BILL                            </first_name>
      </ROW>
    </ROWSET>Here is the XSL-doc I use for transformation:
    <xsl:stylesheet xmlns:xsl= "http://www.w3.org/1999/XSL/Transform" version="1.0">
        <xsl:output method="html"/>
        <xsl:template match="ROWSET">
            <table class="tabell">
                <tr class="headerRow">
                    <xsl:apply-templates select="ROW[1]/*" mode="ColumnHeaders" />
                </tr>
                <xsl:apply-templates />
            </table>
        </xsl:template>
        <xsl:template match="ROW">
            <xsl:variable name="rownum"><xsl:number /></xsl:variable>
            <tr>
            <xsl:choose>
                <xsl:when test="$rownum mod 2 = 1">
                    <xsl:attribute name="class">oddRow</xsl:attribute>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:attribute name="class">evenRow</xsl:attribute>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:apply-templates/>
                    <!-- Debug messages -->
                    <td class="text"><xsl:value-of select="$rownum" /></td>
                    <td class="text"><xsl:value-of select="position()" /></td>
                    <td class="text"><xsl:value-of select="last()" /></td>
            </tr>
            <!-- should be "position()=last()" but error since using ColumnHeaders (?) -->
    <!-- Here is the problem !!!!!!!!!!!!!!! -->
            <xsl:if test="position() + 1=last()">
                <tr class="headerRow">
                    <td class="number">Count:</td>
                    <td class="text"><xsl:value-of select="$rownum" /></td>
                </tr>
            </xsl:if>
        </xsl:template>
        <!-- Match any element child of a ROW -->
        <xsl:template match="ROW/*">
            <td><xsl:apply-templates/></td>
        </xsl:template>
        <!-- Match any element child of a ROW when in "ColumnHeaders" Mode-->
        <xsl:template match="ROW/*" mode="ColumnHeaders">
            <!-- Put the value of the *name* of the current element -->
            <th><xsl:value-of select="name(.)"/></th>
        </xsl:template>
    </xsl:stylesheet>Since the XML doesn't have the column headers in separate tags, I found a way to get the column headers from the names of the tags (see the last template <xsl:template match="ROW/*" mode="ColumnHeaders">).
    Please note the row after the row containing "Here is the problem !!!!!!!!!!!!!!!". There I try to print the number of records after the last record. But for some reason I have to write
    <xsl:if test="position() + 1=last()">instead of<xsl:if test="position()=last()">which I would find more logical. After adding the "Debug messages" lines above, I found out that the position increases by 2 for each row, and not by one. Why is that??
    Here is the output from the XML/XSL:
    <table class="tabell">
    <tr class="headerRow">
    <th>customer_id</th><th>last_name</th><th>first_name</th>
    </tr>
    <tr class="oddRow">
    <td>10000000 </td>
    <td>NILSON                       </td>
    <td>JAN                        </td>
    <td class="text">rownum=1</td>
    <td class="text">position()=2</td>
    <td class="text">last()=7</td>
    </tr>
    <tr class="evenRow">
    <td>90000000 </td>
    <td>RAYMOND                    </td>
    <td>CHARLES                               </td>
    <td class="text">rownum=2</td>
    <td class="text">position()=4</td>
    <td class="text">last()=7</td>
    </tr>
    <tr class="oddRow">
    <td>01379047 </td>
    <td>LUNDSTROM                         </td>
    <td>BILL                            </td>
    <td class="text">rownum=3</td>
    <td class="text">position()=6</td>
    <td class="text">last()=7</td>
    </tr>
    <tr class="headerRow">
    <td class="number">Antal:</td><td class="text">3</td>
    </tr>
    </table>As you can see my variable "rownum" counts the rows correctly. The "position()" function, however, shows twice the "rownum" value and the "last()" function shows 7 (seven) for three records (2*n+1).
    Now I have two questions:
    1 Can I rewrite my XSLT so that I can use the more intuitive<xsl:if test="position()=last()">? I still need to get the column headers from the names of the elements.
    2 Can you explain why "position()" and "last()" reports such strange numbers?

    Thanks DrClap for guiding me in the right direction! I could not figure out why there were 7 child nodes, but the whitespace before, between and after the ROW nodes become nodes in the result tree.
    The solution is to put    <!-- Make sure whitespace make a node in the result tree -->
        <xsl:strip-space elements="*" />at the top, right after "output method".
    Again, Thanks!

  • Counting number of lines in a text/csv file using xquery/xslt.

    Hi,
    I have a CSV file, I need to count the total number of lines in that file. This I have to use in OSB. My requirement is I have to count total no of lines in the $body file (CSV/flat file) and subtract header and footer lines from it.
    EX:
    header,1, @total_no_of_detal@
    detail,1
    detail,2
    detail,3
    detail,n
    footer, 1
    If suppose i have 10 detail lines, and I am getting body of the file as shown above,
    then in the final file, I have to change the body of the file as:
    header,1, *10*
    detail,1
    detail,2
    detail,3
    detail,n
    footer, 1
    Please advice how to do this in OSB.
    Edited by: user12679330 on Aug 2, 2011 2:34 AM

    I would suggest you to use MFL to convert the file into XML when you read it and then you can count the detail elements within the XML and update the values in Header element before writing the file again in flat file format again using MFL.
    You can read the documentation of Format Builder utility which is used to define MFL here:
    http://download.oracle.com/docs/cd/E21764_01/doc.1111/e15866/part_fb.htm
    Alternatively, another approach is the read the whole flat file as a text string and then doing needed manipulations to get what you need. If you want to do it like this then you will need to consider following things:
    1. Is the file in DOS format or Unix format? (To know the End of line character in use)
    2. Does the file contain an end of line at the end of file? (whether there is an end of line char at the end of data of footer record)
    Once you know above, you can try an xquery like following:
    let $intermediateXML :=
    <Root>
    for $a in (tokenize($in, 'EOL'))
    return
    if (string-length($a) > 0)
    then
    <record>{$a}</record>
    else ()
    </Root>
    let $count := count($intermediateXML/record)
    let $outXML :=
    <OutRoot>
    for $i in 1 to $count
    return
    if (data($i) = 1)
    then
    <Record>{concat($out, $intermediateXML/record[$i]/text(), ',Count=',($count)-2)}</Record>
    else
    <Record>{concat($out, $intermediateXML/record[$i]/text())}</Record>
    </OutRoot>
    return op:concatenate($outXML/Record/text(), 'EOL')In Above XQuery, replace EOL with the end of line character which for unix wound be "&#xA ;" (remove quotes and space between the A and ; ) and for DOS would be "&#xD ;&#xA ;" (remove quotes and space between the A and ; and D ; )

  • Xslt/xpath: count preceding elements which starts-with 'S'

    Hi everybody,
    I got the following XML:
    <?xml version="1.0" encoding="UTF-8"?>
    <ROOT>
         <A1>
              <FOO>1</FOO>
         </A1>
         <A1>
              <FOO>2</FOO>
         </A1>
         <B1>
              <FOO>3</FOO>
         </B1>
         <A1>
              <FOO>4</FOO>
         </A1>
    </ROOT>
    I want wo count all preceding Elements of each 3
    How has the experssion has to look?
    count(/ROOT/A1/FOO/preceding::[starts-with(.,'A')])
    DOES not work
    Any suggestions?
    Regards Mario
    Edited by: Mario Müller on Sep 12, 2008 2:23 AM

    Hi Mario,
    What are you using to test xsl expressions?
    I am using XSL Tester, all sugestions that i gave you retrieve a solution. Therefore, this solution will depend from XML tree. For instance if you have something like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <ROOT>
         <A1>
              <FOO>1</FOO>
              <FOO>5</FOO>
                            <A1000>
                                  <FOO>46</FOO>
                           <FOO>400</FOO>
                            </A1000>
              <FOO>300</FOO>
         </A1>
         <A2>
              <FOO>2</FOO>
              <FO>6</FO>
         </A2>
         <B1>
              <FOO>3</FOO>
         </B1>
         <A1>
              <FOO>4</FOO>
              <FO>7</FO>
         </A1>
    </ROOT>
    Using this XSL:
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
         <xsl:template match="/">
                <Result>
                   ---- Expression ----
              </Result>
         </xsl:template>
    </xsl:stylesheet>
    Results using the expressions that i gave you, will be:
    1.1
    <xsl:value-of select="count(//FOO[1][starts-with(name(parent::node()),'A')])"/>
    <?xml version="1.0" encoding="UTF-16"?>
         <Result>7</Result>
    1.2
    <xsl:value-of select="count(//FOO[1][starts-with(name(parent::node()),'A')])"/>
    <?xml version="1.0" encoding="UTF-16"?>
        <Result>4</Result>
    2.1
    <xsl:value-of select="count(/ROOT/*/FOO[starts-with(name(parent::node()),'A')])"/>
    <?xml version="1.0" encoding="UTF-16"?>
      <Result>5</Result>
    2.2
    <xsl:value-of select="count(/ROOT/*/FOO[1][starts-with(name(parent::node()),'A')])"/>
    <?xml version="1.0" encoding="UTF-16"?>
        <Result>3</Result>
    I think the last one, fits your solution. Give me more hints, maybe i can help you.
    Best regards,
    Pedro Pereira

  • How to count number of xml nodes , with JSTL XML api?

    I am trying to count the number of nodes in the parsed xml by doing this:
    <x:out select="count($doc/Items/Item)"/>
    There are about 50 item nodes in the source xml, but I get the output as 0
    Is this syntax correct?
    I searched every where but couldn't find the xpath syntax to be used inside jstl xml tags, I was assuming that it's the same as the syntax used in xslt

    Thank you for your reply, sorry I wasnt very clear with my question.
    I want to count the number of nodes inside the jsp file , not inside the xslt file.
    My xml file is something like this for example:
    <?xml version="1.0" encoding="UTF-8"?>
    <DocumentRootNode>
    <Products>
    <Item>1</Item>
    <Item>2</Item>
    <Item>3</Item>
    <Products>
    </DocumentRootNode>
    I want the count of number of Item nodes , in the JSP file.
    I'm doing something like this in the JSP but it gives 0 instead of 3:
    <c:import url="source.xml" var="xml" charEncoding="UTF-8"/>
    <x:parse doc="${xml}" var="xml_doc"/>
    <x:out select="count($xml_doc/Products/Item)"/>
    null

Maybe you are looking for

  • Spry Menu Bar text mirrored in IE

    I'm making my first website with Dreamweaver.  So far, I've managed to figure out all my problems on my own.  This one, though, is just weird.  My webpage looks fine on Firefox but when I load it up on Internet Explorer, my menu bar text (ex:Home) re

  • Resolution of extended display

    When connect my macbook pro to a 24" display by mini-didplay-2-vga cable, I can set the resolution to 1920x1080. But when connect it to a TV by the same cable set, the highest resolution can only be 1280x1024. Wrong ratio and wrong resolution. While

  • Excessive redo generation in Production DB?

    my production database is generation lot of redo's since one month.Nearly 45 redo's its archiving per hour.b4 it use to generate 2 redo's per hour.The size of redolog file is 300M and we are having 3 redogroups.I want to know what is causing this muc

  • Ipod nano  won't sync vidio I purchased on itunes

    I have a Ipod nano 3rd generation and I can't get it to upload I have purchased on Itunes. Tried everything any ideas?

  • Kann pdf export in austria nicht abonnieren, $ 19,90

    kann pdf export in austria nicht für $ 19,90 abonnieren pöllmann