• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3503
  • Last Modified:

xsl for-each repeat number of times

Hi.
I have some XML data :
<Import>
  <row>  
    <name> blablabla </name>
    <nTimes>8</nTimes>
  <row>
  <row>  
    <name> blebleble </name>
    <nTimes>3</nTimes>
  <row>
</Import>

I want to transform it with xsl and have some code like this :
  <xsl:for-each select="Row">
BUT, I would like the blablabla to be repeated 8 times and the blebleble repeated 3 times

Someone can help me here ??
0
conceptdata
Asked:
conceptdata
  • 5
  • 5
1 Solution
 
zc2Commented:
I used a recursive template call to repeat the strings the specified number of times:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template match="/Import">
		<xsl:for-each select="row">
			<xsl:call-template name="repeat">
				<xsl:with-param name="num" select="nTimes"/><xsl:with-param name="str" select="name"/>				
			</xsl:call-template>
  		</xsl:for-each>
	</xsl:template>
	
	<xsl:template name="repeat">
		<xsl:param name="str"/>
		<xsl:param name="num"/>
		<xsl:if test="$num &gt; 0">
			<xsl:value-of select="$str"/>
			<xsl:call-template name="repeat">
				<xsl:with-param name="num" select="$num - 1"/><xsl:with-param name="str" select="$str"/>				
			</xsl:call-template>
  		</xsl:if>
 	</xsl:template>
	
</xsl:stylesheet>

Open in new window

0
 
conceptdataAuthor Commented:
I can see how you do it.
But can you give me a hint about putting your code into this.

Look at code snippet
<xsl:for-each select="Row">
 
<fo:table-row height="133.72795pt" keep-with-next.within-column="always">
<fo:table-cell display-align="before" background-color="transparent">
<fo:block line-height="10.799999999999999pt" white-space-collapse="true"  text-align="start" background-color="transparent">
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:text>Style</xsl:text></fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
</fo:inline>
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
<xsl:text>  </xsl:text></fo:inline>
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
<xsl:value-of disable-output-escaping="no" select="Style"/>
</fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
</fo:inline>
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:text>Description</xsl:text></fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
</fo:inline>
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
<xsl:text>  </xsl:text></fo:inline>
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
<xsl:value-of disable-output-escaping="no" select="Navn"/>
</fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
</fo:inline>
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:text>Colour</xsl:text></fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
</fo:inline>
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
<xsl:text>  </xsl:text></fo:inline>
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
<xsl:value-of disable-output-escaping="no" select="Farvenavn"/>
</fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
</fo:inline>
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:text>Size</xsl:text></fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
</fo:inline>
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
<xsl:text>  </xsl:text></fo:inline>
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
<xsl:value-of disable-output-escaping="no" select="Størrelse"/>
</fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:text>
</xsl:text></fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
</fo:inline>
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="6.0pt">
<xsl:text>Recommended retail prices</xsl:text></fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="6.0pt">
</fo:inline>
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:value-of disable-output-escaping="no" select="Valuta_x0020_1"/>
</fo:inline>
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:text>  </xsl:text></fo:inline>
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:value-of disable-output-escaping="no" select="Pris_x0020_1"/>
</fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
</fo:inline>
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:value-of disable-output-escaping="no" select="Valuta_x0020_2"/>
</fo:inline>
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:text>  </xsl:text></fo:inline>
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:value-of disable-output-escaping="no" select="Pris_x0020_2"/>
</fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
</fo:inline>
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:value-of disable-output-escaping="no" select="Valuta_x0020_3"/>
</fo:inline>
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:text>  </xsl:text></fo:inline>
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:value-of disable-output-escaping="no" select="Pris_x0020_3"/>
</fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
</fo:inline>
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:value-of disable-output-escaping="no" select="Valuta_x0020_4"/>
</fo:inline>
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:text>  </xsl:text></fo:inline>
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:value-of disable-output-escaping="no" select="Pris_x0020_4"/>
</fo:inline>
</fo:block>
</fo:block>
</fo:table-cell>
</fo:table-row>
 
