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