1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
|
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.1"
xmlns:saxon="http://icl.com/saxon"
extension-element-prefixes="saxon">
<!-- parameter "dir" must be set from the command line: it represents the output directory -->
<!-- this stylesheet uses "preview" mode to process each scene as it is encountered, avoiding -->
<!-- loading the entire document into memory -->
<saxon:preview mode="preview" elements="SCENE PROLOGUE EPILOGUE"/>
<xsl:variable name="backcolor" select="'#FFFFCC'" />
<xsl:variable name="panelcolor" select="'#88FF88'" />
<xsl:variable name="filesep" select="system-property('file.separator')" />
<xsl:param name="dir"/>
<xsl:template match="PLAY">
<xsl:if test="not($dir)">
<xsl:message terminate="yes">Parameter "dir" has not been set</xsl:message>
</xsl:if>
<xsl:document href="{$dir}{$filesep}play.html" method="html">
<HTML>
<HEAD><TITLE><xsl:apply-templates select="TITLE"/></TITLE></HEAD>
<BODY BGCOLOR='{$backcolor}'>
<CENTER>
<H1><xsl:value-of select="TITLE"/></H1>
<H3><xsl:apply-templates select="PLAYSUBT"/></H3>
<I><xsl:apply-templates select="SCNDESCR"/></I>
</CENTER><BR/><BR/>
<TABLE><TR>
<TD WIDTH='350' VALIGN='TOP' BGCOLOR='{$panelcolor}'>
<xsl:apply-templates select="PERSONAE"/>
</TD>
<TD WIDTH='30'></TD>
<TD VALIGN='TOP'>
<xsl:apply-templates select="PROLOGUE | ACT | EPILOGUE"/>
</TD>
</TR></TABLE><HR/>
</BODY></HTML>
</xsl:document>
</xsl:template>
<xsl:template match="ACT/TITLE">
<CENTER><H3>
<xsl:apply-templates/>
</H3></CENTER>
</xsl:template>
<xsl:template match="PLAYSUBT">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="PERSONAE">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="PERSONAE/TITLE">
<CENTER><H3>
<xsl:apply-templates/>
</H3></CENTER>
</xsl:template>
<xsl:template match="PERSONAE/PERSONA">
<TABLE><TR><TD VALIGN="TOP">
<xsl:apply-templates/>
</TD></TR></TABLE>
</xsl:template>
<xsl:template match="PGROUP">
<TABLE><TR><TD WIDTH="160" VALIGN="TOP">
<xsl:apply-templates select="PERSONA"/>
</TD><TD WIDTH="20"></TD>
<TD VALIGN="BOTTOM"><I>
<xsl:apply-templates select="GRPDESCR"/>
</I></TD>
</TR></TABLE>
</xsl:template>
<xsl:template match="PGROUP/PERSONA">
<xsl:apply-templates/>
<BR/>
</xsl:template>
<xsl:template match="PGROUP/GRPDESCR">
<xsl:apply-templates/>
<BR/>
</xsl:template>
<xsl:template match="SCNDESCR">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="ACT">
<HR/>
<xsl:apply-templates/>
<xsl:if test="position()=last()"><HR/></xsl:if>
</xsl:template>
<xsl:template match="SCENE|PROLOGUE|EPILOGUE">
<xsl:variable name="NR"><xsl:number count="SCENE|PROLOGUE|EPILOGUE" level="any"/></xsl:variable>
<A HREF="scene{$NR}.html">
<xsl:value-of select="saxon:getUserData('TITLE')" />
</A><BR/>
</xsl:template>
<xsl:template match="SCENE|PROLOGUE|EPILOGUE" mode="preview">
<xsl:variable name="NR"><xsl:number count="SCENE|PROLOGUE|EPILOGUE" level="any"/></xsl:variable>
<xsl:variable name="play"><xsl:value-of select="ancestor::PLAY/TITLE"/></xsl:variable>
<xsl:variable name="act"><xsl:value-of select="ancestor::ACT/TITLE"/></xsl:variable>
<!-- note that global variables are not available in preview mode -->
<xsl:variable name="backcolor" select="'#FFFFCC'" />
<xsl:variable name="filesep" select="system-property('file.separator')" />
<!-- save the TITLE because it will be needed later to create a hyperlink -->
<xsl:variable name="dummy" select="saxon:setUserData('TITLE', string(TITLE))"/>
<xsl:document href="{$dir}{$filesep}scene{$NR}.html" method="html">
<HTML>
<HEAD>
<TITLE><xsl:value-of select="concat($play, ' ', $act, ': ', TITLE)"/></TITLE>
</HEAD>
<BODY BGCOLOR='{$backcolor}'>
<P>
<A HREF="play.html"><xsl:value-of select="$play"/></A><BR/>
<B><xsl:value-of select="$act"/></B><BR/>
</P>
<xsl:apply-templates/>
</BODY>
</HTML>
</xsl:document>
</xsl:template>
<xsl:template match="SCENE/TITLE | PROLOGUE/TITLE | EPILOGUE/TITLE">
<H1><CENTER>
<xsl:apply-templates/>
</CENTER></H1><HR/>
</xsl:template>
<xsl:template match="SPEECH">
<TABLE><TR>
<TD WIDTH="160" VALIGN="TOP">
<xsl:apply-templates select="SPEAKER"/>
</TD>
<TD VALIGN="TOP">
<xsl:apply-templates select="STAGEDIR|LINE"/>
</TD>
</TR></TABLE>
</xsl:template>
<xsl:template match="SPEAKER">
<B>
<xsl:apply-templates/>
<xsl:if test="not(position()=last())"><BR/></xsl:if>
</B>
</xsl:template>
<xsl:template match="SCENE/STAGEDIR">
<CENTER><H3>
<xsl:apply-templates/>
</H3></CENTER>
</xsl:template>
<xsl:template match="SPEECH/STAGEDIR">
<P><I>
<xsl:apply-templates/>
</I></P>
</xsl:template>
<xsl:template match="LINE/STAGEDIR">
[ <I>
<xsl:apply-templates/>
</I> ]
</xsl:template>
<xsl:template match="SCENE/SUBHEAD">
<CENTER><H3>
<xsl:apply-templates/>
</H3></CENTER>
</xsl:template>
<xsl:template match="SPEECH/SUBHEAD">
<P><B>
<xsl:apply-templates/>
</B></P>
</xsl:template>
<xsl:template match="LINE">
<xsl:apply-templates/>
<BR/>
</xsl:template>
</xsl:stylesheet>
|