<fo:table-row height="42.67913pt">
<fo:table-cell display-align="center">
<fo:block position="relative" white-space-collapse="false"  linefeed-treatment="preserve"  padding-bottom="30.0pt" padding-top="30.0pt" display-align="center" text-align="start" color="#000000" font-family="Arial" font-size="12.0pt"><fo:instream-foreign-object>
  <xsl:call-template name="draw-bar-code">
     <xsl:with-param name="value" select="EAN"/>
     <xsl:with-param name="code-type" select="'EAN-13'"/>
     <xsl:with-param name="module" select="0.6"/>
     <xsl:with-param name="unit" select="cm"/>
     <xsl:with-param name="height" select="34.1433"/>
     <xsl:with-param name="font-height" select="12"/>
     <xsl:with-param name="font-family" select="'Arial'"/>
     <xsl:with-param name="font-style" select="'normal'"/>
     <xsl:with-param name="font-weight" select="'normal'"/>
   </xsl:call-template>
</fo:instream-foreign-object>
</fo:block>
</fo:table-cell>
</fo:table-row>
 
</xsl:for-each>

Open in new window

0
 
zc2Commented:
I'm sorry, but I have no idea what are you going to repeat in your XSL-FO. You have jumped from an abstract sample to a real life code so suddenly. :)
Please explain.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
conceptdataAuthor Commented:
Ok, I try to explain
The Code snippet is my xml file.
The <Antal>52</Antal> tag is the number of times the row must be repeated.

It is for a labelsheet, and the Style 1391600706 must be repeated 13 times ( on 13 labels )

Did it help ?

<?xml version="1.0" encoding="UTF-8"?>
<Import>
	<Row>
		<Style>1391600706</Style>
		<Nøgle>900006</Nøgle>
		<Navn>Rib T-Shirt LS</Navn>
		<Farve>0006</Farve>
		<Farvenavn>charcoalgrey</Farvenavn>
		<Størrelse>2</Størrelse>
		<Enhed>Yr</Enhed>
		<Tekst/>
		<Gruppe_x0020_1/>
		<Valuta_x0020_1>DKK</Valuta_x0020_1>
		<Pris_x0020_1>90,00</Pris_x0020_1>
		<Gruppe_x0020_2/>
		<Valuta_x0020_2>EUR</Valuta_x0020_2>
		<Pris_x0020_2>14,00</Pris_x0020_2>
		<Gruppe_x0020_3/>
		<Valuta_x0020_3>SEK</Valuta_x0020_3>
		<Pris_x0020_3>130,00</Pris_x0020_3>
		<Gruppe_x0020_4/>
		<Valuta_x0020_4>NOK</Valuta_x0020_4>
		<Pris_x0020_4>120,00</Pris_x0020_4>
		<Gruppe_x0020_5/>
		<Valuta_x0020_5>USD</Valuta_x0020_5>
		<Pris_x0020_5>0,00</Pris_x0020_5>
		<Produktkode>1391600706</Produktkode>
		<EAN/>
		<Tekst_x0020_A/>
		<Tekst_x0020_B/>
		<Tekst_x0020_C/>
		<Antal>13</Antal>
		<Tabel_x0020_nr>1</Tabel_x0020_nr>
	</Row>
	<Row>
		<Style>30591960076</Style>
		<Nøgle>900006</Nøgle>
		<Navn>Rib T-Shirt LS</Navn>
		<Farve>0006</Farve>
		<Farvenavn>charcoalgrey</Farvenavn>
		<Størrelse>4</Størrelse>
		<Enhed>Yr</Enhed>
		<Tekst/>
		<Gruppe_x0020_1/>
		<Valuta_x0020_1>DKK</Valuta_x0020_1>
		<Pris_x0020_1>90,00</Pris_x0020_1>
		<Gruppe_x0020_2/>
		<Valuta_x0020_2>EUR</Valuta_x0020_2>
		<Pris_x0020_2>14,00</Pris_x0020_2>
		<Gruppe_x0020_3/>
		<Valuta_x0020_3>SEK</Valuta_x0020_3>
		<Pris_x0020_3>130,00</Pris_x0020_3>
		<Gruppe_x0020_4/>
		<Valuta_x0020_4>NOK</Valuta_x0020_4>
		<Pris_x0020_4>120,00</Pris_x0020_4>
		<Gruppe_x0020_5/>
		<Valuta_x0020_5>USD</Valuta_x0020_5>
		<Pris_x0020_5>0,00</Pris_x0020_5>
		<Produktkode>30591960076</Produktkode>
		<EAN/>
		<Tekst_x0020_A/>
		<Tekst_x0020_B/>
		<Tekst_x0020_C/>
		<Antal>52</Antal>
		<Tabel_x0020_nr>2</Tabel_x0020_nr>
	</Row>
