XML:
<levelledPara><title>Tools List and Tool Illustrations</title>
<levelledPara><title>General</title>
<levelledPara><para>The special tools, fixtures, and equipment needed.</para></levelledPara></levelledPara>
XSLT:
<xsl:template match="levelledPara" name="levelledPara" mode="tocdm">
<xsl:if test="*[self::title] and not(parent::*[self::levelledPara])">
<xsl:variable name="id">
<xsl:call-template name="para.id"/>
</xsl:variable>
<fo:table-row>
<fo:table-cell xsl:use-attribute-sets="table.cell.padding1" number-columns-spanned="2">
<fo:block text-transform="capitalize" text-align-last="justify" text-indent="21mm">
<xsl:number count="levelledPara" from="content" level="multiple" format="1.1.1.1.1"/>
<xsl:text> </xsl:text>
<xsl:value-of select="title" /><fo:leader leader-pattern="dots"/><fo:basic-link internal-destination="{$id}"><fo:page-number-citation ref-id="{$id}"/></fo:basic-link>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:if>
</xsl:template>
<xsl:template match="levelledPara">
<fo:list-block
provisional-distance-between-starts="21mm"
provisional-label-separation="4pt">
<fo:list-item space-after="8pt" space-before="13pt" start-indent="0pt">
<xsl:variable name="id">
<xsl:if test="*[self::title] and not(parent::*[self::levelledPara])">
<xsl:call-template name="para.id"/>
</xsl:if>
</xsl:variable>
<fo:list-item-label
end-indent="label-end()"
text-align="start">
<fo:block font-weight="bold" id="{$id}">
<xsl:if test="not(./table)">
<xsl:number count="levelledPara" from="content" level="multiple" format="1.1.1.1.1"/>
</xsl:if>
</fo:block>
</fo:list-item-label>
<fo:list-item-body
start-indent="body-start()">
<xsl:apply-templates/>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</xsl:template>
<xsl:template name="para.id">
<xsl:param name="object" select="."/>
<xsl:apply-templates select="ancestor::dmodule/identAndStatusSection/dmAddress/dmIdent/dmCode"/>
<xsl:choose>
<xsl:when test="$object/#id">
<xsl:value-of select="$object/#id"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat(count(ancestor::node()),'00000000',count(preceding::node()))"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
The first titled levelledPara should be included in the Table of Contents. In my sample markup none have IDs. The page number wasn't resolving because I forgot to assign an id to the fo:block for levelledPara.
You've shown the XSLT for the table of contents. The ID in the TOC should match an ID in the main text of your document.
So the template match="levelledPara" should contain a block that sets the ID:
<xsl:variable name="lpcode"><xsl:value-of select="$dmcode" /><xsl:value-of select="generate-id(.)" /></xsl:variable>
<fo:block id="{$lpcode}">
Related
I'm new to the XSLT FO world and came across an issue. I have my XSLT that works well with the fop-0.95 processor and generates the PDF, but after I upgraded to fop-2.3, it left my first page blank and started the PDF body from the second page (my PDF has a header that appears fine on the first page).
I figured out where the issue was, and it was because I had the margin-top value set to 3 inches in the "fo:region-body" tag within the "fo:layout-master-set" (please see screenshot). I had to change the margin-top from 3 inches to 2.5 inches for the body of my PDF to appear like it was while using fop-0.95.
<?xml version="1.0" encoding="UTF-8"?>
<!--Designed and generated by Altova StyleVision Enterprise Edition 2013 (x64) - see http://www.altova.com/stylevision for more information.-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:altova="http://www.altova.com" xmlns:altovaext="http://www.altova.com/xslt-extensions" xmlns:clitype="clitype" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:iso4217="http://www.xbrl.org/2003/iso4217" xmlns:ix="http://www.xbrl.org/2008/inlineXBRL" xmlns:java="java" xmlns:link="http://www.xbrl.org/2003/linkbase" xmlns:sps="http://www.altova.com/StyleVision/user-xpath-functions" xmlns:xbrldi="http://xbrl.org/2006/xbrldi" xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg" exclude-result-prefixes="altova altovaext clitype fn iso4217 ix java link sps xbrldi xbrli xlink xs xsi">
<xsl:output version="1.0" method="xml" encoding="UTF-8" indent="no"/>
<xsl:param name="SV_OutputFormat" select="'PDF'"/>
<xsl:variable name="XML" select="/"/>
<xsl:variable name="fo:layout-master-set">
<fo:layout-master-set>
<fo:simple-page-master master-name="page-master-0-even" margin-left="0.50in" margin-right="0.50in" page-height="11in" page-width="8.50in" margin-top="0.30in" margin-bottom="0.30in">
<fo:region-body margin-top="0.45in" margin-bottom="0.45in" column-count="1" column-gap="0.50in"/>
<fo:region-before region-name="even-page-header" overflow="hidden" extent="0.45in"/>
<fo:region-after region-name="even-page-footer" overflow="hidden" extent="0.45in"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="page-master-0-odd" margin-left="0.50in" margin-right="0.50in" page-height="11in" page-width="8.50in" margin-top="0.30in" margin-bottom="0.30in">
<fo:region-body margin-top="0.45in" margin-bottom="0.45in" column-count="1" column-gap="0.50in"/>
<fo:region-before region-name="odd-page-header" overflow="hidden" extent="0.45in"/>
<fo:region-after region-name="odd-page-footer" overflow="hidden" extent="0.45in"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="page-master-0-even-first" margin-left="0.50in" margin-right="0.50in" page-height="11in" page-width="8.50in" margin-top="0.30in" margin-bottom="0.30in">
<fo:region-body margin-top="3in" margin-bottom="0.45in" column-count="1" column-gap="0.50in"/>
<fo:region-before region-name="even-page-header-first" overflow="hidden" extent="3in"/>
<fo:region-after region-name="even-page-footer" overflow="hidden" extent="0.45in"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="page-master-0-odd-first" margin-left="0.50in" margin-right="0.50in" page-height="11in" page-width="8.50in" margin-top="0.30in" margin-bottom="0.30in">
<fo:region-body margin-top="3in" margin-bottom="0.45in" column-count="1" column-gap="0.50in"/>
<fo:region-before region-name="odd-page-header-first" overflow="hidden" extent="3in"/>
<fo:region-after region-name="odd-page-footer" overflow="hidden" extent="0.45in"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="page-master-0">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="page-master-0-even-first" odd-or-even="even" page-position="first"/>
<fo:conditional-page-master-reference master-reference="page-master-0-odd-first" odd-or-even="odd" page-position="first"/>
<fo:conditional-page-master-reference master-reference="page-master-0-even" odd-or-even="even"/>
<fo:conditional-page-master-reference master-reference="page-master-0-odd" odd-or-even="odd"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
</xsl:variable>
<xsl:variable name="altova:nPxPerIn" select="96"/>
<xsl:template match="/">
<fo:root>
<xsl:copy-of select="$fo:layout-master-set"/>
<fo:declarations>
<x:xmpmeta xmlns:x="adobe:ns:meta/">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/">
<xmp:CreatorTool>Altova StyleVision Enterprise Edition 2013 (x64) (http://www.altova.com)</xmp:CreatorTool>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
</fo:declarations>
<fo:page-sequence force-page-count="no-force" master-reference="page-master-0" initial-page-number="auto" format="1">
<fo:static-content flow-name="odd-page-header-first">
<fo:block-container overflow="hidden" display-align="before">
<fo:block>
<xsl:for-each select="$XML">
<xsl:for-each select="DOCUMENT">
<xsl:for-each select="DATA">
<xsl:for-each select="STRUCT">
<xsl:for-each select="FIELD[FNAME='nfHeaderDtls']">
<xsl:for-each select="STRUCT">
<fo:block-container font-family="Arial" font-size="10pt" width="7.490000in" height="3.000000in" overflow="hidden">
<fo:block-container absolute-position="absolute" font-family="Arial" font-size="9pt" height="1.21in" left="4.55in" top="1.75in" width="2.90in" overflow="hidden">
<fo:block>
<xsl:for-each select="FIELD[FNAME='Name']">
<xsl:for-each select="VALUE">
<xsl:variable name="value-of-template_1">
<xsl:apply-templates/>
</xsl:variable>
<xsl:choose>
<xsl:when test="contains(string($value-of-template_1),'')">
<fo:block>
<xsl:copy-of select="$value-of-template_1"/>
</fo:block>
</xsl:when>
<xsl:otherwise>
<fo:inline>
<xsl:copy-of select="$value-of-template_1"/>
</fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:for-each>
<fo:block/>
</fo:block>
</fo:block-container>
</fo:block-container>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</fo:block>
</fo:block-container>
</fo:static-content>
<fo:static-content flow-name="even-page-header-first">
<fo:block-container overflow="hidden" display-align="before">
<fo:block>
<xsl:for-each select="$XML">
<xsl:for-each select="DOCUMENT">
<xsl:for-each select="DATA">
<xsl:for-each select="STRUCT">
<xsl:for-each select="FIELD[FNAME='nfHeaderDtls']">
<xsl:for-each select="STRUCT">
<fo:block-container font-family="Arial" font-size="10pt" width="7.490000in" height="3.000000in" overflow="hidden">
<fo:block-container absolute-position="absolute" font-family="Arial" font-size="9pt" height="1.21in" left="4.55in" top="1.75in" width="2.90in" overflow="hidden">
<fo:block>
<xsl:for-each select="FIELD[FNAME='Name']">
<xsl:for-each select="VALUE">
<xsl:variable name="value-of-template_1">
<xsl:apply-templates/>
</xsl:variable>
<xsl:choose>
<xsl:when test="contains(string($value-of-template_1),'')">
<fo:block>
<xsl:copy-of select="$value-of-template_1"/>
</fo:block>
</xsl:when>
<xsl:otherwise>
<fo:inline>
<xsl:copy-of select="$value-of-template_1"/>
</fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:for-each>
<fo:block/>
</fo:block>
</fo:block-container>
</fo:block-container>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</fo:block>
</fo:block-container>
</fo:static-content>
<fo:static-content flow-name="odd-page-header">
<fo:block-container overflow="hidden" display-align="before">
<fo:block>
<xsl:for-each select="$XML">
<xsl:for-each select="DOCUMENT">
<xsl:for-each select="DATA">
<xsl:for-each select="STRUCT">
<xsl:for-each select="FIELD[FNAME='nfHeaderDtls']">
<xsl:for-each select="STRUCT">
<fo:block-container font-family="Arial" font-size="10pt" width="7.500000in" height="0.500000in" overflow="hidden">
<fo:block-container absolute-position="absolute" height="0.19in" left="0in" top="0in" width="2.78in" overflow="hidden">
<fo:block>
<fo:inline>
<xsl:text>Identifier: </xsl:text>
</fo:inline>
<xsl:for-each select="FIELD[FNAME='caseReference']">
<xsl:for-each select="VALUE">
<xsl:variable name="value-of-template_27">
<xsl:apply-templates/>
</xsl:variable>
<xsl:choose>
<xsl:when test="contains(string($value-of-template_27),'')">
<fo:block>
<xsl:copy-of select="$value-of-template_27"/>
</fo:block>
</xsl:when>
<xsl:otherwise>
<fo:inline>
<xsl:copy-of select="$value-of-template_27"/>
</fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:for-each>
</fo:block>
</fo:block-container>
</fo:block-container>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</fo:block>
</fo:block-container>
</fo:static-content>
<fo:static-content flow-name="even-page-header">
<fo:block-container overflow="hidden" display-align="before">
<fo:block>
<xsl:for-each select="$XML">
<xsl:for-each select="DOCUMENT">
<xsl:for-each select="DATA">
<xsl:for-each select="STRUCT">
<xsl:for-each select="FIELD[FNAME='nfHeaderDtls']">
<xsl:for-each select="STRUCT">
<fo:block-container font-family="Arial" font-size="10pt" width="7.500000in" height="0.500000in" overflow="hidden">
<fo:block-container absolute-position="absolute" height="0.19in" left="0in" top="0in" width="2.78in" overflow="hidden">
<fo:block>
<fo:inline>
<xsl:text>Identifier: </xsl:text>
</fo:inline>
<xsl:for-each select="FIELD[FNAME='caseReference']">
<xsl:for-each select="VALUE">
<xsl:variable name="value-of-template_27">
<xsl:apply-templates/>
</xsl:variable>
<xsl:choose>
<xsl:when test="contains(string($value-of-template_27),'')">
<fo:block>
<xsl:copy-of select="$value-of-template_27"/>
</fo:block>
</xsl:when>
<xsl:otherwise>
<fo:inline>
<xsl:copy-of select="$value-of-template_27"/>
</fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:for-each>
</fo:block>
</fo:block-container>
</fo:block-container>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</fo:block>
</fo:block-container>
</fo:static-content>
<fo:static-content flow-name="odd-page-footer">
<fo:block-container height="0.45in" overflow="hidden" display-align="after">
<fo:block>
<fo:block-container font-family="Arial" font-size="10pt" width="7.490000in" height="0.500000in" overflow="hidden">
<fo:block-container absolute-position="absolute" height="0.40in" left="0in" top="0in" width="4.04in" overflow="hidden">
<fo:block>
<fo:inline>
<xsl:text>My Test Form</xsl:text>
</fo:inline>
<fo:block/>
<fo:inline>
<xsl:text>Test Text</xsl:text>
</fo:inline>
</fo:block>
</fo:block-container>
<fo:block-container absolute-position="absolute" height="0.38in" left="4.82in" text-align="right" top="0in" width="2.63in" overflow="hidden">
<fo:block>
<fo:inline font-weight="bold">
<xsl:text>Page: </xsl:text>
</fo:inline>
<fo:page-number font-weight="bold"/>
<fo:inline font-weight="bold">
<xsl:text> of </xsl:text>
</fo:inline>
<fo:page-number-citation ref-id="SV_RefID_PageTotal" font-weight="bold"/>
</fo:block>
</fo:block-container>
</fo:block-container>
</fo:block>
</fo:block-container>
</fo:static-content>
<fo:static-content flow-name="even-page-footer">
<fo:block-container height="0.45in" overflow="hidden" display-align="after">
<fo:block>
<fo:block-container font-family="Arial" font-size="10pt" width="7.490000in" height="0.500000in" overflow="hidden">
<fo:block-container absolute-position="absolute" height="0.40in" left="0in" top="0in" width="4.04in" overflow="hidden">
<fo:block>
<fo:inline>
<xsl:text>My Test Form</xsl:text>
</fo:inline>
<fo:block/>
<fo:inline>
<xsl:text>Test Text</xsl:text>
</fo:inline>
</fo:block>
</fo:block-container>
<fo:block-container absolute-position="absolute" height="0.38in" left="4.82in" text-align="right" top="0in" width="2.63in" overflow="hidden">
<fo:block>
<fo:inline font-weight="bold">
<xsl:text>Page: </xsl:text>
</fo:inline>
<fo:page-number font-weight="bold"/>
<fo:inline font-weight="bold">
<xsl:text> of </xsl:text>
</fo:inline>
<fo:page-number-citation ref-id="SV_RefID_PageTotal" font-weight="bold"/>
</fo:block>
</fo:block-container>
</fo:block-container>
</fo:block>
</fo:block-container>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block>
<xsl:for-each select="$XML">
<xsl:for-each select="DOCUMENT">
<xsl:for-each select="DATA">
<xsl:for-each select="STRUCT">
<fo:block-container font-family="Arial" font-size="10pt" width="7.500000in" height="7.040000in" overflow="hidden">
<fo:block-container absolute-position="absolute" font-family="Arial" font-size="13pt" font-weight="bold" height="0.28in" left="0in" text-align="center" top="0in" width="7.46in" overflow="hidden">
<fo:block>
<fo:inline>
<xsl:text>Form Body Starts Here </xsl:text>
</fo:inline>
<xsl:for-each select="FIELD[FNAME='nfFormTitle']">
<xsl:for-each select="VALUE">
<xsl:variable name="value-of-template_28">
<xsl:apply-templates/>
</xsl:variable>
<xsl:choose>
<xsl:when test="contains(string($value-of-template_28),'')">
<fo:block>
<xsl:copy-of select="$value-of-template_28"/>
</fo:block>
</xsl:when>
<xsl:otherwise>
<fo:inline>
<xsl:copy-of select="$value-of-template_28"/>
</fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:for-each>
<fo:inline>
<xsl:text> Test Test</xsl:text>
</fo:inline>
</fo:block>
</fo:block-container>
</fo:block-container>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</fo:block>
<fo:block id="SV_RefID_PageTotal"/>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template name="altova:double-backslash">
<xsl:param name="text"/>
<xsl:param name="text-length"/>
<xsl:variable name="text-after-bs" select="substring-after($text, '\')"/>
<xsl:variable name="text-after-bs-length" select="string-length($text-after-bs)"/>
<xsl:choose>
<xsl:when test="$text-after-bs-length = 0">
<xsl:choose>
<xsl:when test="substring($text, $text-length) = '\'">
<xsl:value-of select="concat(substring($text,1,$text-length - 1), '\\')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat(substring($text,1,$text-length - $text-after-bs-length - 1), '\\')"/>
<xsl:call-template name="altova:double-backslash">
<xsl:with-param name="text" select="$text-after-bs"/>
<xsl:with-param name="text-length" select="$text-after-bs-length"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="altova:MakeValueAbsoluteIfPixels">
<xsl:param name="sValue"/>
<xsl:variable name="sBeforePx" select="substring-before($sValue, 'px')"/>
<xsl:choose>
<xsl:when test="$sBeforePx">
<xsl:variable name="nLengthOfInteger">
<xsl:call-template name="altova:GetCharCountOfIntegerAtEndOfString">
<xsl:with-param name="sText" select="$sBeforePx"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="nPosOfInteger" select="string-length($sBeforePx) - $nLengthOfInteger + 1"/>
<xsl:variable name="nValuePx" select="substring($sBeforePx, $nPosOfInteger)"/>
<xsl:variable name="nValueIn" select="number($nValuePx) div number($altova:nPxPerIn)"/>
<xsl:variable name="nLengthBeforeInteger" select="string-length($sBeforePx) - $nLengthOfInteger"/>
<xsl:variable name="sRest">
<xsl:call-template name="altova:MakeValueAbsoluteIfPixels">
<xsl:with-param name="sValue" select="substring-after($sValue, 'px')"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="concat(substring($sBeforePx, 1, $nLengthBeforeInteger), string($nValueIn), 'in', $sRest)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$sValue"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="altova:GetCharCountOfIntegerAtEndOfString">
<xsl:param name="sText"/>
<xsl:variable name="sLen" select="string-length($sText)"/>
<xsl:variable name="cLast" select="substring($sText, $sLen)"/>
<xsl:choose>
<xsl:when test="number($cLast) >= 0 and number($cLast) <= 9">
<xsl:variable name="nResultOfRest">
<xsl:call-template name="altova:GetCharCountOfIntegerAtEndOfString">
<xsl:with-param name="sText" select="substring($sText, 1, $sLen - 1)"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$nResultOfRest + 1"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>0</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Does anyone know why this is happening?
I have multiple PDFs with the same layout, so if I need to upgrade to fop-2.3 do I have to make this change to all of my PDFs?
EDIT- 1. Thank you for the comments and the answer. Sorry it took a while to reply back, as I was working on getting approvals to post this xslt.
2. I edited the xslt as it was too big to adhere to the word limit of this post. But it still has all the important parts like beginning of the PDF body etc.
Sorry, but the best way to work out why something is different between different versions of the same software is to look through the release notes for the releases since your older version.
FOP has release notes on its website. When I was confirming that, I found this at https://xmlgraphics.apache.org/fop/1.0/changes_1.0.html, which might be what you are looking for:
Allowing non-zero borders and padding on page regions when relaxed validation is turned on. Committed by LF.
If that is the cause, then the solution would be to remove the margin-top from the fo:simple-page-master. Otherwise, there's plenty more release notes for you to look through, I'm afraid.
I have an xml document as shown below. Each repeating doc is a page in PDF file
<AFPXMLFile>
<docs>
<regList>
<region>1</region>
<secList>
<col>1</col>
<lines></lines>
</secList>
</regList>
<regList>
<region>2</region>
<secList>
<col>2</col>
<lines>
<line>IBM BELGIUM xxx</line>
<line>xxxxxx</line>
<line>xxxx</line>
</lines>
</secList>
</regList>
<regList></regList>
<regList></regList>
</docs>
<docs></docs>
</AFPXMLFile>
My XSL is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"
exclude-result-prefixes="fo">
<xsl:template match="AFPXMLFile">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master page-width="21cm" page-height="29.7cm" margin-top="1.27cm" margin-bottom="1.27cm" margin-left="1.75cm" master-name="A4">
<fo:region-body margin-top="1mm" margin-bottom="1mm"/>
<fo:region-before extent="0mm"/>
<fo:region-after extent="0mm"/>
<fo:region-start writing-mode="tb-rl" precedence="true" extent="10mm" />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="A4" font-family="sans-serif">
<xsl:for-each select="docs">
<xsl:for-each select="./regList">
<xsl:choose>
<xsl:when test="region = 1">
<fo:static-content flow-name="xsl-region-before">
<xsl:for-each select="./secList/lines">
<xsl:for-each select="node()">
<fo:block font-size="8pt" color="purple">
<xsl:value-of select="."/>
</fo:block>
</xsl:for-each>
</xsl:for-each>
</fo:static-content>
</xsl:when>
<xsl:when test="region = 2">
<fo:static-content flow-name="xsl-region-start">
<xsl:for-each select="./secList/lines">
<xsl:for-each select="node()">
<fo:block font-size="4pt" padding-before="4pt" text-align="left" color="green">
<xsl:value-of select="."/>
</fo:block>
</xsl:for-each>
</xsl:for-each>
</fo:static-content>
</xsl:when>
<xsl:when test="region = 3">
<fo:static-content flow-name="xsl-region-body">
<xsl:for-each select="./secList/lines">
<xsl:for-each select="node()">
<fo:block font-size="8pt" color="blue">
<xsl:value-of select="."/>
</fo:block>
</xsl:for-each>
</xsl:for-each>
</fo:static-content>
</xsl:when>
<xsl:when test="region = 4">
<fo:flow flow-name="xsl-region-after">
<xsl:for-each select="./secList">
<xsl:for-each select="./lines">
<xsl:for-each select="node()">
<fo:block font-size="8pt" color="orange">
<xsl:value-of select="."/>
</fo:block>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</fo:flow>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:for-each>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>
When I run the transformation I get the following error:
org.apache.fop.fo.ValidationException: For "fo:page-sequence", "fo:static-content" must be declared before "fo:flow"! (No context info available)
This I suspect because it is repeating the static content region for each page. So I believe I need to change the simple-page-master:master-name for every page
I need help with that.
According to the XSL-FO recommendation, the contents of 'fo:page-sequence' is:
(title?,folio-prefix?,folio-suffix?,static-content*,flow+)
which means that all the fo:static-content elements must be before the fo:flow elements.
Your stylesheet dynamically creates either fo:static-content (if region is 1, 2 or 3) or fo:flow (if region is 4). From the reduced input file in your question it is not possible to see whether the regList elements are alway correctly sorted, so that they produce a valid output when sequentially processed.
Moreover, as each docs element represents a different document with different headers/footers, you have to create distinct fo:page-sequences instead of a single one (otherwise you get too many static contents and flows for a single page sequence):
<xsl:for-each select="docs">
<fo:page-sequence master-reference="A4" font-family="sans-serif">
<xsl:for-each select="./regList">
....
</xsl:for-each>
</fo:page-sequence>
</xsl:for-each>
Moreover, there is a strange thing in the stylesheet: you map an fo:static-content to the xsl-region-body region, and the fo:flow to the xsl-region-after region, which is quite unusual. If the "real" content for the body region is the one with region = 3, you must process region 1, 2 and 4 first, and then region 3:
<xsl:for-each select="docs">
<fo:page-sequence master-reference="A4" font-family="sans-serif">
<!-- create static contents -->
<xsl:apply-templates select="./regList[region != '3']"/>
<!-- create flow -->
<xsl:apply-templates select="./regList[region = '3']"/>
</fo:page-sequence>
</xsl:for-each>
with an additional template to match reglist:
<xsl:template match="regList">
<xsl:choose>
<xsl:when test="region = '1'">
<fo:static-content flow-name="xsl-region-before">
<xsl:for-each select="./secList/lines">
<xsl:for-each select="node()">
<fo:block font-size="8pt" color="purple">
<xsl:value-of select="."/>
</fo:block>
</xsl:for-each>
</xsl:for-each>
</fo:static-content>
</xsl:when>
<xsl:when test="region = '2'">
<fo:static-content flow-name="xsl-region-start">
<xsl:for-each select="./secList/lines">
<xsl:for-each select="node()">
<fo:block font-size="4pt" padding-before="4pt" text-align="left" color="green">
<xsl:value-of select="."/>
</fo:block>
</xsl:for-each>
</xsl:for-each>
</fo:static-content>
</xsl:when>
<xsl:when test="region = '3'">
<fo:flow flow-name="xsl-region-body">
<xsl:for-each select="./secList/lines">
<xsl:for-each select="node()">
<fo:block font-size="8pt" color="blue">
<xsl:value-of select="."/>
</fo:block>
</xsl:for-each>
</xsl:for-each>
</fo:flow>
</xsl:when>
<xsl:when test="region = '4'">
<fo:static-content flow-name="xsl-region-after">
<xsl:for-each select="./secList">
<xsl:for-each select="./lines">
<xsl:for-each select="node()">
<fo:block font-size="8pt" color="orange">
<xsl:value-of select="."/>
</fo:block>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</fo:static-content>
</xsl:when>
</xsl:choose>
</xsl:template>
or several, smaller templates:
<xsl:template match="reglist[region = '1']">
<fo:static-content flow-name="xsl-region-before">
<xsl:for-each select="./secList/lines">
<xsl:for-each select="node()">
<fo:block font-size="8pt" color="purple">
<xsl:value-of select="."/>
</fo:block>
</xsl:for-each>
</xsl:for-each>
</fo:static-content>
</xsl:template>
<xsl:template match="reglist[region = '2']">
...
</xsl:template>
...
I would like to use node-set() in Antenna House so I can access preceding-siblings in a sorted list. (I'm trying to follow this example: [using preceding-sibling with with xsl:sort)
I'm not sure what the syntax is for declaring the namespace to access node-set(). AH is not giving any errors, but my call to node-set() fails. I've tried:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" extension-element-prefixes="msxsl" version="1.0">
Here is the XML:
<illustratedPartsCatalog>
<figure id="fig1">...</figure>
<catalogSeqNumber assyCode="00" figureNumber="01" indenture="0" item="000" itemVariant="A" subSubSystemCode="0" subSystemCode="0" systemCode="00">
<itemSeqNumber itemSeqNumberValue="000">
<quantityPerNextHigherAssy>XX</quantityPerNextHigherAssy>
<partRef manufacturerCodeValue="00000" partNumberValue="11111-111">
</partRef>
<partSegment>
<itemIdentData>
<descrForPart>VALVE ASSEMBLY</descrForPart></itemIdentData>
</partSegment><applicabilitySegment><usableOnCodeAssy>X</usableOnCodeAssy>
</applicabilitySegment></itemSeqNumber></catalogSeqNumber>
<catalogSeqNumber>...</catalogSeqNumber>
<catalogSeqNumber>...</catalogSeqNumber>
<catalogSeqNumber>...</catalogSeqNumber>
<catalogSeqNumber>...</catalogSeqNumber>
<figure id="fig2">...</figure>
<catalogSeqNumber>...</catalogSeqNumber>
<catalogSeqNumber>...</catalogSeqNumber>
<catalogSeqNumber>...</catalogSeqNumber>
<catalogSeqNumber>...</catalogSeqNumber>
<catalogSeqNumber>...</catalogSeqNumber>
</illustratedPartsCatalog>
XSLT:
<xsl:variable name="sortedCSN">
<xsl:for-each select="illustratedPartsCatalog/catalogSeqNumber">
<xsl:sort select="concat(itemSeqNumber/partRef/#partNumberValue, #figureNumber,#item)"/>
<xsl:copy-of select="." />
</xsl:for-each>
</xsl:variable>
<xsl:template name="SortParts2" >
<xsl:for-each select="msxsl:node-set($sortedCSN)/catalogSeqNumber">
<xsl:sort select="concat(itemSeqNumber/partRef/#partNumberValue, #figureNumber,#item)"/>
<xsl:call-template name="catalogSeqNumber-NI">
<xsl:with-param name="figNo" select="concat(#figureNumber,#figureNumberVariant)"/>
<xsl:with-param name="prfigNo" select="concat(preceding-sibling::catalogSeqNumber/#figureNumber,preceding-sibling::catalogSeqNumber/#figureNumberVariant)" />
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name="catalogSeqNumber-NI">
<xsl:param name="figNo"/>
<xsl:param name="prfigNo" />
<fo:table-row keep-together.within-page="always" wrap-option="wrap">
<fo:table-cell xsl:use-attribute-sets="table.cell.padding" text-transform="uppercase" wrap-option="wrap">
<fo:block wrap-option="wrap">
<xsl:value-of select=" ./itemSeqNumber/partRef/#partNumberValue"/>
</fo:block>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="table.cell.padding" text-align="start">
<xsl:choose>
<xsl:when test="$figNo">
<fo:block>
<xsl:text> </xsl:text><xsl:value-of select="$figNo"/><xsl:text> </xsl:text> <xsl:value-of select="$prfigNo"/>
</fo:block>
</xsl:when>
<xsl:otherwise>
<fo:block />
</xsl:otherwise>
</xsl:choose>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="table.cell.padding" text-align="start">
<fo:block>
<xsl:if test="./itemSeqNumber/partLocationSegment/notIllustrated">
<xsl:text>-</xsl:text>
</xsl:if>
<xsl:choose>
<xsl:when test="#item">
<xsl:variable name="itemNo">
<xsl:call-template name="suppressZero" >
<xsl:with-param name="pText" select="#item"/>
</xsl:call-template>
</xsl:variable>
<xsl:text> </xsl:text>
<xsl:value-of select="concat($itemNo,#itemVariant)"/>
</xsl:when>
<xsl:otherwise />
</xsl:choose>
</fo:block>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="table.cell.padding">
<fo:block>
<xsl:value-of select="./itemSeqNumber/quantityPerNextHigherAssy"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
I think the default for Antenna House on Windows is to use MSXML so the attempt with xmlns:msxsl="urn:schemas-microsoft-com:xslt" is fine as far as using the node-set extension function.
I think you simply need to change the XSLT to
<xsl:variable name="sortedCSN">
<xsl:for-each select="illustratedPartsCatalog/catalogSeqNumber">
<xsl:sort select="concat(itemSeqNumber/partRef/#partNumberValue, #figureNumber,#item)"/>
<xsl:copy-of select="." />
</xsl:for-each>
</xsl:variable>
<xsl:template name="SortParts2" >
<xsl:for-each select="msxsl:node-set($sortedCSN)/catalogSeqNumber">
<xsl:sort select="concat(itemSeqNumber/partRef/#partNumberValue, #figureNumber,#item)"/>
<xsl:call-template name="catalogSeqNumber-NI">
<xsl:with-param name="figNo" select="concat(#figureNumber,#figureNumberVariant)"/>
<xsl:with-param name="prfigNo" select="concat(preceding-sibling::catalogSeqNumber/#figureNumber,preceding-sibling::catalogSeqNumber/#figureNumberVariant)" />
</xsl:call-template>
</xsl:for-each>
</xsl:template>
to make sense with the input you have shown (as far as you have shown it, can't judge all those xsl:sort attempts without seeing the data to be sorted).
On the other hand, if you get errors about the stylesheet not being correct XSLT or XML, you would better show us a minimal but complete stylesheet allowing us to reproduce the problem.
I'm using Apache FOP to generate PDFs from my web application, where users can edit richtext using CKEditor.
My problem is that users sometimes use different levels of indentation in (un-)ordered lists, e.g.:
List item level 1
List item level 2
The CKEditor shows different bulletins per level (or indentation), but the generated PDFs do not, because my template looks like this:
<!-- Lists -->
<xsl:template match="ul|ol" mode="content">
<xsl:apply-templates select="li" mode="content">
<xsl:with-param name="ordered">
<xsl:value-of select="name()='ol'"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="li" mode="content">
<xsl:param name="ordered"/>
<xsl:variable name="label">
<xsl:choose>
<xsl:when test="$ordered='true'">
<xsl:value-of select="position()"/>
.
</xsl:when>
<xsl:otherwise>
•
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<fo:list-block padding-bottom="0pt">
<fo:list-item>
<fo:list-item-label>
<fo:block>
<xsl:value-of select="$label"/>
</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
<xsl:apply-templates mode="content"/>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</xsl:template>
So how can I set the label variable depending on which level of indentation I'm at?
Something like:
1st level: •
2nd level: ◦
3rd level: ⁍
Thanks in advance, ~Fabi
EDIT: So the solution suggested by #fafl looks like this:
<!-- Lists -->
<xsl:template match="ul|ol" mode="content">
<xsl:param name="depth" select="0"/>
<xsl:apply-templates select="li" mode="content">
<xsl:with-param name="ordered">
<xsl:value-of select="name()='ol'"/>
</xsl:with-param>
<xsl:with-param name="depth">
<xsl:value-of select="$depth + 1"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="li" mode="content">
<xsl:param name="depth" select="0"/>
<xsl:param name="ordered"/>
<xsl:variable name="label">
<xsl:choose>
<xsl:when test="$ordered='true'">
<xsl:value-of select="position()"/>
.
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$depth = 1">
• <!--filled circle-->
</xsl:when>
<xsl:when test="$depth = 2">
◦ <!--not-filled circle-->
</xsl:when>
<xsl:otherwise>
■ <!--black square -->
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<fo:list-block padding-bottom="0pt">
<fo:list-item>
<fo:list-item-label>
<fo:block>
<xsl:value-of select="$label"/>
</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
<xsl:apply-templates mode="content">
<xsl:with-param name="depth">
<xsl:value-of select="$depth"/>
</xsl:with-param>
</xsl:apply-templates>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</xsl:template>
Try adding a parameter "depth" to both templates with a default value of 1. On each recursive call of "ul|ol" increase it by 1. Then you can query it inside both templates.
Given this XML:
<figure id="fig-0011">
<title>Removal of Shipping Kit(s)</title>
<graphic id="fig-0011-gra-0001" infoEntityIdent="66503-00129-A-001-01"></graphic>
</figure>
and
<proceduralStep><para>Remove screw (see <internalRef internalRefId="fig-0011" internalRefTargetType="irtt01"></internalRef>)
<proceduralStep><para>Remove two screws (10) (see <internalRef internalRefId="fig-0011-gra-0001" internalRefTargetType="irtt09"></internalRef>),
I'm trying to create links to the figures and graphics. The link to the figure is working correctly, but the link to the graphic is not:
<fo:basic-link>
<xsl:attribute name="internal-destination"><xsl:apply-templates select="//dmodule/identAndStatusSection/dmAddress/dmIdent/dmCode"/><xsl:value-of select="#internalRefId"/></xsl:attribute>
<xsl:variable name="targetElement" select="local-name(key('id',#internalRefId))"/>
<xsl:for-each select="key('id',(#internalRefId))">
<xsl:choose>
<xsl:when test="$targetElement='graphic'">
<xsl:text>Fig </xsl:text>
<xsl:number count="figure" from="content" level="any"/>
</xsl:when>
<xsl:when test="$targetElement='figure'">
<xsl:text>Fig </xsl:text>
<xsl:number count="figure" from="content" level="any"/>
</xsl:when>
</xsl:choose>
</xsl:for-each>
Key:
<xsl:key name="id" match="*" use="#id"/>
Figure:
<xsl:template match="figure">
<xsl:apply-templates select="graphic"/>
</xsl:template>
<xsl:template match="figure/graphic" priority="10">
<fo:block text-align="center" start-indent="0pt" color="black" keep-with-next="always">
<xsl:call-template name="do-graphic">
<xsl:with-param name="include-graphic" select="true()"/>
</xsl:call-template>
</fo:block>
<xsl:if test="position()=last()">
<xsl:apply-templates select="../legend"/>
</xsl:if>
<xsl:if test="#infoEntityIdent">
<fo:block text-align="right" keep-with-previous="always">
<xsl:value-of select="#infoEntityIdent"/>
</fo:block>
</xsl:if>
<fo:block font-weight="normal" font-style="italic" text-align="center" space-before="12pt" space-after="8pt" start-indent="0pt" keep-with-previous="always">
<xsl:if test="../#id">
<xsl:attribute name="id"><xsl:apply-templates select="//dmodule/identAndStatusSection/dmAddress/dmIdent/dmCode"/><xsl:value-of select="../#id"/></xsl:attribute>
</xsl:if>
<xsl:text>Fig </xsl:text>
<xsl:number count="figure" level="any" format="1" from="content"/>
<xsl:apply-templates select="../title"/>
<xsl:variable name="numSheets" select="count(../graphic)"/>
<xsl:choose>
<xsl:when test="$numSheets>1">
<xsl:text> (Sheet </xsl:text>
<xsl:number count="graphic" level="any" format="1" from="figure"/>
<xsl:text> of </xsl:text>
<xsl:value-of select="$numSheets"/>
<xsl:text>)</xsl:text>
</xsl:when>
</xsl:choose>
</fo:block>
Graphic:
<xsl:template match="graphic">
<fo:inline-container>
<fo:block space-before="12pt" space-before.conditionality="retain">
<xsl:call-template name="do-graphic"/>
</fo:block>
</fo:inline-container>
</xsl:template>
<xsl:template name="do-graphic">
<xsl:param name="include-graphic" select="true()"/>
<xsl:variable name="content-width">
<xsl:choose>
<xsl:when test="#reproductionWidth != ''">
<xsl:value-of select="#reproductionWidth"/>
</xsl:when>
<!-- coding for reproduction scale based on clarifications in Issue 4.1 -->
<xsl:when test="#reproductionScale != ''">
<xsl:value-of select="#reproductionScale"/>
<xsl:text>%</xsl:text>
</xsl:when>
<xsl:otherwise>95%</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="content-height">
<xsl:choose>
<xsl:when test="#reproductionHeight != ''">
<xsl:value-of select="#reproductionHeight"/>
</xsl:when>
<xsl:when test="#reproductionScale != ''">
<xsl:value-of select="#reproductionScale"/>
<xsl:text>%</xsl:text>
</xsl:when>
<xsl:otherwise>95%</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="$include-graphic">
<fo:external-graphic src="{unparsed-entity-uri(#infoEntityIdent)}" scaling="uniform" content-height="{$content-height}" content-width="{$content-width}"/>
</xsl:when>
<xsl:otherwise>
<fo:inline-container display-align="center" text-align="center" block-progression-dimension="{$content-height}" inline-progression-dimension="{$content-width}" background-color="silver" color="red">
<fo:block>Graphic Not Included</fo:block>
</fo:inline-container>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
This returns:
Remove two screws (10) (see Fig 2)
which is the correct figure number, but the 2 is not a clickable link to the graphic.
The dmcode template builds a string. If I remove that from the XSLT then the figure number no longer links to the figure.
I am using XSLT 1.0. I appreciate any help, thank you.
The second internalRef refers to a graphic. It appears that your XSLT is not copying the graphic/#id into the FO in the result tree. With AH Formatter and a stylesheet that doesn't copy graphic/#id, I get no link and the error message:
Unresolved internal-destination: "fig-0011-gra-0001".
It appears that your FO formatter also isn't making the link when there's no matching target ID.
I can't help you much more without seeing your xsl:key declaration(s), the templates for figure and graphic, and knowing whether graphic can appear outside of figure.
Reedited to use figure/#id and graphic/#id:
<xsl:key name="id" match="*" use="#id" />
<xsl:variable name="prefix">
<xsl:apply-templates select="//dmodule/identAndStatusSection/dmAddress/dmIdent/dmCode" />
</xsl:variable>
<xsl:template match="internalRef">
<xsl:for-each select="key('id', #internalRefId)">
<fo:basic-link internal-destination="{$prefix}{#id}">
<xsl:text>Fig </xsl:text>
<xsl:number count="figure" from="content" level="any" />
</fo:basic-link>
</xsl:for-each>
</xsl:template>
<xsl:template match="figure">
<fo:wrapper id="{#id}">
<xsl:apply-templates select="graphic" />
</fo:wrapper>
</xsl:template>
<xsl:template match="figure/graphic" priority="10">
<fo:block text-align="center" start-indent="0pt" color="black" keep-with-next="always">
<xsl:if test="#id">
<xsl:attribute name="id">
<xsl:value-of select="$prefix" />
<xsl:value-of select="#id" />
</xsl:attribute>
</xsl:if>
<xsl:call-template name="do-graphic">
<xsl:with-param name="include-graphic" select="true()" />
</xsl:call-template>
</fo:block>
<xsl:if test="position() = last()">
<xsl:apply-templates select="../legend" />
</xsl:if>
<xsl:if test="#infoEntityIdent">
<fo:block text-align="right" keep-with-previous="always">
<xsl:value-of select="#infoEntityIdent" />
</fo:block>
</xsl:if>
<fo:block font-weight="normal" font-style="italic" text-align="center" space-before="12pt" space-after="8pt" start-indent="0pt" keep-with-previous="always">
<xsl:text>Fig </xsl:text>
<xsl:number count="figure" level="any" format="1" from="content" />
<xsl:apply-templates select="../title" />
<xsl:variable name="numSheets" select="count(../graphic)" />
<xsl:choose>
<xsl:when test="$numSheets > 1">
<xsl:text> (Sheet </xsl:text>
<xsl:number count="graphic" level="any" format="1" from="figure" />
<xsl:text> of </xsl:text>
<xsl:value-of select="$numSheets" />
<xsl:text>)</xsl:text>
</xsl:when>
</xsl:choose>
</fo:block>
</xsl:template>
I also moved the graphic's ID to the first fo:block in the figure/graphic template. Having it on the last fo:block would have meant scrolling up to see the graphic every time that you followed a link to a graphic.
It was suggested to add <xsl:attribute name="id"> to the <fo:external-graphic> in the do-graphic template and that seems to solve the problem:
<xsl:template name="do-graphic">
<xsl:param name="include-graphic" select="true()"/>
<xsl:variable name="content-width">
<xsl:choose>
<xsl:when test="#reproductionWidth != ''">
<xsl:value-of select="#reproductionWidth"/>
<xsl:call-template name="checkForUom">
<xsl:with-param name="measure" select="#reproductionWidth"/>
</xsl:call-template>
</xsl:when>
<!-- coding for reproduction scale based on clarifications in Issue 4.1 -->
<xsl:when test="#reproductionScale != ''">
<xsl:value-of select="#reproductionScale"/>
<xsl:text>%</xsl:text>
</xsl:when>
<xsl:otherwise>95%</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="content-height">
<xsl:choose>
<xsl:when test="#reproductionHeight != ''">
<xsl:value-of select="#reproductionHeight"/>
<xsl:call-template name="checkForUom">
<xsl:with-param name="measure" select="#reproductionWidth"/>
</xsl:call-template>
</xsl:when>
<!-- coding for reproduction scale based on clarifications in Issue 4.1 -->
<xsl:when test="#reproductionScale != ''">
<xsl:value-of select="#reproductionScale"/>
<xsl:text>%</xsl:text>
</xsl:when>
<xsl:otherwise>95%</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="$include-graphic">
<fo:external-graphic src="{unparsed-entity-uri(#infoEntityIdent)}" scaling="uniform" content-height="{$content-height}" content-width="{$content-width}">
<xsl:attribute name="id"><xsl:apply-templates select="//dmodule/identAndStatusSection/dmAddress/dmIdent/dmCode"/><xsl:value-of select="#id"/></xsl:attribute>
</fo:external-graphic>
</xsl:when>
<xsl:otherwise>
<fo:inline-container display-align="center" text-align="center" block-progression-dimension="{$content-height}" inline-progression-dimension="{$content-width}" background-color="silver" color="red">
<fo:block>Graphic Not Included</fo:block>
</fo:inline-container>
</xsl:otherwise>
</xsl:choose>
</xsl:template>