XSLTools

Changeset

330:ab57b4b4dcb9
2005-10-24 paulb raw files shortlog changelog graph [project @ 2005-10-24 15:26:47 by paulb] Added a stylesheet which extracts widgets from Qt Designer files.
XSLForms/XSL/QtDesignerExtract.xsl (file)
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/XSLForms/XSL/QtDesignerExtract.xsl	Mon Oct 24 15:26:47 2005 +0000
     1.3 @@ -0,0 +1,69 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<!--
     1.6 +An experimental Qt Designer widget extractor for use with QWidgetFactory.
     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 +
    1.27 +  <xsl:output indent="yes" omit-xml-declaration="yes"/>
    1.28 +  <xsl:param name="widget-name"/>
    1.29 +
    1.30 +
    1.31 +
    1.32 +  <!-- Start at the top, producing a template file. -->
    1.33 +
    1.34 +  <xsl:template match="UI">
    1.35 +    <xsl:copy>
    1.36 +      <xsl:apply-templates select="@*"/>
    1.37 +      <!-- xsl:copy-of select="class"/>
    1.38 +      <widget class="QWidget">
    1.39 +        <property name="name">
    1.40 +          <cstring><xsl:value-of select="class/text()"/></cstring>
    1.41 +        </property -->
    1.42 +        <xsl:apply-templates select="//widget[property[@name='name' and cstring/text() = $widget-name]]"/>
    1.43 +      <!-- /widget -->
    1.44 +      <xsl:apply-templates select="connections"/>
    1.45 +      <xsl:copy-of select="slots"/>
    1.46 +      <xsl:copy-of select="layoutdefaults"/>
    1.47 +    </xsl:copy>
    1.48 +  </xsl:template>
    1.49 +
    1.50 +  <xsl:template match="widget">
    1.51 +    <xsl:copy>
    1.52 +      <xsl:copy-of select="@class|*"/>
    1.53 +    </xsl:copy>
    1.54 +  </xsl:template>
    1.55 +
    1.56 +  <xsl:template match="connections">
    1.57 +    <xsl:copy>
    1.58 +      <xsl:copy-of select="connection[sender/text() = $widget-name or receiver/text() = $widget-name]"/>
    1.59 +    </xsl:copy>
    1.60 +  </xsl:template>
    1.61 +
    1.62 +
    1.63 +
    1.64 +  <!-- Copy attributes. -->
    1.65 +
    1.66 +  <xsl:template match="@*">
    1.67 +    <xsl:copy>
    1.68 +      <xsl:apply-templates select="node()"/>
    1.69 +    </xsl:copy>
    1.70 +  </xsl:template>
    1.71 +
    1.72 +</xsl:stylesheet>