</Import>

Open in new window

0
 
zc2Commented:
Not exactly. What should be repeated - the whole row with all the fields, or only the caption and value of the "Style" field?
If it the second, then the XSL could be like the snippet bellow.
But if it the first (i.e. whole row should be repeated), then just move all the other elements inside the "style-repeat" template.

(some tags in your code had characters invalid on my system. I had to replace them with a dash ('-'). Please be aware.)
    <xsl:template name="style-repeat">
            <xsl:param name="str"/>
            <xsl:param name="num"/>
            <xsl:if test="$num &gt; 0">
				<fo:block text-align="left" white-space-collapse="true">
					<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
						<xsl:text>Style</xsl:text>
					</fo:inline>
				</fo:block>
				<fo:block text-align="left" white-space-collapse="true">
					<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt"/>
					<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
						<xsl:text/>
					</fo:inline>
					<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
						<xsl:value-of disable-output-escaping="no" select="Style"/>
					</fo:inline>
				</fo:block>
                <xsl:call-template name="style-repeat">
                        <xsl:with-param name="num" select="$num - 1"/><xsl:with-param name="str" select="$str"/>                                
                </xsl:call-template>
            </xsl:if>
    </xsl:template>
 
	<xsl:template match="Import">
		<xsl:for-each select="Row">
			<fo:table-row height="133.72795pt" keep-with-next.within-column="always">
				<fo:table-cell display-align="before" background-color="transparent">
					<fo:block line-height="10.799999999999999pt" white-space-collapse="true" text-align="start" background-color="transparent">
 						<!-- call to the recursive template -->
                        <xsl:call-template name="style-repeat">
                                <xsl:with-param name="num" select="Antal"/>
                        </xsl:call-template>
 						<fo:block text-align="left" white-space-collapse="true">
							<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt"/>
							<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
								<xsl:text>Description</xsl:text>
							</fo:inline>
						</fo:block>
						<fo:block text-align="left" white-space-collapse="true">
							<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt"/>
							<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
								<xsl:text/>
							</fo:inline>
							<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
								<xsl:value-of disable-output-escaping="no" select="Navn"/>
							</fo:inline>
						</fo:block>
						<fo:block text-align="left" white-space-collapse="true">
							<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt"/>
							<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
								<xsl:text>Colour</xsl:text>
							</fo:inline>
						</fo:block>
						<fo:block text-align="left" white-space-collapse="true">
							<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt"/>
							<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
								<xsl:text/>
							</fo:inline>
							<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
								<xsl:value-of disable-output-escaping="no" select="Farvenavn"/>
							</fo:inline>
						</fo:block>
						<fo:block text-align="left" white-space-collapse="true">
							<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt"/>
							<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
								<xsl:text>Size</xsl:text>
							</fo:inline>
						</fo:block>
						<fo:block text-align="left" white-space-collapse="true">
							<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt"/>
							<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
								<xsl:text/>
							</fo:inline>
							<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
								<xsl:value-of disable-output-escaping="no" select="St-rrelse"/>
							</fo:inline>
						</fo:block>
						<fo:block text-align="left" white-space-collapse="true">
							<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
								<xsl:text/>
							</fo:inline>
						</fo:block>
						<fo:block text-align="left" white-space-collapse="true">
							<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt"/>
							<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="6.0pt">
								<xsl:text>Recommended retail prices</xsl:text>
							</fo:inline>
						</fo:block>
						<fo:block text-align="left" white-space-collapse="true">
							<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="6.0pt"/>
							<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
								<xsl:value-of disable-output-escaping="no" select="Valuta_x0020_1"/>
							</fo:inline>
							<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
								<xsl:text/>
							</fo:inline>
							<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
								<xsl:value-of disable-output-escaping="no" select="Pris_x0020_1"/>
							</fo:inline>
						</fo:block>
						<fo:block text-align="left" white-space-collapse="true">
							<fo:inline color="#000000" font-family="Arial" font-size="9.0pt"/>
							<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
								<xsl:value-of disable-output-escaping="no" select="Valuta_x0020_2"/>
							</fo:inline>
							<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
								<xsl:text/>
							</fo:inline>
							<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
								<xsl:value-of disable-output-escaping="no" select="Pris_x0020_2"/>
							</fo:inline>
						</fo:block>
						<fo:block text-align="left" white-space-collapse="true">
							<fo:inline color="#000000" font-family="Arial" font-size="9.0pt"/>
							<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
								<xsl:value-of disable-output-escaping="no" select="Valuta_x0020_3"/>
							</fo:inline>
							<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
								<xsl:text/>
							</fo:inline>
							<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
								<xsl:value-of disable-output-escaping="no" select="Pris_x0020_3"/>
							</fo:inline>
						</fo:block>
						<fo:block text-align="left" white-space-collapse="true">
							<fo:inline color="#000000" font-family="Arial" font-size="9.0pt"/>
							<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
								<xsl:value-of disable-output-escaping="no" select="Valuta_x0020_4"/>
							</fo:inline>
							<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
								<xsl:text/>
							</fo:inline>
							<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
								<xsl:value-of disable-output-escaping="no" select="Pris_x0020_4"/>
							</fo:inline>
						</fo:block>
					</fo:block>
				</fo:table-cell>
			</fo:table-row>
			<fo:table-row height="42.67913pt">
				<fo:table-cell display-align="center">
					<fo:block position="relative" white-space-collapse="false" linefeed-treatment="preserve" padding-bottom="30.0pt" padding-top="30.0pt" display-align="center" text-align="start" color="#000000" font-family="Arial" font-size="12.0pt">
						<fo:instream-foreign-object>
  <xsl:call-template name="draw-bar-code">
     <xsl:with-param name="value" select="EAN"/>
     <xsl:with-param name="code-type" select="'EAN-13'"/>
     <xsl:with-param name="module" select="0.6"/>
     <xsl:with-param name="unit" select="cm"/>
     <xsl:with-param name="height" select="34.1433"/>
     <xsl:with-param name="font-height" select="12"/>
     <xsl:with-param name="font-family" select="'Arial'"/>
     <xsl:with-param name="font-style" select="'normal'"/>
     <xsl:with-param name="font-weight" select="'normal'"/>
   </xsl:call-template>
						</fo:instream-foreign-object>
					</fo:block>
				</fo:table-cell>
			</fo:table-row>
		</xsl:for-each>
	</xsl:template>

