1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/XSLForms/XSL/QtDesigner.xsl Mon Oct 17 23:50:33 2005 +0000
1.3 @@ -0,0 +1,239 @@
1.4 +<?xml version="1.0"?>
1.5 +<!--
1.6 +An experimental Qt Designer form conversion stylesheet.
1.7 +
1.8 +Copyright (C) 2005 Paul Boddie <paul@boddie.org.uk>
1.9 +
1.10 +This library is free software; you can redistribute it and/or
1.11 +modify it under the terms of the GNU Lesser General Public
1.12 +License as published by the Free Software Foundation; either
1.13 +version 2.1 of the License, or (at your option) any later version.
1.14 +
1.15 +This library is distributed in the hope that it will be useful,
1.16 +but WITHOUT ANY WARRANTY; without even the implied warranty of
1.17 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1.18 +Lesser General Public License for more details.
1.19 +
1.20 +You should have received a copy of the GNU Lesser General Public
1.21 +License along with this library; if not, write to the Free Software
1.22 +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1.23 +-->
1.24 +<xsl:stylesheet version="1.0"
1.25 + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
1.26 + xmlns:set="http://exslt.org/sets"
1.27 + xmlns:template="http://www.boddie.org.uk/ns/xmltools/template">
1.28 +
1.29 + <xsl:output indent="yes"/>
1.30 +
1.31 +
1.32 +
1.33 + <!-- Start at the top, producing a template file. -->
1.34 +
1.35 + <xsl:template match="UI">
1.36 + <html xmlns="http://www.w3.org/1999/xhtml">
1.37 + <head>
1.38 + <title><xsl:value-of select="widget/property[@name='caption']/string/text()"/></title>
1.39 + <link xmlns:xlink="http://www.w3.org/1999/xlink" href="styles/styles.css" rel="stylesheet" type="text/css" />
1.40 + <script type="text/javascript" src="scripts/sarissa.js"> </script>
1.41 + <script type="text/javascript" src="scripts/XSLForms.js"> </script>
1.42 + </head>
1.43 + <body>
1.44 + <xsl:apply-templates select="widget"/>
1.45 + </body>
1.46 + </html>
1.47 + </xsl:template>
1.48 +
1.49 +
1.50 +
1.51 + <!-- Reproduce the layout. -->
1.52 +
1.53 + <xsl:template match="grid">
1.54 + <xsl:variable name="grid" select="."/>
1.55 + <table xmlns="http://www.w3.org/1999/xhtml">
1.56 + <!-- Get the row numbers in ascending order. -->
1.57 + <xsl:for-each select="set:distinct($grid/*/@row)">
1.58 + <xsl:sort select="." order="ascending"/>
1.59 + <xsl:variable name="row" select="."/>
1.60 + <tr>
1.61 + <!-- Get all elements in the row, ordered by column number. -->
1.62 + <xsl:for-each select="$grid/*[@row=$row]">
1.63 + <xsl:sort select="@column" order="ascending"/>
1.64 + <td>
1.65 + <!-- Add colspan and rowspan details. -->
1.66 + <xsl:apply-templates select="@colspan|@rowspan"/>
1.67 + <!-- Transform the element. -->
1.68 + <xsl:apply-templates select="."/>
1.69 + </td>
1.70 + </xsl:for-each>
1.71 + </tr>
1.72 + </xsl:for-each>
1.73 + </table>
1.74 + </xsl:template>
1.75 +
1.76 + <xsl:template match="spacer">
1.77 + </xsl:template>
1.78 +
1.79 + <xsl:template match="vbox">
1.80 + <xsl:apply-templates select="*[not(local-name() = 'property')]"/>
1.81 + </xsl:template>
1.82 +
1.83 + <xsl:template match="widget">
1.84 + <xsl:apply-templates select="property[@name='geometry']"/>
1.85 + <xsl:apply-templates select="*[not(local-name() = 'property')]"/>
1.86 + </xsl:template>
1.87 +
1.88 +
1.89 +
1.90 + <!-- Specific widgets. -->
1.91 +
1.92 + <xsl:template match="widget[@class='QComboBox']">
1.93 + <select xmlns="http://www.w3.org/1999/xhtml">
1.94 + <xsl:variable name="name-prop" select="property[@name='name']"/>
1.95 + <xsl:attribute name="template:attribute-field"><xsl:value-of select="$name-prop/cstring/text()"/></xsl:attribute>
1.96 + <xsl:attribute name="name"><xsl:value-of select="$name-prop/cstring/text()"/></xsl:attribute>
1.97 + <xsl:apply-templates select="item"/>
1.98 + </select>
1.99 + </xsl:template>
1.100 +
1.101 + <xsl:template match="widget[@class='QListBox']">
1.102 + <select xmlns="http://www.w3.org/1999/xhtml" multiple="multiple">
1.103 + <xsl:variable name="name-prop" select="property[@name='name']"/>
1.104 + <xsl:attribute name="template:attribute-field"><xsl:value-of select="$name-prop/cstring/text()"/></xsl:attribute>
1.105 + <xsl:attribute name="name"><xsl:value-of select="$name-prop/cstring/text()"/></xsl:attribute>
1.106 + <xsl:apply-templates select="item"/>
1.107 + </select>
1.108 + </xsl:template>
1.109 +
1.110 + <xsl:template match="item">
1.111 + <option xmlns="http://www.w3.org/1999/xhtml">
1.112 + <xsl:variable name="value-prop" select="property[@name='text']"/>
1.113 + <xsl:attribute name="value"><xsl:value-of select="$value-prop/string/text()"/></xsl:attribute>
1.114 + <xsl:value-of select="$value-prop/string/text()"/>
1.115 + </option>
1.116 + </xsl:template>
1.117 +
1.118 + <xsl:template match="widget[@class='QPushButton']">
1.119 + <input xmlns="http://www.w3.org/1999/xhtml" type="submit">
1.120 + <xsl:variable name="name-prop" select="property[@name='name']"/>
1.121 + <xsl:variable name="value-prop" select="property[@name='text']"/>
1.122 + <xsl:attribute name="template:attribute-button"><xsl:value-of select="$name-prop/cstring/text()"/></xsl:attribute>
1.123 + <xsl:attribute name="name"><xsl:value-of select="$name-prop/cstring/text()"/></xsl:attribute>
1.124 + <xsl:attribute name="value"><xsl:value-of select="$value-prop/string/text()"/></xsl:attribute>
1.125 + </input>
1.126 + </xsl:template>
1.127 +
1.128 + <xsl:template match="widget[@class='QLineEdit']">
1.129 + <input xmlns="http://www.w3.org/1999/xhtml" type="text">
1.130 + <xsl:variable name="name-prop" select="property[@name='name']"/>
1.131 + <xsl:variable name="value-prop" select="property[@name='text']"/>
1.132 + <xsl:attribute name="template:attribute-field"><xsl:value-of select="$name-prop/cstring/text()"/></xsl:attribute>
1.133 + <xsl:attribute name="name"><xsl:value-of select="$name-prop/cstring/text()"/></xsl:attribute>
1.134 + <xsl:attribute name="value"><xsl:value-of select="$value-prop/string/text()"/></xsl:attribute>
1.135 + </input>
1.136 + </xsl:template>
1.137 +
1.138 + <xsl:template match="widget[@class='QTextEdit']">
1.139 + <textarea xmlns="http://www.w3.org/1999/xhtml">
1.140 + <xsl:variable name="name-prop" select="property[@name='name']"/>
1.141 + <xsl:variable name="value-prop" select="property[@name='text']"/>
1.142 + <xsl:attribute name="template:attribute-area"><xsl:value-of select="$name-prop/cstring/text()"/></xsl:attribute>
1.143 + <xsl:attribute name="name"><xsl:value-of select="$name-prop/cstring/text()"/></xsl:attribute>
1.144 + <xsl:value-of select="$value-prop/string/text()"/>
1.145 + </textarea>
1.146 + </xsl:template>
1.147 +
1.148 + <xsl:template match="widget[@class='QRadioButton']">
1.149 + <input xmlns="http://www.w3.org/1999/xhtml" type="radio">
1.150 + <xsl:variable name="name-prop" select="property[@name='name']"/>
1.151 + <xsl:variable name="value-prop" select="property[@name='text']"/>
1.152 + <xsl:attribute name="template:attribute-field"><xsl:value-of select="$name-prop/cstring/text()"/></xsl:attribute>
1.153 + <xsl:attribute name="name"><xsl:value-of select="$name-prop/cstring/text()"/></xsl:attribute>
1.154 + <xsl:attribute name="value"><xsl:value-of select="$value-prop/string/text()"/></xsl:attribute>
1.155 + </input>
1.156 + </xsl:template>
1.157 +
1.158 +
1.159 +
1.160 + <!-- Geometry. -->
1.161 +
1.162 + <xsl:template match="property[@name='geometry']">
1.163 + <xsl:apply-templates select="rect/*[1]">
1.164 + <xsl:with-param name="style">position: absolute</xsl:with-param>
1.165 + </xsl:apply-templates>
1.166 + </xsl:template>
1.167 +
1.168 + <xsl:template name="make-geometry">
1.169 + <xsl:param name="style"/>
1.170 + <xsl:variable name="dimension" select="following-sibling::*[1]"/>
1.171 + <xsl:choose>
1.172 + <xsl:when test="not($dimension)">
1.173 + <xsl:attribute name="style"><xsl:value-of select="$style"/></xsl:attribute>
1.174 + </xsl:when>
1.175 + <xsl:otherwise>
1.176 + <xsl:apply-templates select="$dimension">
1.177 + <xsl:with-param name="style" select="$style"/>
1.178 + </xsl:apply-templates>
1.179 + </xsl:otherwise>
1.180 + </xsl:choose>
1.181 + </xsl:template>
1.182 +
1.183 + <xsl:template match="x">
1.184 + <xsl:param name="style"/>
1.185 + <xsl:call-template name="make-geometry">
1.186 + <xsl:with-param name="style"><xsl:value-of select="$style"/>; left: <xsl:value-of select="text()"/>px</xsl:with-param>
1.187 + </xsl:call-template>
1.188 + </xsl:template>
1.189 +
1.190 + <xsl:template match="y">
1.191 + <xsl:param name="style"/>
1.192 + <xsl:call-template name="make-geometry">
1.193 + <xsl:with-param name="style"><xsl:value-of select="$style"/>; top: <xsl:value-of select="text()"/>px</xsl:with-param>
1.194 + </xsl:call-template>
1.195 + </xsl:template>
1.196 +
1.197 + <xsl:template match="width">
1.198 + <xsl:param name="style"/>
1.199 + <xsl:call-template name="make-geometry">
1.200 + <xsl:with-param name="style"><xsl:value-of select="$style"/>; width: <xsl:value-of select="text()"/>px</xsl:with-param>
1.201 + </xsl:call-template>
1.202 + </xsl:template>
1.203 +
1.204 + <xsl:template match="height">
1.205 + <xsl:param name="style"/>
1.206 + <xsl:call-template name="make-geometry">
1.207 + <xsl:with-param name="style"><xsl:value-of select="$style"/>; height: <xsl:value-of select="text()"/>px</xsl:with-param>
1.208 + </xsl:call-template>
1.209 + </xsl:template>
1.210 +
1.211 +
1.212 +
1.213 + <!-- Identification. -->
1.214 +
1.215 + <xsl:template match="property[@name='name']">
1.216 + </xsl:template>
1.217 +
1.218 +
1.219 +
1.220 + <!-- Labels and values. -->
1.221 +
1.222 + <xsl:template match="property[@name='text']">
1.223 + </xsl:template>
1.224 +
1.225 +
1.226 +
1.227 + <!-- Captions. -->
1.228 +
1.229 + <xsl:template match="property[@name='caption']">
1.230 + </xsl:template>
1.231 +
1.232 +
1.233 +
1.234 + <!-- Copy attributes. -->
1.235 +
1.236 + <xsl:template match="@*">
1.237 + <xsl:copy>
1.238 + <xsl:apply-templates select="node()"/>
1.239 + </xsl:copy>
1.240 + </xsl:template>
1.241 +
1.242 +</xsl:stylesheet>