View stylesheet

XML schema http://water.eionet.europa.eu/schemas/dir200760ec/FRMP_1p1.xsd
Output type PDF
Description test pdf
XSL file test.xslt (Last modified: 02 Nov 2016 09:57 )
<?xml version="1.0" encoding="UTF-8"?>
<!--Designed and generated by Altova StyleVision Enterprise Edition 2017 - see http://www.altova.com/stylevision for more information.-->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:altova="http://www.altova.com" xmlns:altova-xfi="http://www.altova.com/xslt-extensions/xbrl" xmlns:altovaext="http://www.altova.com/xslt-extensions" xmlns:array="http://www.w3.org/2005/xpath-functions/array" xmlns:clitype="clitype" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:fd="http://water.eionet.europa.eu/schemas/dir200760ec/fdcommon" 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:map="http://www.w3.org/2005/xpath-functions/map" xmlns:math="http://www.w3.org/2005/xpath-functions/math" xmlns:n1="http://water.eionet.europa.eu/schemas/dir200760ec" 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:xff="http://www.xbrl.org/2010/function/formula" xmlns:xfi="http://www.xbrl.org/2008/function/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="#all">
	<xsl:output version="1.0" method="xml" encoding="UTF-8" indent="no"/>
	<xsl:param name="altova:bGeneratingFromPxf" select="false()"/>
	<xsl:param name="SV_OutputFormat" select="'PDF'"/>
	<xsl:param name="SV_BaseOutputFileName" as="xs:string?">
		<xsl:sequence select="for $i in altovaext:get-base-output-uri(), $j in tokenize( $i, &apos;[/\\]&apos; )[last()] return replace( $j, &apos;\.[^\.\s#%;]*$&apos;, &apos;&apos; )" use-when="function-available(&apos;altovaext:get-base-output-uri&apos;)"/>
	</xsl:param>
	<xsl:param name="SV_GeneratedFileNamePrefix" select="if ( $SV_BaseOutputFileName ) then $SV_BaseOutputFileName else &apos;SPS1&apos;" as="xs:string?"/>
	<xsl:variable name="XML" select="/"/>
	<xsl:import-schema schema-location="http://water.eionet.europa.eu/schemas/dir200760ec/FRMP_1p1.xsd" use-when="system-property('xsl:is-schema-aware')='yes'" namespace="http://water.eionet.europa.eu/schemas/dir200760ec"/>
	<xsl:variable name="fo:layout-master-set">
		<fo:layout-master-set>
			<fo:simple-page-master master-name="page-master-0-even" margin-left="0.60in" margin-right="0.60in" page-height="11in" page-width="8.50in" margin-top="0.30in" margin-bottom="0.30in">
				<fo:region-body margin-top="0.49in" margin-bottom="0.49in" column-count="1" column-gap="0.50in"/>
			</fo:simple-page-master>
			<fo:simple-page-master master-name="page-master-0-odd" margin-left="0.60in" margin-right="0.60in" page-height="11in" page-width="8.50in" margin-top="0.30in" margin-bottom="0.30in">
				<fo:region-body margin-top="0.49in" margin-bottom="0.49in" column-count="1" column-gap="0.50in"/>
			</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" 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:variable name="altova:CssImages" select="()"/>
	<xsl:variable name="altova:bDoFirstSectionBreak" as="xs:boolean" select="true()"/>
	<xsl:variable name="altova:sCssSwitch" as="xs:string" select="''"/>
	<xsl:variable name="altova:nodeCssClasses" select="()"/>
	<xsl:variable name="altova:design-xslt-tree-view">
		<altova:main-document url="{if ($SV_BaseOutputFileName) then concat($SV_BaseOutputFileName,'.fo') else ''}">
			<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 2017 (http://www.altova.com)</xmp:CreatorTool>
							</rdf:Description>
						</rdf:RDF>
					</x:xmpmeta>
				</fo:declarations>
				<fo:page-sequence master-reference="page-master-0" initial-page-number="auto" format="1" force-page-count="no-force">
					<fo:static-content flow-name="xsl-footnote-separator">
						<fo:block>
							<fo:leader leader-pattern="rule" leader-length="100%" rule-style="solid" rule-thickness="0.5pt"/>
						</fo:block>
					</fo:static-content>
					<fo:flow flow-name="xsl-region-body">
						<fo:block>
							<xsl:for-each select="$XML">
								<xsl:for-each select="n1:FRMP">
									<xsl:for-each select="n1:SummaryOverall">
										<xsl:for-each select="n1:APSFRCode">
											<altova:inline-container-substitute>
												<xsl:apply-templates/>
											</altova:inline-container-substitute>
										</xsl:for-each>
									</xsl:for-each>
								</xsl:for-each>
							</xsl:for-each>
							<xsl:for-each select="$XML">
								<xsl:for-each select="n1:FRMP">
									<xsl:for-each select="n1:SummaryOverall">
										<xsl:for-each select="n1:SummaryObjectives">
											<altova:inline-container-substitute>
												<xsl:apply-templates/>
											</altova:inline-container-substitute>
										</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>
		</altova:main-document>
	</xsl:variable>
	<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) &gt;= 0 and number($cLast) &lt;= 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:template match="@* | node()" mode="altova:copy-table">
		<xsl:copy>
			<xsl:apply-templates select="@* | node()" mode="#current"/>
		</xsl:copy>
	</xsl:template>
	<xsl:template match="fo:table" mode="altova:copy-table">
		<xsl:choose>
			<xsl:when test="(empty(fo:table-body/fo:table-row) and empty(fo:table-header/fo:table-row) and empty(fo:table-footer/fo:table-row)) or empty(.//fo:table-cell)">				</xsl:when>
			<xsl:otherwise>
				<xsl:copy>
					<xsl:apply-templates select="@* | node()" mode="#current"/>
				</xsl:copy>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="fo:table-header | fo:table-footer" mode="altova:copy-table">
		<xsl:choose>
			<xsl:when test="empty(fo:table-row)">				</xsl:when>
			<xsl:otherwise>
				<xsl:copy>
					<xsl:apply-templates select="@* | node()" mode="#current"/>
				</xsl:copy>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="fo:table-body" mode="altova:copy-table">
		<xsl:choose>
			<xsl:when test="empty(fo:table-row)">
				<xsl:copy>
					<xsl:apply-templates select="@* | node()" mode="#current"/>
					<fo:table-row>
						<fo:table-cell>
							<fo:block/>
						</fo:table-cell>
					</fo:table-row>
				</xsl:copy>
			</xsl:when>
			<xsl:otherwise>
				<xsl:copy-of select="."/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="fo:table-row" mode="altova:copy-table">
		<xsl:choose>
			<xsl:when test="empty(fo:table-cell)">
				<xsl:copy>
					<fo:table-cell>
						<fo:block/>
					</fo:table-cell>
				</xsl:copy>
			</xsl:when>
			<xsl:otherwise>
				<xsl:copy-of select="."/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="fo:list-item[empty(@break-before)]" mode="second-step">
		<xsl:copy>
			<xsl:choose>
				<xsl:when test=".//altova:page-break">
					<xsl:attribute name="break-before" select="'page'"/>
				</xsl:when>
				<xsl:when test=".//altova:column-break">
					<xsl:attribute name="break-before" select="'column'"/>
				</xsl:when>
			</xsl:choose>
			<xsl:apply-templates select="@* | node()" mode="#current"/>
		</xsl:copy>
	</xsl:template>
	<xsl:template match="altova:pdf-bookmark-tree[@generate-from-toc = false()]" mode="second-step">
		<xsl:variable name="altova:pdf-bookmarks">
			<xsl:apply-templates mode="altova:filter-pdf-bookmark-tree"/>
		</xsl:variable>
		<xsl:if test="exists($altova:pdf-bookmarks/fo:bookmark)">
			<fo:bookmark-tree>
				<xsl:copy-of select="$altova:pdf-bookmarks"/>
			</fo:bookmark-tree>
		</xsl:if>
	</xsl:template>
	<xsl:template match="node()" mode="altova:filter-pdf-bookmark-tree">
		<xsl:apply-templates mode="#current"/>
	</xsl:template>
	<xsl:template match="altova:pdf-bookmark" mode="altova:filter-pdf-bookmark-tree">
		<fo:bookmark>
			<xsl:sequence select="@starting-state"/>
			<xsl:variable name="altova:hyperlink" select="altova:hyperlink[1]"/>
			<xsl:choose>
				<xsl:when test="not(exists($altova:hyperlink))">
					<xsl:message select="'Error: Found PDF bookmark without a corresponding hyperlink!'" terminate="yes"/>
					<xsl:attribute name="internal-destination" select="'undefined'"/>
					<fo:bookmark-title/>
				</xsl:when>
				<xsl:when test="not(starts-with($altova:hyperlink/@href,'#'))">
					<xsl:message select="concat('Error: External bookmark destinations (',$altova:hyperlink/@href,') are not supported by FOP 0.93/1.0!')" terminate="yes"/>
					<xsl:attribute name="internal-destination" select="'external-destination-not-supported'"/>
					<fo:bookmark-title>
						<xsl:sequence select="$altova:hyperlink//@color[1] | $altova:hyperlink//@font-style[.='normal' or .='italic'][1] | $altova:hyperlink//@font-weight[.='normal' or .='bold'][1]"/>
						<xsl:value-of select="string($altova:hyperlink)"/>
					</fo:bookmark-title>
				</xsl:when>
				<xsl:otherwise>
					<xsl:variable name="altova:bookmark-name" select="substring($altova:hyperlink/@href,2)"/>
					<xsl:variable name="altova:source-document" select="ancestor::*[self::altova:result-document | self::altova:main-document][1]"/>
					<xsl:variable name="altova:target-document" select="key('altova:bookmark-key',$altova:bookmark-name,$altova:design-xslt-tree-view)[1]/ancestor::*[self::altova:result-document | self::altova:main-document][1]"/>
					<xsl:choose>
						<xsl:when test="empty($altova:target-document) or $altova:source-document is $altova:target-document">
							<xsl:attribute name="internal-destination" select="$altova:bookmark-name"/>
						</xsl:when>
						<xsl:otherwise>
							<xsl:variable name="altova:relative-path" select="altova:calc-relative-path($altova:source-document/@url,$altova:target-document/@url)"/>
							<xsl:variable name="altova:url" select="concat(substring($altova:relative-path,1,string-length($altova:relative-path) - 3),'.pdf#dest=',$altova:bookmark-name)"/>
							<xsl:message select="concat('Warning: External bookmark destinations (',$altova:url,') are not supported by FOP 0.93/1.0!')"/>
							<xsl:attribute name="internal-destination" select="'external-destination-not-supported'"/>
						</xsl:otherwise>
					</xsl:choose>
					<fo:bookmark-title>
						<xsl:sequence select="$altova:hyperlink//@color[1] | $altova:hyperlink//@font-style[.='normal' or .='italic'][1] | $altova:hyperlink//@font-weight[.='normal' or .='bold'][1]"/>
						<xsl:value-of select="string($altova:hyperlink)"/>
					</fo:bookmark-title>
				</xsl:otherwise>
			</xsl:choose>
			<xsl:if test="count(altova:hyperlink) gt 1">
				<xsl:message select="concat('Error: Found PDF bookmark (',$altova:hyperlink/@href,') with more than one corresponding hyperlinks!')" terminate="yes"/>
			</xsl:if>
			<xsl:apply-templates mode="#current"/>
		</fo:bookmark>
	</xsl:template>
	<xsl:template match="fo:basic-link" mode="second-step">
		<xsl:choose>
			<xsl:when test="count(node()) eq 1 and fo:block">
				<fo:block>
					<xsl:apply-templates select="fo:block[1]/@*" mode="#current"/>
					<fo:basic-link>
						<xsl:apply-templates select="@*" mode="#current"/>
						<xsl:apply-templates select="fo:block[1]/node()" mode="#current"/>
					</fo:basic-link>
				</fo:block>
			</xsl:when>
			<xsl:otherwise>
				<xsl:copy>
					<xsl:apply-templates select="@* | node()" mode="#current"/>
				</xsl:copy>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:function name="altova:is-node-empty" as="xs:boolean">
		<xsl:param name="altova:node" as="element()"/>
		<xsl:sequence select="every $altova:child in $altova:node/child::node() satisfies ( ( boolean( $altova:child/self::text() ) and string-length( $altova:child ) = 0 ) or ( ( boolean( $altova:child/self::altova:inline-container-substitute ) or boolean( $altova:child/self::fo:inline ) or boolean( $altova:child/self::fo:inline-container ) or boolean( $altova:child/self::fo:block-container ) or boolean( $altova:child/self::fo:block ) or boolean( $altova:child/self::fo:basic-link ) ) and altova:is-node-empty( $altova:child ) ) )"/>
	</xsl:function>
	<xsl:function name="altova:col-span" as="xs:integer">
		<xsl:param name="altova:cell" as="element()"/>
		<xsl:sequence select="if ( exists( $altova:cell/@number-columns-spanned ) ) then xs:integer( $altova:cell/@number-columns-spanned ) else 1"/>
	</xsl:function>
	<xsl:template match="/">
		<xsl:apply-templates select="$altova:design-xslt-tree-view" mode="second-step"/>
	</xsl:template>
	<xsl:template match="altova:result-document" mode="second-step">
		<xsl:result-document href="{@url}">
			<xsl:apply-templates mode="#current"/>
		</xsl:result-document>
	</xsl:template>
	<xsl:template match="altova:bookmark" mode="second-step">
		<xsl:variable name="bookmark-content">
			<altova:bookmark>
				<xsl:apply-templates select="node()" mode="#current"/>
			</altova:bookmark>
		</xsl:variable>
		<xsl:choose>
			<xsl:when test="altova:is-node-empty($bookmark-content/altova:bookmark)">
				<fo:block>
					<xsl:apply-templates select="@*" mode="#current"/>
					<xsl:copy-of select="$bookmark-content/altova:bookmark/node()"/>
				</fo:block>
			</xsl:when>
			<xsl:otherwise>
				<fo:inline>
					<xsl:apply-templates select="@*" mode="#current"/>
					<xsl:copy-of select="$bookmark-content/altova:bookmark/node()"/>
				</fo:inline>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:key name="altova:bookmark-key" match="altova:bookmark" use="@name"/>
	<xsl:template match="altova:bookmark/@name" mode="second-step">
		<xsl:attribute name="id" select="."/>
	</xsl:template>
	<xsl:template match="altova:hyperlink" mode="second-step">
		<fo:basic-link>
			<xsl:apply-templates select="@* | node()" mode="#current"/>
		</fo:basic-link>
	</xsl:template>
	<xsl:template match="altova:hyperlink/@href" mode="second-step">
		<xsl:choose>
			<xsl:when test="not(string(.))">
				<xsl:attribute name="external-destination" select="'url()'"/>
			</xsl:when>
			<xsl:when test="starts-with(.,'#')">
				<xsl:variable name="altova:bookmark-name" select="substring(.,2)"/>
				<xsl:variable name="altova:source-document" select="ancestor::*[self::altova:result-document | self::altova:main-document][1]"/>
				<xsl:variable name="altova:target-document" select="key('altova:bookmark-key',$altova:bookmark-name,$altova:design-xslt-tree-view)[1]/ancestor::*[self::altova:result-document | self::altova:main-document][1]"/>
				<xsl:choose>
					<xsl:when test="empty($altova:target-document) or $altova:source-document is $altova:target-document">
						<xsl:attribute name="internal-destination" select="$altova:bookmark-name"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:variable name="altova:relative-path" select="altova:calc-relative-path($altova:source-document/@url,$altova:target-document/@url)"/>
						<xsl:variable name="altova:url" select="concat(substring($altova:relative-path,1,string-length($altova:relative-path) - 3),'.pdf#dest=',$altova:bookmark-name)"/>
						<xsl:variable name="altova:escaped-url">
							<xsl:call-template name="altova:double-backslash">
								<xsl:with-param name="text" select="$altova:url"/>
								<xsl:with-param name="text-length" select="string-length($altova:url)"/>
							</xsl:call-template>
						</xsl:variable>
						<xsl:attribute name="external-destination" select="concat('url(',$altova:escaped-url,')')"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:otherwise>
				<xsl:variable name="altova:escaped-url">
					<xsl:choose>
						<xsl:when test="starts-with(.,'\\') or substring(.,2,1)=':'">
							<xsl:value-of select="iri-to-uri(concat('file:///',translate(.,'\','/')))"/>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="iri-to-uri(.)"/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:variable>
				<xsl:attribute name="external-destination" select="concat('url(',$altova:escaped-url,')')"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="altova:inline-container-substitute" mode="second-step">
		<xsl:choose>
			<xsl:when test="altova:IsInline(.)">
				<fo:inline>
					<xsl:copy-of select="@* except @altova-DisableOutputEscaping"/>
					<xsl:apply-templates mode="second-step"/>
				</fo:inline>
			</xsl:when>
			<xsl:otherwise>
				<fo:block>
					<xsl:copy-of select="@* except @altova-DisableOutputEscaping"/>
					<xsl:apply-templates mode="second-step"/>
				</fo:block>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:function name="altova:IsInline" as="xs:boolean">
		<xsl:param name="nodePassed" as="node()"/>
		<xsl:choose>
			<xsl:when test="(empty(for $i in $nodePassed/child::node() return index-of(('fo:block', 'fo:block-container', 'fo:list-block', 'fo:table'), name($i))) and (every $i in $nodePassed/altova:inline-container-substitute satisfies altova:IsInline($i))) or name($nodePassed/../..) eq 'fo:list-item-body'">
				<xsl:sequence select="true()"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:sequence select="false()"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:function>
	<xsl:template match="altova:main-document" mode="second-step">
		<xsl:apply-templates mode="#current"/>
	</xsl:template>
	<xsl:template match="altova:basic-link-container" mode="second-step">
		<fo:block text-align-last="justify">
			<xsl:apply-templates mode="second-step"/>
		</fo:block>
	</xsl:template>
	<xsl:template match="altova:page-break" mode="second-step">
		<xsl:if test="empty(ancestor::fo:list-item)">
			<fo:block break-after="page"/>
		</xsl:if>
	</xsl:template>
	<xsl:template match="altova:line-break" mode="second-step">
		<xsl:variable name="name-following-sibling" select="name(following-sibling::*[1])"/>
		<xsl:variable name="name-preceding-sibling" select="name(preceding-sibling::*[1])"/>
		<xsl:if test="($name-following-sibling and $name-following-sibling != 'fo:table' and $name-following-sibling != 'altova:line-break' and $name-preceding-sibling != 'altova:basic-link-container') or $name-preceding-sibling = 'altova:line-break'">
			<fo:block>
				<xsl:if test="($name-preceding-sibling != 'altova:inline-container-substitute' and $name-preceding-sibling != 'fo:inline' and $name-preceding-sibling != 'fo:basic-link' and $name-preceding-sibling != 'altova:bookmark' and $name-preceding-sibling != 'altova:hyperlink') or ($name-following-sibling != 'altova:inline-container-substitute' and $name-following-sibling != 'fo:inline' and $name-following-sibling != 'fo:basic-link' and $name-following-sibling != 'altova:bookmark' and $name-following-sibling != 'altova:hyperlink')">
					<fo:leader leader-pattern="space"/>
				</xsl:if>
			</fo:block>
		</xsl:if>
	</xsl:template>
	<xsl:template match="altova:column-break" mode="second-step">
		<xsl:if test="empty(ancestor::fo:list-item)">
			<fo:block break-after="column"/>
		</xsl:if>
	</xsl:template>
	<xsl:function name="altova:calc-relative-path" as="xs:string">
		<xsl:param name="altova:source-path"/>
		<xsl:param name="altova:target-path"/>
		<xsl:choose>
			<xsl:when test="$altova:source-path = $altova:target-path">
				<xsl:sequence select="''"/>
			</xsl:when>
			<xsl:when test="starts-with($altova:target-path,'http:') or starts-with($altova:target-path,'ftp:') or starts-with($altova:target-path,'file:')">
				<xsl:sequence select="$altova:target-path"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:variable name="altova:source-parts" select="tokenize($altova:source-path,'[/\\]')"/>
				<xsl:variable name="altova:target-parts" select="tokenize($altova:target-path,'[/\\]')"/>
				<xsl:variable name="altova:common-part-count" select="sum(for $i in (1 to count($altova:source-parts) - 1) return if( subsequence($altova:source-parts,1,$i) = subsequence($altova:target-parts,1,$i) ) then 1 else 0)"/>
				<xsl:sequence select="string-join((for $i in ($altova:common-part-count + 1 to count($altova:source-parts) - 1) return '..',for $i in ($altova:common-part-count + 1 to count($altova:target-parts)) return $altova:target-parts[$i]),'/')"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:function>
	<xsl:function name="altova:map-preview-filepath" as="xs:string">
		<xsl:param name="filepath"/>
		<xsl:sequence select="altovaext:create-temp-file-mapping($filepath)" use-when="function-available('altovaext:create-temp-file-mapping',1)"/>
		<xsl:sequence select="$filepath" use-when="not(function-available('altovaext:create-temp-file-mapping',1))"/>
	</xsl:function>
	<xsl:template match="*|@*|comment()|processing-instruction()" mode="second-step">
		<xsl:copy>
			<xsl:apply-templates select="node()|@* except @altova-DisableOutputEscaping" mode="second-step"/>
		</xsl:copy>
	</xsl:template>
	<xsl:template match="text()" mode="second-step">
		<xsl:choose>
			<xsl:when test="../@altova-DisableOutputEscaping">
				<xsl:value-of select="." disable-output-escaping="yes"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:copy/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="altova:number" mode="second-step">
		<xsl:number level="single" count="altova:dummy-list-item | fo:list-item" format="{@format}" from="fo:list-block"/>
	</xsl:template>
	<xsl:template match="altova:dummy-list-item" mode="second-step">		</xsl:template>
	<xsl:function name="altova:AddCompositeStyles">
		<xsl:param name="altova:sStyleList" as="xs:string?"/>
		<xsl:variable name="altova:seqStyles" select="tokenize($altova:sStyleList, ';')" as="xs:string*"/>
		<xsl:for-each select="$altova:seqStyles">
			<xsl:variable name="altova:sStyleName" select="normalize-space(substring-before(., ':'))" as="xs:string?"/>
			<xsl:variable name="altova:sStyleValue" as="xs:string?">
				<xsl:call-template name="altova:MakeValueAbsoluteIfPixels">
					<xsl:with-param name="sValue" select="normalize-space(substring-after(., ':'))"/>
				</xsl:call-template>
			</xsl:variable>
			<xsl:if test="$altova:sStyleName and $altova:sStyleValue">
				<xsl:attribute name="{$altova:sStyleName}" select="$altova:sStyleValue"/>
			</xsl:if>
		</xsl:for-each>
	</xsl:function>
	<xsl:function name="altova:AddDynamicClassStyles">
		<xsl:param name="altova:sClassName" as="xs:string?"/>
		<xsl:variable name="nodeRule" select="$altova:nodeCssClasses/Class[@sSelector eq $altova:sClassName and ($altova:sCssSwitch eq '' or @sFile eq $altova:sCssSwitch)]" as="node()*"/>
		<xsl:if test="$nodeRule">
			<xsl:copy-of select="$nodeRule/Styles/@*"/>
		</xsl:if>
	</xsl:function>
	<xsl:function name="altova:GetCellFromRow" as="node()?" xpath-default-namespace="">
		<xsl:param name="nodeTableRow" as="node()"/>
		<xsl:param name="nCell" as="xs:integer"/>
		<xsl:sequence select="$nodeTableRow/(fo:table-cell | fo:table-cell)[$nCell]"/>
	</xsl:function>
	<xsl:function name="altova:GetCellsFromRow" as="node()*" xpath-default-namespace="">
		<xsl:param name="nodeTableRow" as="node()"/>
		<xsl:sequence select="$nodeTableRow/(fo:table-cell | fo:table-cell)"/>
	</xsl:function>
	<xsl:function name="altova:GetRowsFromTable" as="node()*" xpath-default-namespace="">
		<xsl:param name="nodeTable" as="node()"/>
		<xsl:sequence select="$nodeTable/(fo:table-header | fo:table-body | fo:table-footer)/fo:table-row"/>
	</xsl:function>
	<xsl:function name="altova:GetRowspanFromCell" as="xs:integer" xpath-default-namespace="">
		<xsl:param name="altova:nodeCell" as="node()"/>
		<xsl:variable name="altova:sRowSpan" select="$altova:nodeCell/@number-rows-spanned" as="xs:string?"/>
		<xsl:variable name="altova:nRowSpan" select="if ($altova:sRowSpan) then xs:integer($altova:sRowSpan) else 1" as="xs:integer"/>
		<xsl:sequence select="$altova:nRowSpan"/>
	</xsl:function>
	<!-- In HTML and FO, the table section order is header, footer, body. This function determines, for a given cell, the number its row would have if the section order were header, body, footer -->
	<xsl:function name="altova:GetGridRowNumForCell" xpath-default-namespace="">
		<xsl:param name="altova:nodeTableCell" as="node()"/>
		<xsl:variable name="altova:nodeTableRow" select="$altova:nodeTableCell/.." as="node()"/>
		<xsl:variable name="altova:nodeTableSection" select="$altova:nodeTableRow/.." as="node()"/>
		<xsl:variable name="altova:sTableSection" select="fn:local-name($altova:nodeTableSection)" as="xs:string"/>
		<xsl:variable name="altova:nodeTable" select="$altova:nodeTableSection/.." as="node()"/>
		<xsl:variable name="altova:nRowNumInSection" select="count($altova:nodeTableRow/preceding-sibling::fo:table-row) + 1" as="xs:integer"/>
		<xsl:choose>
			<xsl:when test="$altova:sTableSection eq 'table-body'">
				<xsl:sequence select="count($altova:nodeTable/fo:table-header/fo:table-row) + $altova:nRowNumInSection"/>
			</xsl:when>
			<xsl:when test="$altova:sTableSection eq 'table-header'">
				<xsl:sequence select="$altova:nRowNumInSection"/>
			</xsl:when>
			<xsl:when test="$altova:sTableSection eq 'table-footer'">
				<xsl:sequence select="count($altova:nodeTable/fo:table-header/fo:table-row) + count($altova:nodeTable/fo:table-body/fo:table-row) + $altova:nRowNumInSection"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:message select="'Internal Error'" terminate="yes"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:function>
	<xsl:function name="altova:BuildTableIndexInfo" as="node()" xpath-default-namespace="">
		<xsl:param name="altova:nodeTable" as="node()"/>
		<altova:ColumnIndices>
			<xsl:variable name="altova:nodeAllRows" select="altova:GetRowsFromTable($altova:nodeTable/fo:table)" as="node()*"/>
			<xsl:if test="$altova:nodeAllRows">
				<xsl:variable name="altova:seqCellsInFirstRow" select="altova:GetCellsFromRow($altova:nodeAllRows[1])" as="node()*"/>
				<xsl:variable name="altova:nColumnsInTable" select="sum(for $nodeCell in $altova:seqCellsInFirstRow return altova:col-span($nodeCell))" as="xs:integer"/>
				<xsl:variable name="altova:seqActiveRowSpans" select="for $Cell in 1 to $altova:nColumnsInTable return 0" as="xs:integer*"/>
				<!--xsl:sequence select="altova:BuildTableIndexInfo_Recursive($altova:nodeAllRows, 1, $altova:seqActiveRowSpans)"/-->
				<xsl:call-template name="altova:BuildTableIndexInfo_Recursive">
					<xsl:with-param name="altova:nodeTableRows" select="$altova:nodeAllRows"/>
					<xsl:with-param name="altova:nRow" select="1"/>
					<xsl:with-param name="altova:seqActiveRowSpans" select="$altova:seqActiveRowSpans"/>
				</xsl:call-template>
			</xsl:if>
		</altova:ColumnIndices>
	</xsl:function>
	<!--xsl:template name="altova:BuildTableIndexInfo_Recursive" as="node()*" xpath-default-namespace=""-->
	<xsl:template name="altova:BuildTableIndexInfo_Recursive" xpath-default-namespace="">
		<xsl:param name="altova:nodeTableRows" as="node()*"/>
		<xsl:param name="altova:nRow" as="xs:integer"/>
		<xsl:param name="altova:seqActiveRowSpans" as="xs:integer*"/>
		<xsl:variable name="altova:nodeRow" select="$altova:nodeTableRows[$altova:nRow]" as="node()?"/>
		<xsl:choose>
			<xsl:when test="empty($altova:nodeRow)">
				<xsl:sequence select="()"/>
			</xsl:when>
			<xsl:when test="empty(altova:GetCellFromRow($altova:nodeRow, 1))">
				<xsl:sequence select="()"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:variable name="altova:nodeCell1" select="altova:GetCellFromRow($altova:nodeRow, 1)" as="node()?"/>
				<xsl:variable name="altova:nColSpan" select="altova:col-span($altova:nodeCell1)" as="xs:integer"/>
				<altova:Row>
					<!--xsl:variable name="altova:seqColumnIndicesOfCurrentRow" select="altova:BuildTableIndexInfo_SingleRow_Recursive($altova:seqActiveRowSpans, $altova:nodeRow, 1, 1, $altova:nColSpan, true(), 0, 0)" as="node()*"/>
						<xsl:sequence select="$altova:seqColumnIndicesOfCurrentRow"/-->
					<xsl:call-template name="altova:BuildTableIndexInfo_SingleRow_Recursive">
						<xsl:with-param name="altova:seqActiveRowSpans" select="$altova:seqActiveRowSpans"/>
						<xsl:with-param name="altova:nodeRow" select="$altova:nodeRow"/>
						<xsl:with-param name="altova:nColumn" select="1"/>
						<xsl:with-param name="altova:nCellInCurrentRow" select="1"/>
						<xsl:with-param name="altova:nColSpanInCellRemaining" select="$altova:nColSpan"/>
						<xsl:with-param name="altova:bColSpanBegins" select="true()"/>
						<xsl:with-param name="altova:nCurrentSum" select="0"/>
						<xsl:with-param name="altova:nRowSpansToAdd" select="0"/>
					</xsl:call-template>
				</altova:Row>
				<xsl:variable name="altova:seqActiveRowSpans_New" select="altova:BuildTableIndexInfo_ActiveRowSpans_Recursive($altova:seqActiveRowSpans, $altova:nodeRow, 1, 1, $altova:nColSpan)" as="xs:integer*"/>
				<!--xsl:sequence select="altova:BuildTableIndexInfo_Recursive($altova:nodeTableRows, $altova:nRow + 1, $altova:seqActiveRowSpans_New)"/-->
				<xsl:call-template name="altova:BuildTableIndexInfo_Recursive">
					<xsl:with-param name="altova:nodeTableRows" select="$altova:nodeTableRows"/>
					<xsl:with-param name="altova:nRow" select="$altova:nRow + 1"/>
					<xsl:with-param name="altova:seqActiveRowSpans" select="$altova:seqActiveRowSpans_New"/>
				</xsl:call-template>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<!--xsl:template name="altova:BuildTableIndexInfo_SingleRow_Recursive" as="node()*" xpath-default-namespace=""-->
	<xsl:template name="altova:BuildTableIndexInfo_SingleRow_Recursive" xpath-default-namespace="">
		<xsl:param name="altova:seqActiveRowSpans" as="xs:integer*"/>
		<xsl:param name="altova:nodeRow" as="node()"/>
		<xsl:param name="altova:nColumn" as="xs:integer"/>
		<xsl:param name="altova:nCellInCurrentRow" as="xs:integer"/>
		<xsl:param name="altova:nColSpanInCellRemaining" as="xs:integer"/>
		<xsl:param name="altova:bColSpanBegins" as="xs:boolean"/>
		<!-- Also true if it's just a single cell -->
		<xsl:param name="altova:nCurrentSum" as="xs:integer"/>
		<xsl:param name="altova:nRowSpansToAdd" as="xs:integer"/>
		<xsl:choose>
			<xsl:when test="$altova:nColumn gt count($altova:seqActiveRowSpans)">
				<xsl:sequence select="()"/>
			</xsl:when>
			<!-- If the cell is not under a rowspan -->
			<xsl:when test="$altova:seqActiveRowSpans[$altova:nColumn] eq 0">
				<!-- If the cell is not under a colspan -->
				<xsl:if test="$altova:bColSpanBegins eq true()">
					<!-- A non-spanned cell starts in this column -->
					<altova:ColumnIndex>
						<xsl:sequence select="$altova:nCurrentSum + 1"/>
					</altova:ColumnIndex>
				</xsl:if>
				<xsl:variable name="altova:nCellInCurrentRow_New" select="if ($altova:nColSpanInCellRemaining gt 1) then $altova:nCellInCurrentRow else $altova:nCellInCurrentRow + 1" as="xs:integer"/>
				<xsl:variable name="altova:nColSpanInCell_New" select="if ($altova:nColSpanInCellRemaining gt 1) then $altova:nColSpanInCellRemaining - 1 else if (empty(altova:GetCellFromRow($altova:nodeRow, $altova:nCellInCurrentRow_New))) then 1 else altova:col-span(altova:GetCellFromRow($altova:nodeRow, $altova:nCellInCurrentRow_New))" as="xs:integer"/>
				<xsl:variable name="altova:bColSpanBegins_New" select="$altova:nCellInCurrentRow ne $altova:nCellInCurrentRow_New" as="xs:boolean"/>
				<!--xsl:sequence select="altova:BuildTableIndexInfo_SingleRow_Recursive($altova:seqActiveRowSpans, $altova:nodeRow, $altova:nColumn + 1, $altova:nCellInCurrentRow_New, $altova:nColSpanInCell_New, $altova:bColSpanBegins_New, $altova:nCurrentSum + 1, $altova:nRowSpansToAdd)"/-->
				<xsl:call-template name="altova:BuildTableIndexInfo_SingleRow_Recursive">
					<xsl:with-param name="altova:seqActiveRowSpans" select="$altova:seqActiveRowSpans"/>
					<xsl:with-param name="altova:nodeRow" select="$altova:nodeRow"/>
					<xsl:with-param name="altova:nColumn" select="$altova:nColumn + 1"/>
					<xsl:with-param name="altova:nCellInCurrentRow" select="$altova:nCellInCurrentRow_New"/>
					<xsl:with-param name="altova:nColSpanInCellRemaining" select="$altova:nColSpanInCell_New"/>
					<xsl:with-param name="altova:bColSpanBegins" select="$altova:bColSpanBegins_New"/>
					<xsl:with-param name="altova:nCurrentSum" select="$altova:nCurrentSum + 1"/>
					<xsl:with-param name="altova:nRowSpansToAdd" select="$altova:nRowSpansToAdd"/>
				</xsl:call-template>
			</xsl:when>
			<!-- The cell is under a rowspan -->
			<xsl:otherwise>
				<!--xsl:sequence select="altova:BuildTableIndexInfo_SingleRow_Recursive($altova:seqActiveRowSpans, $altova:nodeRow, $altova:nColumn + 1, $altova:nCellInCurrentRow, $altova:nColSpanInCellRemaining, $altova:bColSpanBegins, $altova:nCurrentSum + 1, $altova:nRowSpansToAdd + 1)"/-->
				<xsl:call-template name="altova:BuildTableIndexInfo_SingleRow_Recursive">
					<xsl:with-param name="altova:seqActiveRowSpans" select="$altova:seqActiveRowSpans"/>
					<xsl:with-param name="altova:nodeRow" select="$altova:nodeRow"/>
					<xsl:with-param name="altova:nColumn" select="$altova:nColumn + 1"/>
					<xsl:with-param name="altova:nCellInCurrentRow" select="$altova:nCellInCurrentRow"/>
					<xsl:with-param name="altova:nColSpanInCellRemaining" select="$altova:nColSpanInCellRemaining"/>
					<xsl:with-param name="altova:bColSpanBegins" select="$altova:bColSpanBegins"/>
					<xsl:with-param name="altova:nCurrentSum" select="$altova:nCurrentSum + 1"/>
					<xsl:with-param name="altova:nRowSpansToAdd" select="$altova:nRowSpansToAdd + 1"/>
				</xsl:call-template>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:function name="altova:BuildTableIndexInfo_ActiveRowSpans_Recursive" as="xs:integer*" xpath-default-namespace="">
		<xsl:param name="altova:seqRowSpans" as="xs:integer*"/>
		<xsl:param name="altova:nodeCurrentRow" as="node()"/>
		<xsl:param name="altova:nColumn" as="xs:integer"/>
		<xsl:param name="altova:nCellInCurrentRow" as="xs:integer"/>
		<xsl:param name="altova:nColSpanInCellRemaining" as="xs:integer"/>
		<xsl:choose>
			<xsl:when test="$altova:nColumn gt count($altova:seqRowSpans)">
				<xsl:sequence select="()"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:variable name="altova:nRowSpanForCurrentColumn" select="altova:BuildTableIndexInfo_ActiveRowSpans_SingleColumn($altova:seqRowSpans, $altova:nodeCurrentRow, $altova:nColumn, $altova:nCellInCurrentRow)" as="xs:integer?"/>
				<xsl:sequence select="$altova:nRowSpanForCurrentColumn"/>
				<xsl:variable name="altova:nCellInCurrentRow_New" select="if ($altova:seqRowSpans[$altova:nColumn] eq 0 and $altova:nColSpanInCellRemaining eq 1) then $altova:nCellInCurrentRow + 1 else $altova:nCellInCurrentRow" as="xs:integer"/>
				<xsl:variable name="altova:nColSpanInCell_New" select="if ($altova:seqRowSpans[$altova:nColumn] eq 0 and $altova:nCellInCurrentRow eq $altova:nCellInCurrentRow_New) then $altova:nColSpanInCellRemaining - 1 else if (empty(altova:GetCellFromRow($altova:nodeCurrentRow, $altova:nCellInCurrentRow_New))) then 1 else altova:col-span(altova:GetCellFromRow($altova:nodeCurrentRow, $altova:nCellInCurrentRow_New))" as="xs:integer"/>
				<xsl:variable name="altova:seqRowSpansForFollowingColumns" select="altova:BuildTableIndexInfo_ActiveRowSpans_Recursive($altova:seqRowSpans, $altova:nodeCurrentRow, $altova:nColumn + 1, $altova:nCellInCurrentRow_New, $altova:nColSpanInCell_New)" as="xs:integer*"/>
				<xsl:sequence select="$altova:seqRowSpansForFollowingColumns"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:function>
	<xsl:function name="altova:BuildTableIndexInfo_ActiveRowSpans_SingleColumn" as="xs:integer?" xpath-default-namespace="">
		<xsl:param name="altova:seqRowSpans" as="xs:integer*"/>
		<xsl:param name="altova:nodeCurrentRow" as="node()"/>
		<xsl:param name="altova:nColumn" as="xs:integer"/>
		<xsl:param name="altova:nCellInCurrentRow" as="xs:integer"/>
		<xsl:choose>
			<xsl:when test="$altova:seqRowSpans[$altova:nColumn] gt 0">
				<xsl:sequence select="$altova:seqRowSpans[$altova:nColumn] - 1"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:variable name="altova:nodeCell" select="altova:GetCellFromRow($altova:nodeCurrentRow, $altova:nCellInCurrentRow)" as="node()"/>
				<xsl:variable name="altova:nRowSpan" select="altova:GetRowspanFromCell($altova:nodeCell) - 1" as="xs:integer"/>
				<xsl:sequence select="$altova:nRowSpan"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:function>
	<xsl:function name="altova:GetChartYValuesForSingleSeries">
		<xsl:param name="seqCategoryLeafPos" as="node()*"/>
		<xsl:param name="nodeSeriesLeafPos" as="node()"/>
		<xsl:param name="bValuesInCategory" as="xs:boolean"/>
		<xsl:for-each select="$seqCategoryLeafPos">
			<xsl:element name="altova:Value">
				<xsl:value-of select="altova:GetChartYValueForSingleSeriesPos($nodeSeriesLeafPos, ., $bValuesInCategory)"/>
			</xsl:element>
		</xsl:for-each>
	</xsl:function>
	<xsl:function name="altova:GetChartYValueForSingleSeriesPos">
		<xsl:param name="nodeSeriesLeafPos" as="node()"/>
		<xsl:param name="nodeCategoryLeafPos" as="node()"/>
		<xsl:param name="bValuesInCategory" as="xs:boolean"/>
		<xsl:variable name="altova:seqCategoryContextIds" select="$nodeCategoryLeafPos/altova:Context/@altova:ContextId" as="xs:string*"/>
		<xsl:variable name="altova:seqSeriesContextIds" select="$nodeSeriesLeafPos/altova:Context/@altova:ContextId" as="xs:string*"/>
		<xsl:variable name="altova:sCommonContextId" select="for $i in $altova:seqCategoryContextIds return if (some $j in $altova:seqSeriesContextIds satisfies $i eq $j) then $i else ()" as="xs:string*"/>
		<xsl:choose>
			<xsl:when test="count($altova:sCommonContextId) gt 1">
				<xsl:message select="concat('Found several values instead of a single one (contexts: ', string-join($altova:sCommonContextId, ', '), ').')" terminate="yes"/>
			</xsl:when>
			<xsl:when test="count($altova:sCommonContextId) lt 1">
				<xsl:message select="concat('XBRL Chart: Info: No value found for position labeled &quot;', $nodeCategoryLeafPos/@altova:sLabel, '&quot;')" terminate="no"/>
				<xsl:sequence select="'altova:no-value'"/>
			</xsl:when>
			<xsl:when test="$bValuesInCategory">
				<xsl:sequence select="xs:string($nodeCategoryLeafPos/altova:Context[@altova:ContextId eq $altova:sCommonContextId]/@altova:Value)"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:sequence select="xs:string($nodeSeriesLeafPos/altova:Context[@altova:ContextId eq $altova:sCommonContextId]/@altova:Value)"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:function>
	<xsl:function name="altova:GetChartLabelForPos" as="xs:string">
		<xsl:param name="nodeParam" as="node()"/>
		<xsl:value-of select="string-join($nodeParam/ancestor-or-self::altova:Pos/@altova:sLabel, ' ')"/>
	</xsl:function>
	<xsl:function name="altova:convert-length-to-pixel" as="xs:decimal">
		<xsl:param name="altova:length"/>
		<xsl:variable name="normLength" select="normalize-space($altova:length)"/>
		<xsl:choose>
			<xsl:when test="ends-with($normLength, 'px')">
				<xsl:value-of select="substring-before($normLength, 'px')"/>
			</xsl:when>
			<xsl:when test="ends-with($normLength, 'in')">
				<xsl:value-of select="xs:decimal(substring-before($normLength, 'in')) * $altova:nPxPerIn"/>
			</xsl:when>
			<xsl:when test="ends-with($normLength, 'cm')">
				<xsl:value-of select="xs:decimal(substring-before($normLength, 'cm')) * $altova:nPxPerIn div 2.54"/>
			</xsl:when>
			<xsl:when test="ends-with($normLength, 'mm')">
				<xsl:value-of select="xs:decimal(substring-before($normLength, 'mm')) * $altova:nPxPerIn div 25.4"/>
			</xsl:when>
			<xsl:when test="ends-with($normLength, 'pt')">
				<xsl:value-of select="xs:decimal(substring-before($normLength, 'pt')) * $altova:nPxPerIn div 72.0"/>
			</xsl:when>
			<xsl:when test="ends-with($normLength, 'pc')">
				<xsl:value-of select="xs:decimal(substring-before($normLength, 'pc')) * $altova:nPxPerIn div 6.0"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$normLength"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:function>
	<xsl:function name="altova:convert-length-to-mm" as="xs:decimal">
		<xsl:param name="altova:length"/>
		<xsl:variable name="normLength" select="normalize-space($altova:length)"/>
		<xsl:choose>
			<xsl:when test="ends-with($normLength, 'px')">
				<xsl:value-of select="xs:decimal(substring-before($normLength, 'px')) div $altova:nPxPerIn * 25.4"/>
			</xsl:when>
			<xsl:when test="ends-with($normLength, 'in')">
				<xsl:value-of select="xs:decimal(substring-before($normLength, 'in')) * 25.4"/>
			</xsl:when>
			<xsl:when test="ends-with($normLength, 'cm')">
				<xsl:value-of select="xs:decimal(substring-before($normLength, 'cm')) * 10"/>
			</xsl:when>
			<xsl:when test="ends-with($normLength, 'mm')">
				<xsl:value-of select="substring-before($normLength, 'mm') "/>
			</xsl:when>
			<xsl:when test="ends-with($normLength, 'pt')">
				<xsl:value-of select="xs:decimal(substring-before($normLength, 'pt')) * 25.4 div 72.0"/>
			</xsl:when>
			<xsl:when test="ends-with($normLength, 'pc')">
				<xsl:value-of select="xs:decimal(substring-before($normLength, 'pc')) * 25.4 div 6.0"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="number($normLength) div $altova:nPxPerIn * 25.4"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:function>
	<xsl:variable name="altova:nDefaultFontSizePt" as="xs:integer" select="12"/>
	<xsl:variable name="altova:nCmPerIn" as="xs:double" select="2.54"/>
	<xsl:variable name="altova:nPercentPerEm" as="xs:integer" select="100"/>
	<xsl:variable name="altova:nPercentPerEx" as="xs:integer" select="50"/>
	<xsl:variable name="altova:nPtPerPc" as="xs:integer" select="12"/>
	<xsl:variable name="altova:nPtPerIn" as="xs:integer" select="72"/>
	<xsl:template match="altova:Footnote" mode="second-step">
		<fo:footnote>
			<xsl:variable name="altova:nodeDocumentRoot" as="node()" select="if (ancestor::altova:result-document) then ancestor::altova:result-document[1] else /altova:main-document"/>
			<fo:inline>
				<xsl:copy-of select="@*"/>
				<fo:inline vertical-align="super" font-size="8">
					<xsl:number format="1" level="any" count="altova:Footnote[some $anc in ancestor::* satisfies $anc is $altova:nodeDocumentRoot]"/>
				</fo:inline>
			</fo:inline>
			<fo:footnote-body>
				<fo:block>
					<xsl:copy-of select="@*"/>
					<fo:inline vertical-align="super" font-size="8">
						<xsl:number format="1" level="any" count="altova:Footnote[some $anc in ancestor::* satisfies $anc is $altova:nodeDocumentRoot]"/>
					</fo:inline>
					<xsl:apply-templates mode="#current"/>
				</fo:block>
			</fo:footnote-body>
		</fo:footnote>
	</xsl:template>
	<xsl:function name="altova:MapLengthUnitEmExPercentToPointsUnrounded" as="xs:double">
		<xsl:param name="sLength" as="xs:string"/>
		<xsl:sequence select="altova:MapLengthUnitToPointsUnroundedCore($sLength, true(), true())"/>
	</xsl:function>
	<xsl:function name="altova:MapLengthUnitEmExPercentToPointsUnrounded_AbsentOk" as="xs:double">
		<xsl:param name="sLength" as="xs:string?"/>
		<xsl:choose>
			<xsl:when test="not($sLength)">0</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="altova:MapLengthUnitEmExPercentToPointsUnrounded($sLength)"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:function>
	<xsl:function name="altova:MapLengthUnitEmExToPointsUnrounded" as="xs:double">
		<xsl:param name="sLength" as="xs:string"/>
		<xsl:sequence select="altova:MapLengthUnitToPointsUnroundedCore($sLength, true(), false())"/>
	</xsl:function>
	<xsl:function name="altova:MapLengthUnitEmExToPointsUnrounded_AbsentOk" as="xs:double">
		<xsl:param name="sLength" as="xs:string?"/>
		<xsl:choose>
			<xsl:when test="not($sLength)">0</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="altova:MapLengthUnitEmExToPointsUnrounded($sLength)"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:function>
	<xsl:function name="altova:MapLengthUnitPercentToPointsUnrounded" as="xs:double">
		<xsl:param name="sLength" as="xs:string"/>
		<xsl:sequence select="altova:MapLengthUnitToPointsUnroundedCore($sLength, false(), true())"/>
	</xsl:function>
	<xsl:function name="altova:MapLengthUnitPercentToPointsUnrounded_AbsentOk" as="xs:double">
		<xsl:param name="sLength" as="xs:string?"/>
		<xsl:choose>
			<xsl:when test="not($sLength)">0</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="altova:MapLengthUnitPercentToPointsUnrounded($sLength)"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:function>
	<xsl:function name="altova:MapLengthUnitToPointsUnrounded" as="xs:double">
		<xsl:param name="sLength" as="xs:string"/>
		<xsl:sequence select="altova:MapLengthUnitToPointsUnroundedCore($sLength, false(), false())"/>
	</xsl:function>
	<xsl:function name="altova:MapLengthUnitToPointsUnrounded_AbsentOk" as="xs:double">
		<xsl:param name="sLength" as="xs:string?"/>
		<xsl:choose>
			<xsl:when test="not($sLength)">0</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="altova:MapLengthUnitToPointsUnrounded($sLength)"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:function>
	<xsl:function name="altova:MapLengthUnitToPointsUnroundedCore" as="xs:double">
		<xsl:param name="sLength" as="xs:string"/>
		<xsl:param name="bAcceptEmEx" as="xs:boolean"/>
		<xsl:param name="bAcceptPercent" as="xs:boolean"/>
		<xsl:variable name="sLengthNormalized" as="xs:string" select="normalize-space($sLength)"/>
		<xsl:choose>
			<xsl:when test="matches($sLengthNormalized, '^\d+(\.\d+)?[a-zA-Z%]+$')">
				<xsl:variable name="nValue" select="number(replace($sLengthNormalized, '([a-zA-Z%])+', ''))"/>
				<xsl:variable name="sUnit" select="replace($sLengthNormalized, '(\d+(\.\d+)?)', '')"/>
				<xsl:choose>
					<xsl:when test="$sUnit = 'cm'">
						<xsl:value-of select="altova:MapUnitCmToPt($nValue)"/>
					</xsl:when>
					<xsl:when test="$sUnit = 'in'">
						<xsl:value-of select="altova:MapUnitInToPt($nValue)"/>
					</xsl:when>
					<xsl:when test="$sUnit = 'mm'">
						<xsl:value-of select="altova:MapUnitMmToPt($nValue)"/>
					</xsl:when>
					<xsl:when test="$sUnit = 'pc'">
						<xsl:value-of select="altova:MapUnitPcToPt($nValue)"/>
					</xsl:when>
					<xsl:when test="$sUnit = 'pt'">
						<xsl:value-of select="$nValue"/>
					</xsl:when>
					<xsl:when test="$sUnit = 'px'">
						<xsl:value-of select="altova:MapUnitPxToPt($nValue)"/>
					</xsl:when>
					<xsl:when test="$sUnit = 'em' and $bAcceptEmEx = true()">
						<xsl:value-of select="altova:MapUnitEmToPt($nValue)"/>
					</xsl:when>
					<xsl:when test="$sUnit = 'ex' and $bAcceptEmEx = true()">
						<xsl:value-of select="altova:MapUnitExToPt($nValue)"/>
					</xsl:when>
					<xsl:when test="$sUnit = '%' and $bAcceptPercent = true()">
						<xsl:value-of select="altova:MapUnitPercentToPt($nValue)"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="-1"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="-1"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:function>
	<xsl:function name="altova:MapLengthUnitToPointsWithUnit" as="xs:string">
		<xsl:param name="sLength" as="xs:string"/>
		<xsl:variable name="dPoints" as="xs:double" select="altova:MapLengthUnitToPointsUnroundedCore($sLength, false(), false())"/>
		<xsl:sequence select="concat(xs:string(round($dPoints * 100) div 100), 'pt')"/>
	</xsl:function>
	<xsl:function name="altova:MapLengthUnitToPointsWithUnit_AbsentOk" as="xs:string">
		<xsl:param name="sLength" as="xs:string?"/>
		<xsl:choose>
			<xsl:when test="not($sLength)">0</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="altova:MapLengthUnitToPointsWithUnit($sLength)"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:function>
	<xsl:function name="altova:MapUnitCmToPt" as="xs:double">
		<xsl:param name="dCm" as="xs:double"/>
		<xsl:sequence select="altova:MapUnitInToPt($dCm div $altova:nCmPerIn)"/>
	</xsl:function>
	<xsl:function name="altova:MapUnitEmToPt" as="xs:double">
		<xsl:param name="dEm" as="xs:double"/>
		<xsl:sequence select="altova:MapUnitPercentToPt($dEm * $altova:nPercentPerEm)"/>
	</xsl:function>
	<xsl:function name="altova:MapUnitExToPt" as="xs:double">
		<xsl:param name="dEx" as="xs:double"/>
		<xsl:sequence select="altova:MapUnitPercentToPt($dEx * $altova:nPercentPerEx)"/>
	</xsl:function>
	<xsl:function name="altova:MapUnitInToPt" as="xs:double">
		<xsl:param name="dIn" as="xs:double"/>
		<xsl:sequence select="$dIn * $altova:nPtPerIn"/>
	</xsl:function>
	<xsl:function name="altova:MapUnitMmToPt" as="xs:double">
		<xsl:param name="dMm" as="xs:double"/>
		<xsl:sequence select="altova:MapUnitCmToPt($dMm div 10)"/>
	</xsl:function>
	<xsl:function name="altova:MapUnitPcToPt" as="xs:double">
		<xsl:param name="dPc" as="xs:double"/>
		<xsl:sequence select="$dPc * $altova:nPtPerPc"/>
	</xsl:function>
	<xsl:function name="altova:MapUnitPercentToPt" as="xs:double">
		<xsl:param name="dPercent" as="xs:double"/>
		<xsl:sequence select="$dPercent div 100 * $altova:nDefaultFontSizePt"/>
	</xsl:function>
	<xsl:function name="altova:MapUnitPxToPt" as="xs:double">
		<xsl:param name="dPx" as="xs:double"/>
		<xsl:sequence select="$dPx div $altova:nPxPerIn * $altova:nPtPerIn"/>
	</xsl:function>
	<xsl:function name="altova:Sqrt" as="xs:double">
		<xsl:param name="nValue" as="xs:double"/>
		<xsl:sequence select="altova:SqrtRecursive($nValue, $nValue)"/>
	</xsl:function>
	<xsl:function name="altova:SqrtRecursive" as="xs:double">
		<xsl:param name="nValue" as="xs:double"/>
		<xsl:param name="nApprox" as="xs:double"/>
		<xsl:choose>
			<xsl:when test="abs($nApprox * $nApprox - $nValue) lt 0.01">
				<xsl:sequence select="$nApprox"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:sequence select="altova:SqrtRecursive($nValue, ($nValue div $nApprox + $nApprox) div 2)"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:function>
</xsl:stylesheet>