<?xml version="1.0"?>
<!-- XSLT Document  QXDStylesheet.xsl-->
<!-- This displays the QXD format    -->
<!-- Multiple pages supported    -->
<!-- (c) 2004 Qusoft and QBS Software -->
<!-- Modify by Bruno Guerange ( http://nono40.developpez.com/ ) to be browser independant -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!-- root template -->
<xsl:template match ="QXDocument">
<html>
<head>
  <title>QXD Document display</title>
</head>
<body>
   <xsl:apply-templates select="Header"/>
   <xsl:apply-templates select="Page"/>
</body>
</html>
</xsl:template>

<!-- header template -->
<xsl:template match="Header">
  <xsl:variable name = "pageheight"><xsl:value-of select="@Pageheight" /></xsl:variable>
</xsl:template>


<!-- page template -->
<xsl:template match="Page">
  <xsl:variable name = "decalpage" select="(number(@Number)-1.0)*/QXDocument/Header/@Pageheight"/>

  <xsl:apply-templates select="Item">
	<xsl:with-param name="decaly" select="$decalpage"/>
  </xsl:apply-templates>
</xsl:template>


<!-- item template -->
<xsl:template match="Item">
  <xsl:param name="decaly">0</xsl:param>
  <xsl:variable name = "itemtype"><xsl:value-of select="@Type" /></xsl:variable>
  <xsl:variable name = "xpos"><xsl:value-of select="@XPos" /></xsl:variable>
  <xsl:variable name = "ypos"><xsl:value-of select="@YPos" /></xsl:variable>
  <xsl:variable name = "fcolor"><xsl:value-of select="@Color" /></xsl:variable>
  <xsl:if test="$itemtype = 'Text'">
	 <xsl:variable name = "fsize"><xsl:value-of select="@Height" /></xsl:variable>
	 <xsl:variable name = "fname"><xsl:value-of select="@Font" /></xsl:variable>
	 <xsl:variable name = "fweight"><xsl:value-of select="@Weight" /></xsl:variable>
	 <!-- this is the important line - makes a HTML div tag -->
	 <DIV style="position:absolute;left:{$xpos}mm;
	 top:{string($ypos+$decaly)}mm;font-family:{$fname};font-size:{$fsize}pt;font-weight:{$fweight};
	 color:{concat('#',substring($fcolor,3,6))}"><xsl:value-of select="." /></DIV>
  </xsl:if>

  <xsl:if test="$itemtype = 'Graphic'">

	 <xsl:variable name = "shape"><xsl:value-of select="@Shape" /></xsl:variable>
	 <xsl:variable name = "width"><xsl:value-of select="@Width" /></xsl:variable>
	 <xsl:variable name = "height"><xsl:value-of select="@Height" /></xsl:variable>
	 <xsl:variable name = "linewidth"><xsl:value-of select="@Linewidth" /></xsl:variable>
     <xsl:variable name = "filltype"><xsl:value-of select="@FillType" /></xsl:variable>
     <xsl:if test="$shape='0'" >
       <xsl:if test="$filltype='Fill'" >
		 <DIV style="position:absolute;left:{$xpos}mm;top:{string($ypos+$decaly)}mm;width:{$width}mm;height:{$height}mm;
		 background-color:{concat('#',substring($fcolor,3,6))};"> </DIV>
	   </xsl:if>
	   <xsl:if test="$filltype='Outline'" >
		 <DIV style="position:absolute;left:{$xpos}mm;top:{string($ypos+$decaly)}mm;width:{$width}mm;height:{$height}mm;
		 border-style:solid;border-width:1;border-color:{$fcolor};"> </DIV>
	   </xsl:if>
	 </xsl:if>
	 <xsl:if test="$shape='2'" >
		 <DIV style="position:absolute;left:{$xpos}mm;top:{string($ypos+($decaly)-2.0)}mm;width:{$width}mm;
		   height:8mm;background-color:transparent;">
		   <hr width="{string(number($width)*3.77)}" size="{string(number($linewidth)*3.77)}" color="{concat('#',substring($fcolor,3,6))}"/>
		 </DIV>
	 </xsl:if>
	 <xsl:if test="$shape='3'" >
		 <DIV style="position:absolute;left:{$xpos}mm;top:{string($ypos+$decaly)}mm;width:{$linewidth}mm;
		 height:{$height}mm;
		 background-color:{concat('#',substring($fcolor,3,6))};"></DIV>
	 </xsl:if>
  </xsl:if>

  <xsl:if test="$itemtype = 'Image'">
	 <xsl:variable name = "width"><xsl:value-of select="@Width" /></xsl:variable>
	 <xsl:variable name = "height"><xsl:value-of select="@Height" /></xsl:variable>
	 <xsl:variable name = "xscale"><xsl:value-of select="@Xscale" /></xsl:variable>
	 <xsl:variable name = "yscale"><xsl:value-of select="@Yscale" /></xsl:variable>
	 <xsl:variable name = "imgsrc"><xsl:value-of select="." /></xsl:variable>
	 <DIV style="position:absolute;left:{$xpos}mm;top:{string($ypos+$decaly)}mm;width:{$width*$xscale}mm;height:{$height*$yscale}mm;
	 background-color:#808080;"><IMG style="width:{$width*$xscale}mm;height:{$height*$yscale}mm;" SRC="{$imgsrc}"> </IMG></DIV>
  </xsl:if>
</xsl:template>

</xsl:stylesheet>