Open in new window

0
 
zc2Commented:
oops, I forgot to remove the "str" parameter from the template. It's not necessary anymore. Please remove it in the both places.
0
 
conceptdataAuthor Commented:
Hi again
the whole row with all the fields

I have to fix it i XSLFAST, so I can edit it later on.

Have you any suggestions ?
0
 
conceptdataAuthor Commented:
My whole xsl file is attached
<?xml version="1.0" encoding="UTF-8"?>
 
<!-- File was generated by XSLfast 3.1.26 -->
<!-- Please leave unchanged; manage layouts unstead -->
<!DOCTYPE xsl:stylesheet [
<!ENTITY XML "http://www.w3.org/TR/REC-xml">
<!ENTITY XMLNames "http://www.w3.org/TR/REC-xml-names">
<!ENTITY XSLT.ns "http://www.w3.org/1999/XSL/Transform">
<!ENTITY XSLTA.ns "http://www.w3.org/1999/XSL/TransformAlias">
<!ENTITY XSLFO.ns "http://www.w3.org/1999/XSL/Format">
<!ENTITY copy "&#169;">
<!ENTITY trade "&#8482;">
<!ENTITY deg "&#x00b0;">
<!ENTITY gt "&#62;">
<!ENTITY sup2 "&#x00b2;">
<!ENTITY frac14 "&#x00bc;">
<!ENTITY quot "&#34;">
<!ENTITY frac12 "&#x00bd;">
<!ENTITY euro "&#x20ac;">
<!ENTITY Omega "&#937;">
]>
 
<xsl:stylesheet xmlns:fox="http://xml.apache.org/fop/extensions" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:saxon="http://icl.com/saxon" extension-element-prefixes="saxon" >
 
<xsl:template match="Import">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="pagemaster1" page-height="844.98994pt" page-width="597.99157pt" margin-top="9.98691pt" margin-left="9.98691pt" margin-bottom="9.98691pt" margin-right="6.00353pt">
<fo:region-body margin-left="50.0pt" margin-top="62.0pt" margin-bottom="80.00914pt" margin-right="50.0pt" column-count="5" column-gap="2.84527pt"/>
<fo:region-before extent="62.0pt" precedence="true"/>
<fo:region-after extent="80.00914pt" precedence="true"/>
<fo:region-start extent="50.0pt" precedence="false"/>
<fo:region-end extent="50.0pt" precedence="false"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-name="pagemaster1" master-reference="pagemaster1">
<xsl:attribute name="force-page-count">no-force</xsl:attribute>
<fo:static-content flow-name="xsl-region-before"/>
<fo:static-content flow-name="xsl-region-after"/>
<fo:static-content flow-name="xsl-region-start"/>
<fo:static-content flow-name="xsl-region-end"/>
<fo:flow flow-name="xsl-region-body">
<fo:block/>
<fo:block-container position="absolute" top="4pt" left="2pt" height="752.0pt" width="536.0pt" border-width="1.0pt"> <fo:block span="none" white-space-collapse="false" font-family="Helvetica" font-size="12pt" text-align="start" position="relative" top="44pt" left="27pt" height="752.0pt" width="536.0pt"><fo:instream-foreign-object xmlns:xlink="http://www.w3.org/1999/xlink"><svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="600" height="600" viewBox="0 0 1000 1000"> <g id="test-body-content"><text x="0" y="250" style="opacity:.1; font-family:Arial; font-size:200pt; fill:rgb(200,200,200)">XSLfast</text><text x="50" y="420" style="opacity:.1; font-family:Arial; font-size:200pt; fill:rgb(200,200,200)">DEMO</text></g></svg></fo:instream-foreign-object></fo:block></fo:block-container><fo:block span="none"><!-- GENERATE TABLE START-->
 
<fo:table table-layout="fixed">
<fo:table-column column-width="98.162pt"/>
<fo:table-body>
<xsl:for-each select="Row">
 
