I am trying to implement FOP to output a PDF using XML and XSLT files.
My problem is the following I need to fix the position of words in a line (but not through using tables) for example:
I have the following xml:
<address>
<Line1 length="32" noLine="5" col="60" />
<Line2 length="32" noLine="6" col="60">Mr. John Kane</Line2 >
<Line3 length="32" noLine="7" col="60">15 Street Springfield</Line3 >
<Line4 length="32" noLine="8" col="60" />
<Line5 length="32" noLine="9" col="60" />
<Line6 length="6" noLine="10" col="60">75009</Line6 >
<Line7 length="25" noLine="10" col="67">Freesberg</Line7 >
<Line8 length="25" noLine="11" col="67">Idaho</Line8 >
</address>
- Where the
length
is the word/sentence length noLine
is the line numbercol
is the beginning position of the word/sentence in the line
I did the lines but I can't seem to get to insert the word/sentence in the right position (col) in the line.
This is a part from my xslt:
<fo:block font-size="10" font-family="monospace">
<xsl:for-each select="*">
<xsl:variable name="currentNode" select ="name(.)"/>
<xsl:choose>
<xsl:when test="$currentNode = 'address'">
<xsl:for-each select="*">
<xsl:variable name="length" select ="@length"/>
<xsl:variable name="noLine" select ="@noLine"/>
<xsl:variable name="col" select ="@col"/>
<xsl:variable name="precNoLig" select = "preceding-sibling::*[1]/@noLine"/>
<xsl:choose>
<xsl:when test="$precNoLig = $noLine">
<fo:block font-size="10" font-family="monospace" text-indent="60">
 <xsl:value-of select="." />
</fo:block>
</xsl:when>
<xsl:otherwise>
<!--<fo:block font-size="10" font-family="monospace" >-->

<xsl:value-of select="." />
<!--</fo:block>-->
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</fo:block>
This is the expected output as PDF
:
Mr. John Kane
15 Street Springfield
75009 Freesberg
Idaho
Where it has the following positions in the PDF
(col):
<-----------------60-------------------->
<-----------------60-------------------->Mr. John Kane
<-----------------60-------------------->15 Street Springfield
<-----------------60-------------------->
<-----------------60-------------------->
<-----------------60-------------------->75009 Freesberg
<-----------------67-------------------------->Idaho
Any help would be appreciated.