Newer
Older
XML / modules / conditional-processing.xml
nstanger on 7 Oct 2011 1 KB - Reformatted code.
<?xml version="1.0" encoding="utf-8"?>

<!--
	Conditional XML processing depending on the target format. It may appear redundant to have two templates, but this is the only way to ensure that the LaTeX template is empty in the HTML style sheet, and vice versa.
		
	Note the assumption that all LaTeX format names include the string 'latex' and all HTML format names include the string 'html'.
	
	@format: the format under which this XML is to be processed. [required]
-->

<stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


	<!--
		Conditional XML processing under for LaTeX output formats.
	-->
	<template name="process-when-latex" match="process-when[ contains( @format, 'latex' ) ]">
		<common formats="/latex/xelatex/">
			<xsl:apply-templates />
		</common>
	</template>
	
	
	<!--
		Conditional XML processing under for HTML output formats.
	-->
	<template name="process-when-html" match="process-when[ contains( @format, 'html' ) ]">
		<common formats="/html/xhtml/">
			<xsl:apply-templates />
		</common>
	</template>


	<!--
		Error handling.
	-->
	<template name="process-when-error" match="process-when[ not( @format ) ]">
		<common>
			<xsl:message terminate="yes">The "process-when" element must include an @format attribute.</xsl:message>
		</common>
	</template>
	
	
</stylesheet>