<fo:table-row height="169.29389pt" keep-with-next.within-column="always">
<fo:table-cell display-align="before" background-color="transparent">
<fo:block line-height="10.799999999999999pt" white-space-collapse="true"  text-align="start" background-color="transparent">
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:text>Style</xsl:text></fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
</fo:inline>
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
<xsl:text>  </xsl:text></fo:inline>
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
<xsl:value-of disable-output-escaping="no" select="Style"/>
</fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
</fo:inline>
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:text>Description</xsl:text></fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
</fo:inline>
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
<xsl:text>  </xsl:text></fo:inline>
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
<xsl:value-of disable-output-escaping="no" select="Navn"/>
</fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
</fo:inline>
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:text>Colour</xsl:text></fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
</fo:inline>
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
<xsl:text>  </xsl:text></fo:inline>
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
<xsl:value-of disable-output-escaping="no" select="Farvenavn"/>
</fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
</fo:inline>
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:text>Size</xsl:text></fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
</fo:inline>
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
<xsl:text>  </xsl:text></fo:inline>
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
<xsl:value-of disable-output-escaping="no" select="Størrelse"/>
</fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:text>
</xsl:text></fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
</fo:inline>
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="6.0pt">
<xsl:text>Recommended retail prices</xsl:text></fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="6.0pt">
</fo:inline>
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:value-of disable-output-escaping="no" select="Valuta_x0020_1"/>
</fo:inline>
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:text>  </xsl:text></fo:inline>
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:value-of disable-output-escaping="no" select="Pris_x0020_1"/>
</fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
</fo:inline>
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:value-of disable-output-escaping="no" select="Valuta_x0020_2"/>
</fo:inline>
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:text>  </xsl:text></fo:inline>
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:value-of disable-output-escaping="no" select="Pris_x0020_2"/>
</fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
</fo:inline>
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:value-of disable-output-escaping="no" select="Valuta_x0020_3"/>
</fo:inline>
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:text>  </xsl:text></fo:inline>
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:value-of disable-output-escaping="no" select="Pris_x0020_3"/>
</fo:inline>
</fo:block>
<fo:block text-align="left" white-space-collapse="true" >
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
</fo:inline>
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:value-of disable-output-escaping="no" select="Valuta_x0020_4"/>
</fo:inline>
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:text>  </xsl:text></fo:inline>
<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
<xsl:value-of disable-output-escaping="no" select="Pris_x0020_4"/>
</fo:inline>
</fo:block>
</fo:block>
</fo:table-cell>
</fo:table-row>
 
<fo:table-row height="56.90551pt">
<fo:table-cell display-align="before">
<fo:block line-height="7.199999999999999pt" white-space-collapse="false"  linefeed-treatment="preserve"  text-align="start" color="#000000" font-family="IDAutomationC39XL" font-size="6.0pt">
<xsl:value-of disable-output-escaping="no" select="EAN"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each></fo:table-body>
</fo:table>
</fo:block></fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>

Open in new window

0
 
zc2Commented:
I have no idea how to deal with XSLFAST in this case.
I modified the XSLT you provided in the last comment to make it repeat the whole fo:table-row with its content as many times as specified in the "Antal" xml element.

(again, please restore the name of the "St?rrelse" string, it has lost one character )
<?xml version="1.0" encoding="UTF-8"?>
 
<!-- File was generated by XSLfast 3.1.26 -->
<!-- Please leave unchanged; manage layouts unstead -->
<!DOCTYPE xsl:stylesheet [
<!ENTITY XML "http://www.w3.org/TR/REC-xml">
<!ENTITY XMLNames "http://www.w3.org/TR/REC-xml-names">
<!ENTITY XSLT.ns "http://www.w3.org/1999/XSL/Transform">
<!ENTITY XSLTA.ns "http://www.w3.org/1999/XSL/TransformAlias">
<!ENTITY XSLFO.ns "http://www.w3.org/1999/XSL/Format">
<!ENTITY copy "&#169;">
<!ENTITY trade "&#8482;">
<!ENTITY deg "&#x00b0;">
<!ENTITY gt "&#62;">
<!ENTITY sup2 "&#x00b2;">
<!ENTITY frac14 "&#x00bc;">
<!ENTITY quot "&#34;">
<!ENTITY frac12 "&#x00bd;">
<!ENTITY euro "&#x20ac;">
<!ENTITY Omega "&#937;">
]>
 
