On Jul 31, 2008, at 18:14, Ashish Kulkarni wrote:
Hi
Strictly speaking this is a purely XSLT-related question, so it does
not really belong here. Please keep that in mind for the future. This
is a list for questions about using FOP. Thanks!
Now to answer your question:
I have an XML file where the data is as below
<data>
<line1>My Name 1 of 1</line1>
<line2>My Address 01/12/2008</
line2>
<!--more lines of data here -->
</data>
I need to have boxes on PDF file like below, where i will hard code
Name, page
___________________________________________________________________
Name: My Name Page: 1of 1
Address: My Address Date: 01/12/2008
___________________________________________________________________
Is it possible to do some thing like this using XSLT and XSL-Fo
Sure, but the input XML is far from an ideal format. You have to go
looking for a criterion that can be used to split the text-nodes,
and /that/ part may turn out to get messy, if I interpret
correctly... How would you determine where the name in line1 ends? Or
the address in line2?
Other than that, it's not very difficult. If you would have:
<data>
<line1>My Name#1 of 1</line1>
<line2>My Address#01/12/2008</line2>
</data>
then you could XPath's substring-before() and substring-after() to
get to the right parts.
It would then be a very straightforward matching template for the
data-elements.
<xsl:template match="data">
<block-container border="solid 1pt black">
<table table-layout="fixed" inline-progression-dimension="100%">
<table-column column-width="proportional-column-width(1)"
number-columns-repeated="2" />
<table-body>
<table-cell starts-row="true" text-align="start">
<block>
<wrapper font-weight="bold">Name:</wrapper>
<xsl:text> </xsl:text>
<xsl:value-of select="substring-before(line1, '#')" />
</block>
</table-cell>
<table-cell ends-row="true" text-align="end">
<block>
<wrapper font-weight="bold">Page:</wrapper>
<xsl:text> </xsl:text>
<xsl:value-of select="substring-after(line1, '#')" />
</block>
</table-cell>
<table-cell starts-row="true" text-align="start">
<block>
<wrapper font-weight="bold">Address:</wrapper>
<xsl:text> </xsl:text>
<xsl:value-of select="substring-before(line2, '#')" />
</block>
</table-cell>
<table-cell ends-row="true" text-align="end">
<block>
<wrapper font-weight="bold">Date:</wrapper>
<xsl:text> </xsl:text>
<xsl:value-of select="substring-after(line2, '#')" />
</block>
</table-cell>
</table-body>
</table>
</block-container>
</xsl:template>
HTH!
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]