[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] placing graphics side by side with xsl-fo


Subject: [xsl] placing graphics side by side with xsl-fo
From: "Flanders, Charles E (US SSA)" <charles.flanders@xxxxxxxxxxxxxx>
Date: Mon, 23 Nov 2009 17:07:57 -0500

I have no real experience with XSL-FO. I've been working on XML to XML
transforms. However, I've been asked to modify an XSL-FO stylesheet to display
subfigures side by side. Right now they are rendering one over the other.

Essentially, I need each <subfig> to render side by side, not over/under.

Here is the basic XML.

<figure>
<title>TITLE</title>
<subfig><graphic boardno="it1235"/></subfig>
<subfig><graphic boardno="it1234"/></subfig>
</figure>

The current templates:




<!--Figure Element -->

	<xsl:template match="figure">
			<xsl:if test="@figtype='normal-page'">
			<fo:block-container font-family="serif" font-size="10pt"
keep-together.within-page="always" space-after.minimum="0pt"
space-after.optimum="0pt" space-before.minimum="9pt"
space-before.optimum="10pt" text-align="center" display-align="center">
			<xsl:if test="descendant::graphic">
					<xsl:attribute name="text-align">
					<xsl:choose>
						<xsl:when test="descendant::graphic/@hplace='right'">right</xsl:when>
						<xsl:when test="descendant::graphic/@hplace='left'">left</xsl:when>
						<xsl:when test="descendant::graphic/@hplace='center'">center</xsl:when>
						<xsl:otherwise>center</xsl:otherwise></xsl:choose></xsl:attribute>
					<xsl:attribute name="display-align">
					<xsl:choose>
						<xsl:when test="descendant::graphic/@vplace = 'top'">before</xsl:when>
						<xsl:when test="descendant::graphic/@vplace =
'middle'">center</xsl:when>
						<xsl:when test="descendant::graphic/@vplace =
'bottom'">after</xsl:when>
						<xsl:otherwise>center</xsl:otherwise></xsl:choose></xsl:attribute>
				</xsl:if>
				<xsl:apply-templates select="subfig | graphic | table | legend |
verbatim"></xsl:apply-templates>
				<xsl:if test="graphic | verbatim">
					<fo:block display-align="center" font-family="serif" font-size="10pt"
keep-together.within-page="always" space-before.conditionality="discard"
space-before.maximum="12pt" space-before.minimum="8pt"
space-before.optimum="10pt" span="all" text-align="center"
white-space="normal">
<xsl:apply-templates select="title
					</fo:block>
				</xsl:if>

			</fo:block-container>
		</xsl:if>

	</xsl:template>

	<!--Subfig Element-->
	<xsl:template match="subfig">
		<fo:block-container font-family="serif" font-size="10pt"
keep-together.within-page="always" margin-top="20pc" space-after.minimum="0pt"
space-after.optimum="0pt" space-before.minimum="9pt"
space-before.optimum="10pt" text-align="center">
			<xsl:if test="descendant::graphic">
				<xsl:attribute name="text-align">
				<xsl:choose>
					<xsl:when test="descendant::graphic/@hplace='right'">right</xsl:when>
					<xsl:when test="descendant::graphic/@hplace='left'">left</xsl:when>
					<xsl:when test="descendant::graphic/@hplace='center'">center</xsl:when>
					<xsl:otherwise>center</xsl:otherwise></xsl:choose></xsl:attribute>
				<xsl:attribute name="display-align">
				<xsl:choose>
					<xsl:when test="descendant::graphic/@vplace = 'top'">before</xsl:when>
					<xsl:when test="descendant::graphic/@vplace =
'middle'">center</xsl:when>
					<xsl:when test="descendant::graphic/@vplace = 'bottom'">after</xsl:when>
					<xsl:otherwise>center</xsl:otherwise></xsl:choose></xsl:attribute>
			</xsl:if>
			<xsl:apply-templates select="legend | graphic |
table"></xsl:apply-templates>
			<fo:block font-family="serif" keep-together.within-page="always"
space-before.conditionality="discard" space-before.maximum="12pt"
space-before.minimum="8pt" space-before.optimum="10pt" span="all"
text-align="center" display-align="center">
				<xsl:text>&#x2002;&#x2002;</xsl:text>
<xsl:apply-templates select="preceding-sibling::title/>
<xsl:apply-templates select="subtitle"/>
			</fo:block>
		</fo:block-container>
	</xsl:template>
		<xsl:template match="graphic">
		<fo:block space-before.maximum="10pt" space-before.minimum="8pt"
space-before.optimum="8pt" span="all" display-align="center">
		<fo:external-graphic content-height="" content-width="">
        <xsl:attribute name="src">
          <xsl:value-of select="unparsed-entity-uri(@boardno)"/>
        </xsl:attribute>
				</fo:external-graphic>
		</fo:block>
	</xsl:template>




Charles Flanders


Current Thread
Keywords
xml