<xsl:stylesheet xmlns:fox="http://xml.apache.org/fop/extensions" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:saxon="http://icl.com/saxon" extension-element-prefixes="saxon" >
<xsl:output method="xml" indent="yes"/>
 
<xsl:template name="repeat-row">
    <xsl:param name="num"/>
    <xsl:if test="$num &gt; 0">
 
		<fo:table-row height="169.29389pt" keep-with-next.within-column="always">
		<fo:table-cell display-align="before" background-color="transparent">
		<fo:block line-height="10.799999999999999pt" white-space-collapse="true"  text-align="start" background-color="transparent">
		<fo:block text-align="left" white-space-collapse="true" >
		<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
		<xsl:text>Style</xsl:text></fo:inline>
		</fo:block>
		<fo:block text-align="left" white-space-collapse="true" >
		<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
		</fo:inline>
		<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
		<xsl:text>  </xsl:text></fo:inline>
		<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
		<xsl:value-of disable-output-escaping="no" select="Style"/>
		</fo:inline>
		</fo:block>
		<fo:block text-align="left" white-space-collapse="true" >
		<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
		</fo:inline>
		<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
		<xsl:text>Description</xsl:text></fo:inline>
		</fo:block>
		<fo:block text-align="left" white-space-collapse="true" >
		<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
		</fo:inline>
		<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
		<xsl:text>  </xsl:text></fo:inline>
		<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
		<xsl:value-of disable-output-escaping="no" select="Navn"/>
		</fo:inline>
		</fo:block>
		<fo:block text-align="left" white-space-collapse="true" >
		<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
		</fo:inline>
		<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
		<xsl:text>Colour</xsl:text></fo:inline>
		</fo:block>
		<fo:block text-align="left" white-space-collapse="true" >
		<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
		</fo:inline>
		<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
		<xsl:text>  </xsl:text></fo:inline>
		<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
		<xsl:value-of disable-output-escaping="no" select="Farvenavn"/>
		</fo:inline>
		</fo:block>
		<fo:block text-align="left" white-space-collapse="true" >
		<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
		</fo:inline>
		<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
		<xsl:text>Size</xsl:text></fo:inline>
		</fo:block>
		<fo:block text-align="left" white-space-collapse="true" >
		<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
		</fo:inline>
		<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
		<xsl:text>  </xsl:text></fo:inline>
		<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt" font-weight="bold">
		<xsl:value-of disable-output-escaping="no" select="St-rrelse"/>
		</fo:inline>
		</fo:block>
		<fo:block text-align="left" white-space-collapse="true" >
		<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
		<xsl:text>
		</xsl:text></fo:inline>
		</fo:block>
		<fo:block text-align="left" white-space-collapse="true" >
		<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="9.0pt">
		</fo:inline>
		<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="6.0pt">
		<xsl:text>Recommended retail prices</xsl:text></fo:inline>
		</fo:block>
		<fo:block text-align="left" white-space-collapse="true" >
		<fo:inline background-color="transparent" color="#000000" font-family="Arial" font-size="6.0pt">
		</fo:inline>
		<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
		<xsl:value-of disable-output-escaping="no" select="Valuta_x0020_1"/>
		</fo:inline>
		<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
		<xsl:text>  </xsl:text></fo:inline>
		<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
		<xsl:value-of disable-output-escaping="no" select="Pris_x0020_1"/>
		</fo:inline>
		</fo:block>
		<fo:block text-align="left" white-space-collapse="true" >
		<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
		</fo:inline>
		<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
		<xsl:value-of disable-output-escaping="no" select="Valuta_x0020_2"/>
		</fo:inline>
		<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
		<xsl:text>  </xsl:text></fo:inline>
		<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
		<xsl:value-of disable-output-escaping="no" select="Pris_x0020_2"/>
		</fo:inline>
		</fo:block>
		<fo:block text-align="left" white-space-collapse="true" >
		<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
		</fo:inline>
		<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
		<xsl:value-of disable-output-escaping="no" select="Valuta_x0020_3"/>
		</fo:inline>
		<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
		<xsl:text>  </xsl:text></fo:inline>
		<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
		<xsl:value-of disable-output-escaping="no" select="Pris_x0020_3"/>
		</fo:inline>
		</fo:block>
		<fo:block text-align="left" white-space-collapse="true" >
		<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
		</fo:inline>
		<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
		<xsl:value-of disable-output-escaping="no" select="Valuta_x0020_4"/>
		</fo:inline>
		<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
		<xsl:text>  </xsl:text></fo:inline>
		<fo:inline color="#000000" font-family="Arial" font-size="9.0pt">
		<xsl:value-of disable-output-escaping="no" select="Pris_x0020_4"/>
		</fo:inline>
		</fo:block>
		</fo:block>
		</fo:table-cell>
		</fo:table-row>
		 
        <xsl:call-template name="repeat-row">
                <xsl:with-param name="num" select="$num - 1"/>
        </xsl:call-template>
    </xsl:if>
