1 <?xml version="1.0"?> 2 <!-- 3 An experimental Qt Designer form conversion stylesheet. 4 5 Copyright (C) 2005 Paul Boddie <paul@boddie.org.uk> 6 7 This library is free software; you can redistribute it and/or 8 modify it under the terms of the GNU Lesser General Public 9 License as published by the Free Software Foundation; either 10 version 2.1 of the License, or (at your option) any later version. 11 12 This library is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 Lesser General Public License for more details. 16 17 You should have received a copy of the GNU Lesser General Public 18 License along with this library; if not, write to the Free Software 19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 --> 21 <xsl:stylesheet version="1.0" 22 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 23 xmlns:set="http://exslt.org/sets" 24 xmlns:template="http://www.boddie.org.uk/ns/xmltools/template"> 25 26 <xsl:output indent="yes"/> 27 28 29 30 <!-- Start at the top, producing a template file. --> 31 32 <xsl:template match="UI"> 33 <html xmlns="http://www.w3.org/1999/xhtml"> 34 <head> 35 <title><xsl:value-of select="widget/property[@name='caption']/string/text()"/></title> 36 <link xmlns:xlink="http://www.w3.org/1999/xlink" href="styles/styles.css" rel="stylesheet" type="text/css" /> 37 <script type="text/javascript" src="scripts/sarissa.js"> </script> 38 <script type="text/javascript" src="scripts/XSLForms.js"> </script> 39 </head> 40 <body> 41 <xsl:apply-templates select="widget"/> 42 </body> 43 </html> 44 </xsl:template> 45 46 47 48 <!-- Reproduce the layout. --> 49 50 <xsl:template match="grid"> 51 <xsl:variable name="grid" select="."/> 52 <table xmlns="http://www.w3.org/1999/xhtml"> 53 <!-- Get the row numbers in ascending order. --> 54 <xsl:for-each select="set:distinct($grid/*/@row)"> 55 <xsl:sort select="." order="ascending"/> 56 <xsl:variable name="row" select="."/> 57 <tr> 58 <!-- Get all elements in the row, ordered by column number. --> 59 <xsl:for-each select="$grid/*[@row=$row]"> 60 <xsl:sort select="@column" order="ascending"/> 61 <td> 62 <!-- Add colspan and rowspan details. --> 63 <xsl:apply-templates select="@colspan|@rowspan"/> 64 <!-- Transform the element. --> 65 <xsl:apply-templates select="."/> 66 </td> 67 </xsl:for-each> 68 </tr> 69 </xsl:for-each> 70 </table> 71 </xsl:template> 72 73 <xsl:template match="spacer"> 74 </xsl:template> 75 76 <xsl:template match="vbox"> 77 <xsl:apply-templates select="*[not(local-name() = 'property')]"/> 78 </xsl:template> 79 80 <xsl:template match="widget"> 81 <xsl:apply-templates select="property[@name='geometry']"/> 82 <xsl:apply-templates select="*[not(local-name() = 'property')]"/> 83 </xsl:template> 84 85 86 87 <!-- Specific widgets. --> 88 89 <xsl:template match="widget[@class='QComboBox']"> 90 <select xmlns="http://www.w3.org/1999/xhtml"> 91 <xsl:variable name="name-prop" select="property[@name='name']"/> 92 <xsl:attribute name="template:attribute-field"><xsl:value-of select="$name-prop/cstring/text()"/></xsl:attribute> 93 <xsl:attribute name="name"><xsl:value-of select="$name-prop/cstring/text()"/></xsl:attribute> 94 <xsl:apply-templates select="item"/> 95 </select> 96 </xsl:template> 97 98 <xsl:template match="widget[@class='QListBox']"> 99 <select xmlns="http://www.w3.org/1999/xhtml" multiple="multiple"> 100 <xsl:variable name="name-prop" select="property[@name='name']"/> 101 <xsl:attribute name="template:attribute-field"><xsl:value-of select="$name-prop/cstring/text()"/></xsl:attribute> 102 <xsl:attribute name="name"><xsl:value-of select="$name-prop/cstring/text()"/></xsl:attribute> 103 <xsl:apply-templates select="item"/> 104 </select> 105 </xsl:template> 106 107 <xsl:template match="item"> 108 <option xmlns="http://www.w3.org/1999/xhtml"> 109 <xsl:variable name="value-prop" select="property[@name='text']"/> 110 <xsl:attribute name="value"><xsl:value-of select="$value-prop/string/text()"/></xsl:attribute> 111 <xsl:value-of select="$value-prop/string/text()"/> 112 </option> 113 </xsl:template> 114 115 <xsl:template match="widget[@class='QPushButton']"> 116 <input xmlns="http://www.w3.org/1999/xhtml" type="submit"> 117 <xsl:variable name="name-prop" select="property[@name='name']"/> 118 <xsl:variable name="value-prop" select="property[@name='text']"/> 119 <xsl:attribute name="template:attribute-button"><xsl:value-of select="$name-prop/cstring/text()"/></xsl:attribute> 120 <xsl:attribute name="name"><xsl:value-of select="$name-prop/cstring/text()"/></xsl:attribute> 121 <xsl:attribute name="value"><xsl:value-of select="$value-prop/string/text()"/></xsl:attribute> 122 </input> 123 </xsl:template> 124 125 <xsl:template match="widget[@class='QLineEdit']"> 126 <input xmlns="http://www.w3.org/1999/xhtml" type="text"> 127 <xsl:variable name="name-prop" select="property[@name='name']"/> 128 <xsl:variable name="value-prop" select="property[@name='text']"/> 129 <xsl:attribute name="template:attribute-field"><xsl:value-of select="$name-prop/cstring/text()"/></xsl:attribute> 130 <xsl:attribute name="name"><xsl:value-of select="$name-prop/cstring/text()"/></xsl:attribute> 131 <xsl:attribute name="value"><xsl:value-of select="$value-prop/string/text()"/></xsl:attribute> 132 </input> 133 </xsl:template> 134 135 <xsl:template match="widget[@class='QTextEdit']"> 136 <textarea xmlns="http://www.w3.org/1999/xhtml"> 137 <xsl:variable name="name-prop" select="property[@name='name']"/> 138 <xsl:variable name="value-prop" select="property[@name='text']"/> 139 <xsl:attribute name="template:attribute-area"><xsl:value-of select="$name-prop/cstring/text()"/></xsl:attribute> 140 <xsl:attribute name="name"><xsl:value-of select="$name-prop/cstring/text()"/></xsl:attribute> 141 <xsl:value-of select="$value-prop/string/text()"/> 142 </textarea> 143 </xsl:template> 144 145 <xsl:template match="widget[@class='QRadioButton']"> 146 <input xmlns="http://www.w3.org/1999/xhtml" type="radio"> 147 <xsl:variable name="name-prop" select="property[@name='name']"/> 148 <xsl:variable name="value-prop" select="property[@name='text']"/> 149 <xsl:attribute name="template:attribute-field"><xsl:value-of select="$name-prop/cstring/text()"/></xsl:attribute> 150 <xsl:attribute name="name"><xsl:value-of select="$name-prop/cstring/text()"/></xsl:attribute> 151 <xsl:attribute name="value"><xsl:value-of select="$value-prop/string/text()"/></xsl:attribute> 152 </input> 153 </xsl:template> 154 155 156 157 <!-- Geometry. --> 158 159 <xsl:template match="property[@name='geometry']"> 160 <xsl:apply-templates select="rect/*[1]"> 161 <xsl:with-param name="style">position: absolute</xsl:with-param> 162 </xsl:apply-templates> 163 </xsl:template> 164 165 <xsl:template name="make-geometry"> 166 <xsl:param name="style"/> 167 <xsl:variable name="dimension" select="following-sibling::*[1]"/> 168 <xsl:choose> 169 <xsl:when test="not($dimension)"> 170 <xsl:attribute name="style"><xsl:value-of select="$style"/></xsl:attribute> 171 </xsl:when> 172 <xsl:otherwise> 173 <xsl:apply-templates select="$dimension"> 174 <xsl:with-param name="style" select="$style"/> 175 </xsl:apply-templates> 176 </xsl:otherwise> 177 </xsl:choose> 178 </xsl:template> 179 180 <xsl:template match="x"> 181 <xsl:param name="style"/> 182 <xsl:call-template name="make-geometry"> 183 <xsl:with-param name="style"><xsl:value-of select="$style"/>; left: <xsl:value-of select="text()"/>px</xsl:with-param> 184 </xsl:call-template> 185 </xsl:template> 186 187 <xsl:template match="y"> 188 <xsl:param name="style"/> 189 <xsl:call-template name="make-geometry"> 190 <xsl:with-param name="style"><xsl:value-of select="$style"/>; top: <xsl:value-of select="text()"/>px</xsl:with-param> 191 </xsl:call-template> 192 </xsl:template> 193 194 <xsl:template match="width"> 195 <xsl:param name="style"/> 196 <xsl:call-template name="make-geometry"> 197 <xsl:with-param name="style"><xsl:value-of select="$style"/>; width: <xsl:value-of select="text()"/>px</xsl:with-param> 198 </xsl:call-template> 199 </xsl:template> 200 201 <xsl:template match="height"> 202 <xsl:param name="style"/> 203 <xsl:call-template name="make-geometry"> 204 <xsl:with-param name="style"><xsl:value-of select="$style"/>; height: <xsl:value-of select="text()"/>px</xsl:with-param> 205 </xsl:call-template> 206 </xsl:template> 207 208 209 210 <!-- Identification. --> 211 212 <xsl:template match="property[@name='name']"> 213 </xsl:template> 214 215 216 217 <!-- Labels and values. --> 218 219 <xsl:template match="property[@name='text']"> 220 </xsl:template> 221 222 223 224 <!-- Captions. --> 225 226 <xsl:template match="property[@name='caption']"> 227 </xsl:template> 228 229 230 231 <!-- Copy attributes. --> 232 233 <xsl:template match="@*"> 234 <xsl:copy> 235 <xsl:apply-templates select="node()"/> 236 </xsl:copy> 237 </xsl:template> 238 239 </xsl:stylesheet>