webmasterbeta
New Member
I am trying to loop through the xml fle data and create a FO object for it but my loop in xsl file selects the first record only and displayes in multiple times equal to number of data records in file.
What is not right in this code?
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:ns1="urn:GoogleSearch" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns1:GoogleSearchResult" >
<xsl:template match="/">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="general" page-height="6in" margin-bottom="0.5in" margin-left="1in" margin-right="1in">
<fo:region-body margin-top="0.5in" margin-bottom="0.5in"/>
<fo:region-before extent="1.0in"/>
<fo:region-after extent="0.5in"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="otherpages" page-height="6in" margin-bottom="0.5in" margin-left="1in" margin-right="1in">
<fo:region-body margin-top="0.5in" margin-bottom="0.5in"/>
<fo:region-before extent="1.0in"/>
<fo:region-after extent="0.5in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<foage-sequence master-reference="general" initial-page-number="1">
<fo:flow flow-name="xsl-region-body">
<fo:block font-size="30pt" font-family="Verdana" background-color="#eeddff">
<fo:external-graphic src=http://www.webdeveloper.com/forum/archive/index.php/"file:logo_sm.gif" />
</fo:block>
<fo:block>
Results from <xsl:value-of select="//return/startIndex" /> - <xsl:value-of select="//return/endIndex" /> from total of <xsl:value-of select="//return/estimatedTotalResultsCount" /> for <xsl:value-of select="//return/searchQuery"/> in (<xsl:value-of select="//return/searchTime" />) seconds.
</fo:block>
</fo:flow>
</foage-sequence>
<foage-sequence master-reference="otherpages" initial-page-number="auto">
<fo:static-content flow-name="xsl-region-before">
<fo:block font-size="20pt" font-family="serif" line-height="30pt" background-color="yellow">
p. <foage-number/> Result for query <xsl:value-of select="//return/searchQuery"/> </fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<xsl:for-each select="//return">
<fo:block font-size="12pt" color="blue">Title:<xsl:value-of select="//return/resultElements/item/directoryTitle"/></fo:block>
<fo:block font-size="12pt" color="black"><xsl:value-of select="//return/resultElements/item/summary"/></fo:block>
<fo:block font-size="12pt" color="black" font-style="italic"><xsl:value-of select="//return/resultElements/item/snippet"/></fo:block>
<fo:block font-size="12pt" color="green"><xsl:value-of select="//return/resultElements/item/URL"/> - <xsl:value-of select="//return/resultElements/item/cachedSize"/> - cached ></fo:block>
</xsl:for-each>
</fo:flow>
</foage-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>
What is not right in this code?
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:ns1="urn:GoogleSearch" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns1:GoogleSearchResult" >
<xsl:template match="/">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="general" page-height="6in" margin-bottom="0.5in" margin-left="1in" margin-right="1in">
<fo:region-body margin-top="0.5in" margin-bottom="0.5in"/>
<fo:region-before extent="1.0in"/>
<fo:region-after extent="0.5in"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="otherpages" page-height="6in" margin-bottom="0.5in" margin-left="1in" margin-right="1in">
<fo:region-body margin-top="0.5in" margin-bottom="0.5in"/>
<fo:region-before extent="1.0in"/>
<fo:region-after extent="0.5in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<foage-sequence master-reference="general" initial-page-number="1">
<fo:flow flow-name="xsl-region-body">
<fo:block font-size="30pt" font-family="Verdana" background-color="#eeddff">
<fo:external-graphic src=http://www.webdeveloper.com/forum/archive/index.php/"file:logo_sm.gif" />
</fo:block>
<fo:block>
Results from <xsl:value-of select="//return/startIndex" /> - <xsl:value-of select="//return/endIndex" /> from total of <xsl:value-of select="//return/estimatedTotalResultsCount" /> for <xsl:value-of select="//return/searchQuery"/> in (<xsl:value-of select="//return/searchTime" />) seconds.
</fo:block>
</fo:flow>
</foage-sequence>
<foage-sequence master-reference="otherpages" initial-page-number="auto">
<fo:static-content flow-name="xsl-region-before">
<fo:block font-size="20pt" font-family="serif" line-height="30pt" background-color="yellow">
p. <foage-number/> Result for query <xsl:value-of select="//return/searchQuery"/> </fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<xsl:for-each select="//return">
<fo:block font-size="12pt" color="blue">Title:<xsl:value-of select="//return/resultElements/item/directoryTitle"/></fo:block>
<fo:block font-size="12pt" color="black"><xsl:value-of select="//return/resultElements/item/summary"/></fo:block>
<fo:block font-size="12pt" color="black" font-style="italic"><xsl:value-of select="//return/resultElements/item/snippet"/></fo:block>
<fo:block font-size="12pt" color="green"><xsl:value-of select="//return/resultElements/item/URL"/> - <xsl:value-of select="//return/resultElements/item/cachedSize"/> - cached ></fo:block>
</xsl:for-each>
</fo:flow>
</foage-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>