</xsl:template>
 
 
<xsl:template match="Import">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="pagemaster1" page-height="844.98994pt" page-width="597.99157pt" margin-top="9.98691pt" margin-left="9.98691pt" margin-bottom="9.98691pt" margin-right="6.00353pt">
<fo:region-body margin-left="50.0pt" margin-top="62.0pt" margin-bottom="80.00914pt" margin-right="50.0pt" column-count="5" column-gap="2.84527pt"/>
<fo:region-before extent="62.0pt" precedence="true"/>
<fo:region-after extent="80.00914pt" precedence="true"/>
<fo:region-start extent="50.0pt" precedence="false"/>
<fo:region-end extent="50.0pt" precedence="false"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-name="pagemaster1" master-reference="pagemaster1">
<xsl:attribute name="force-page-count">no-force</xsl:attribute>
<fo:static-content flow-name="xsl-region-before"/>
<fo:static-content flow-name="xsl-region-after"/>
<fo:static-content flow-name="xsl-region-start"/>
<fo:static-content flow-name="xsl-region-end"/>
<fo:flow flow-name="xsl-region-body">
<fo:block/>
<fo:block-container position="absolute" top="4pt" left="2pt" height="752.0pt" width="536.0pt" border-width="1.0pt"> <fo:block span="none" white-space-collapse="false" font-family="Helvetica" font-size="12pt" text-align="start" position="relative" top="44pt" left="27pt" height="752.0pt" width="536.0pt"><fo:instream-foreign-object xmlns:xlink="http://www.w3.org/1999/xlink"><svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="600" height="600" viewBox="0 0 1000 1000"> <g id="test-body-content"><text x="0" y="250" style="opacity:.1; font-family:Arial; font-size:200pt; fill:rgb(200,200,200)">XSLfast</text><text x="50" y="420" style="opacity:.1; font-family:Arial; font-size:200pt; fill:rgb(200,200,200)">DEMO</text></g></svg></fo:instream-foreign-object></fo:block></fo:block-container><fo:block span="none"><!-- GENERATE TABLE START-->
 
<fo:table table-layout="fixed">
<fo:table-column column-width="98.162pt"/>
<fo:table-body>
<xsl:for-each select="Row">
    <xsl:call-template name="repeat-row">
            <xsl:with-param name="num" select="Antal"/>
    </xsl:call-template>
	<fo:table-row height="56.90551pt">
	<fo:table-cell display-align="before">
	<fo:block line-height="7.199999999999999pt" white-space-collapse="false"  linefeed-treatment="preserve"  text-align="start" color="#000000" font-family="IDAutomationC39XL" font-size="6.0pt">
	<xsl:value-of disable-output-escaping="no" select="EAN"/>
	</fo:block>
	</fo:table-cell>
	</fo:table-row>
</xsl:for-each></fo:table-body>
</fo:table>
</fo:block></fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>

Open in new window

0
 
conceptdataAuthor Commented:
Superb - THANKS zc2
0
 
krajiCommented:
Thanks for the solution.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now