Bad output from xslt

tia_kamakshi
tia_kamakshi used Ask the Experts™
on
Hi,

In my xslt output I only needs details from tender nodes where SUMMARYNODE[@TENDERUNIQUEID='IFSJM017AT2011c']. I wrote below xslt

XSLT

Bad output from xslt

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      
      <!--end of xsl declarations-->
      <!-- global variables -->
      <xsl:param name="tenderUniqueId" />
      <xsl:template match="//SUMMARYNODE[@TENDERUNIQUEID='IFSJM017AT2011c']">
            <xsl:apply-templates select="TENDERDETAILS"></xsl:apply-templates>      
      </xsl:template>

      <xsl:template match="TENDERDETAILS">
            <xsl:for-each select="TENDER">
                  ENQUIRYNUMBER1            
                  <xsl:value-of select="QTY"></xsl:value-of>.                  
            </xsl:for-each>

      </xsl:template>

</xsl:stylesheet>


which is giving me output as follows


OUTPUT:

IFSJM017AT2011a IFS/JM/017-T /2011a ENQUIRYNUMBER1 2,800,000. ENQUIRYNUMBER1 2,900,000. IFSJM017AT2011b IFS/JM/017-T /2011b ENQUIRYNUMBER1 2,800,000. ENQUIRYNUMBER1 2,900,000. ENQUIRYNUMBER1 2,800,005. ENQUIRYNUMBER1 2,900,006.


Why it is giving me such output. Can you please help me fixing this xslt code

Here is my xml

Please help me fixing it

Thanks & Regards
<root>

	<SUMMARYNODE SOURCEFILE="IFSJM017-T2011" TENDERUNIQUEID="IFSJM017AT2011a">
		<SUMMARY>
			<TENDERUNIQUEID>IFSJM017AT2011a</TENDERUNIQUEID>
			<ENQUIRYNUMBER>IFS/JM/017-T /2011a</ENQUIRYNUMBER>

		</SUMMARY>
		<TENDERDETAILS>
			<TENDER>
				<NO>01</NO>
				<QTY>2,800,000</QTY>
				<UNIT>Each</UNIT>
				<ITEMLIST>
					gk
				</ITEMLIST>
				<SPECIFICATIONS>Specifications are as per the attached sheet.</SPECIFICATIONS>
			</TENDER>
			<TENDER>
				<NO>02</NO>
				<QTY>2,900,000</QTY>
				<UNIT>Each</UNIT>
				<ITEMLIST>
					kljkl
				</ITEMLIST>
				<SPECIFICATIONS>Specifications are as per the attached sheet.</SPECIFICATIONS>
			</TENDER>
		</TENDERDETAILS>
	</SUMMARYNODE>

	<SUMMARYNODE SOURCEFILE="IFSJM017-T2011" TENDERUNIQUEID="IFSJM017AT2011b">
		<SUMMARY>
			<TENDERUNIQUEID>IFSJM017AT2011b</TENDERUNIQUEID>
			<ENQUIRYNUMBER>IFS/JM/017-T /2011b</ENQUIRYNUMBER>

		</SUMMARY>
		<TENDERDETAILS>
			<TENDER>
				<NO>01</NO>
				<QTY>2,800,000</QTY>
				<UNIT>Each</UNIT>
				<ITEMLIST>
					yukhyjuk
				</ITEMLIST>
				<SPECIFICATIONS>Specifications are as per the attached sheet.</SPECIFICATIONS>
			</TENDER>
			<TENDER>
				<NO>02</NO>
				<QTY>2,900,000</QTY>
				<UNIT>Each</UNIT>
				<ITEMLIST>
					jkj
				</ITEMLIST>
				<SPECIFICATIONS>Specifications are as per the attached sheet.</SPECIFICATIONS>
			</TENDER>
		</TENDERDETAILS>
	</SUMMARYNODE>

	<SUMMARYNODE SOURCEFILE="IFSJM017-T2011" TENDERUNIQUEID="IFSJM017AT2011c">
		<SUMMARY>
			<TENDERUNIQUEID>IFSJM017AT2011c</TENDERUNIQUEID>
			<ENQUIRYNUMBER>IFS/JM/017-T /2011c</ENQUIRYNUMBER>

		</SUMMARY>
		<TENDERDETAILS>
			<TENDER>
				<NO>01</NO>
				<QTY>2,800,005</QTY>
				<UNIT>Each</UNIT>
				<ITEMLIST>
					gfngf
				</ITEMLIST>
				<SPECIFICATIONS>Specifications are as per the attached sheet.</SPECIFICATIONS>
			</TENDER>
			<TENDER>
				<NO>02</NO>
				<QTY>2,900,006</QTY>
				<UNIT>Each</UNIT>
				<ITEMLIST>
					fghjf
				</ITEMLIST>
				<SPECIFICATIONS>Specifications are as per the attached sheet.</SPECIFICATIONS>
			</TENDER>
		</TENDERDETAILS>
	</SUMMARYNODE>

</root>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Information Architect
Top Expert 2006
Commented:
you need also a template that removes the other summarynodes
(you should actually be selective on a higher level)

 <xsl:template match="SUMMARYNODE[not(@TENDERUNIQUEID='IFSJM017AT2011c')]"/>

will fix this

Author

Commented:
Many Thanks
Gertone (Geert Bormans)Information Architect
Top Expert 2006

Commented:
In this case I strongly believe you should organize this from a higher level
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
    <!--end of xsl declarations-->
    <!-- global variables -->
    <xsl:param name="tenderUniqueId" />
    
    <xsl:template match="root">
        <xsl:apply-templates select="SUMMARYNODE[@TENDERUNIQUEID='IFSJM017AT2011c']"/>
    </xsl:template>
    
    <xsl:template match="SUMMARYNODE">
        <xsl:apply-templates select="TENDERDETAILS"></xsl:apply-templates>      
    </xsl:template>
    
    <xsl:template match="TENDERDETAILS">
        <xsl:for-each select="TENDER">
            ENQUIRYNUMBER1            
            <xsl:value-of select="QTY"></xsl:value-of>.                  
        </xsl:for-each>
        
    </xsl:template>
    
</xsl:stylesheet>

Open in new window

Gertone (Geert Bormans)Information Architect
Top Expert 2006

Commented:
welcome

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial