Link to home
Start Free TrialLog in
Avatar of ank5
ank5Flag for India

asked on

Eliminate additional border

I am writing an XML FO that would transform XML to PDF. It works fine expect for a problem where there are duplicate borders.

XML
<?xml version="1.0" encoding="utf-8"?>
<root>
	<ora1>
		<row ID="">
			<time_stamp>03-Nov-2016</time_stamp>
			<user_name>approver1</user_name>
			<reason>L Approval</reason>
		</row>
		<row ID="">
			<time_stamp>03-Nov-2016</time_stamp>
			<user_name>approver2</user_name>
			<reason>LC Approval</reason>
		</row>
	</ora1>
	<ora2>
		<row>
			<title>test 5</title>
			<artifact_name>Development</artifact_name>
			<authors>
				<authors-value index="0">author1</authors-value>
				<authors-value index="1">author2</authors-value>
				<authors-value index="2">author3</authors-value>
			</authors>
			 
	
		</row>
	</ora2>
</root>

Open in new window


XSL
<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xml.apache.org/fop/extensions">
	
	
	<xsl:template match="/">
		<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
			<fo:layout-master-set>
				<fo:simple-page-master master-name="first" page-height="29.7cm" page-width="21cm" margin-top="2cm" margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">
					<fo:region-body margin-top="1cm" margin-bottom="1.5cm"/>
				</fo:simple-page-master>
			</fo:layout-master-set>
			<fo:page-sequence master-reference="first">
				<fo:flow flow-name="xsl-region-body">
					<fo:block font-size="22pt" font-family="sans-serif" space-after.optimum="15pt" text-align="center" break-before="page" font-weight="bold">
						Form
					</fo:block>
					
					<fo:table text-align="left" space-before="15mm" table-layout="fixed" border-collapse="collapse">
						<fo:table-column column-width="proportional-column-width(0.75)"/>
						<fo:table-column column-width="proportional-column-width(2)"/>
						
						<fo:table-body>
							<fo:table-row>
								
								<fo:table-cell border-width="0.2mm" border-style="solid" text-align="left" font-weight="bold" background-color="#bbb">
									<fo:block padding="2mm" text-indent="2mm">
										Title
									</fo:block>
								</fo:table-cell>
								
								<fo:table-cell border-width="0.2mm" border-style="solid" text-align="left">
									<fo:block padding="2mm" text-indent="2mm">
										<xsl:value-of select="root/ora2/row/title"/>
									</fo:block>
								</fo:table-cell>	
							</fo:table-row>	
							
							<fo:table-row>
								<fo:table-cell border-width="0.2mm" border-style="solid" text-align="left" font-weight="bold" background-color="#bbb">
									<fo:block padding="2mm" text-indent="2mm">
										Info
									</fo:block>
								</fo:table-cell>
								
								<fo:table-cell border-width="0.2mm" border-style="solid" text-align="left">
									<fo:block padding="2mm" text-indent="2mm">
										<xsl:value-of select="root/ora2/row/artifact_name"/>
									</fo:block>
								</fo:table-cell>	
							</fo:table-row>	
							
							<fo:table-row>
								<fo:table-cell border-width="0.2mm" border-style="solid" text-align="left" font-weight="bold" background-color="#bbb">
									<fo:block padding="2mm" text-indent="2mm">
										Author
									</fo:block>
								</fo:table-cell>
								
								<fo:table-cell border-width="0.2mm" border-style="solid" text-align="left">
									<fo:block padding="2mm" text-indent="2mm">
									
										<fo:table>
											<fo:table-body>
												<xsl:apply-templates select="root/ora2/row/authors"></xsl:apply-templates>			
											</fo:table-body>
										</fo:table>						
									</fo:block>
								</fo:table-cell>	
							</fo:table-row>	
							
							
						</fo:table-body>
					</fo:table>
					<fo:table text-align="left" space-before="15mm" table-layout="fixed" border-collapse="collapse">
						
						<fo:table-column column-width="proportional-column-width(0.75)"/>
						<fo:table-column column-width="proportional-column-width(2)"/>
						<fo:table-body>
							<fo:table-row>
								<fo:table-cell border-width="0.2mm" border-style="solid" text-align="center" font-weight="bold" background-color="#bbb">
									<fo:block padding="2mm">Date</fo:block>
								</fo:table-cell>
								
								<fo:table-cell border-width="0.2mm" border-style="solid" text-align="center" font-weight="bold" background-color="#bbb">
									<fo:block padding="2mm">User</fo:block>
								</fo:table-cell>
							</fo:table-row>
							<xsl:for-each select="root/ora1/row">
								<fo:table-row>
									<fo:table-cell border-width="0.2mm" border-style="solid" text-align="center">
										<fo:block padding="2mm">
											<xsl:value-of select="time_stamp"/>
										</fo:block>
									</fo:table-cell>
									
									<fo:table-cell border-width="0.2mm" border-style="solid" text-align="left">
										<fo:block padding="2mm" text-indent="2mm">
											<xsl:value-of select="user_name"/>
										</fo:block>
									</fo:table-cell>
								</fo:table-row>
								<fo:table-row>
									
									<fo:table-cell border-width="0.2mm" border-style="solid" text-align="center" font-weight="bold" background-color="#bbb">
										<fo:block padding="2mm"><xsl:value-of select="Reason"/></fo:block>
									</fo:table-cell>
									
									<fo:table-cell border-width="0.2mm" border-style="solid" text-align="left">
										<fo:block padding="2mm" text-indent="2mm">
											<xsl:value-of select="reason"/>
										</fo:block>
									</fo:table-cell>
									
								</fo:table-row>
								<fo:table-row>
									<fo:table-cell border-width="0.2mm" border-style="solid"><fo:block padding="2mm"></fo:block></fo:table-cell>
									<fo:table-cell border-width="0.2mm" border-style="solid"><fo:block padding="2mm"></fo:block></fo:table-cell>
								</fo:table-row>
							</xsl:for-each>
						</fo:table-body>
					</fo:table>
				</fo:flow>
			</fo:page-sequence>
		</fo:root>
	</xsl:template>
	
	<xsl:template match="authors">
		<xsl:apply-templates select="authors-value[position() mod 2 = 1]"/>
	</xsl:template>
	
	<xsl:template match="authors-value">
		<fo:table-row>
			<fo:table-cell border-width="0.2mm" border-style="solid" text-align="left">
				<fo:block padding="2mm" text-indent="2mm">
					<xsl:value-of select="." />
				</fo:block>
			</fo:table-cell>
			<fo:table-cell border-width="0.2mm" border-style="solid" text-align="left">
				<fo:block padding="2mm" text-indent="2mm">
					<xsl:value-of select="following-sibling::authors-value[1]" />
				</fo:block>
			</fo:table-cell>            
		</fo:table-row>
	</xsl:template>
	
</xsl:stylesheet>

Open in new window


In the output there are duplicate borders in the Authors section (top and bottom of authors section). I think it is because there is one border for the table and another for each row. However, I don't know how to avoid it. What I want is that top border of first row and table border should not be two separate lines. Same for bottom border of the last row.

User generated image
Is there a way to achieve this?
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial