]> saetta.ns0.it Git - libgtkform/commitdiff
Added xsl to transform gtkform to zakform definition files.
authorAndrea Zagli <azagli@libero.it>
Sat, 30 Jul 2016 08:36:08 +0000 (10:36 +0200)
committerAndrea Zagli <azagli@libero.it>
Sat, 30 Jul 2016 08:36:08 +0000 (10:36 +0200)
Makefile.am
configure.ac
tools/Makefile.am [new file with mode: 0644]
tools/gtk2zak.xsl [new file with mode: 0644]

index 925636921cc79d8340b62a72d0723c31f1e3e312..898d285c4c6c23261fcf8da5f53878cc199d7b64 100644 (file)
@@ -1,6 +1,6 @@
 DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc
 
-SUBDIRS = po libgtkform libgtkformui test docs data
+SUBDIRS = po libgtkform libgtkformui test docs data tools
 
 ACLOCAL_AMFLAGS = -I m4
 
index ffe3a9798c0158d8843f48b81000c85ce92dfa2d..6062f395dbbb9b1fbcbdf9692c563b303d0b57c2 100644 (file)
@@ -107,6 +107,7 @@ AC_CONFIG_FILES([
        libgtkformui/Makefile
        libgtkformui/test/Makefile
        test/Makefile
+       tools/Makefile
        docs/Makefile
        docs/reference/Makefile
        docs/reference/version.xml
diff --git a/tools/Makefile.am b/tools/Makefile.am
new file mode 100644 (file)
index 0000000..f45e2f4
--- /dev/null
@@ -0,0 +1,5 @@
+toolsdir = $(datadir)/$(PACKAGE)/tools
+
+tools_DATA = gtk2zak.xsl
+
+EXTRA_DIST = $(tools_DATA)
diff --git a/tools/gtk2zak.xsl b/tools/gtk2zak.xsl
new file mode 100644 (file)
index 0000000..2a685c4
--- /dev/null
@@ -0,0 +1,50 @@
+<xsl:stylesheet version="1.0"
+xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match="/">
+  <zakform>
+       <xsl:for-each select="gtkform/widget">
+         <element>
+               <xsl:attribute name="type">
+                 <xsl:choose>
+                        <xsl:when test="@type = 'entry'">zak_form_gtk_form_element_entry</xsl:when>
+                        <xsl:when test="@type = 'label'">zak_form_gtk_form_element_label</xsl:when>
+                        <xsl:when test="@type = 'textview'">zak_form_gtk_form_element_textview</xsl:when>
+                        <xsl:when test="@type = 'radio'">zak_form_gtk_form_element_radio</xsl:when>
+                        <xsl:when test="@type = 'checkbox'">zak_form_gtk_form_element_check</xsl:when>
+                 </xsl:choose>
+               </xsl:attribute>
+               <name><xsl:value-of select="field/@name"/></name>
+               <type>
+                       <xsl:choose>
+                       <xsl:when test="field/@type = 'text'">string</xsl:when>
+                       <xsl:when test="field/@type = 'integer'">integer</xsl:when>
+                       <xsl:when test="field/@type = 'datetime'">datetime</xsl:when>
+                       <xsl:when test="field/@type = 'boolean'">boolean</xsl:when>
+                       <xsl:when test="field/@type = 'float'">float</xsl:when>
+                       </xsl:choose>
+               </type>
+               <xsl:if test="@label != ''"><label><xsl:value-of select="@label"/></label></xsl:if>
+               <xsl:if test="field/is-key = 't'"><is-key>TRUE</is-key></xsl:if>
+               <xsl:if test="field/to-load = 'f'"><to-load>FALSE</to-load></xsl:if>
+               <xsl:if test="field/to-save = 'f'"><to-save>FALSE</to-save></xsl:if>
+               <xsl:if test="field/default != ''">
+                 <default-value>
+                 <xsl:choose>
+                       <xsl:when test="field/default = 'now'">@now</xsl:when>
+                       <xsl:otherwise><xsl:value-of select="field/default"/></xsl:otherwise>
+                 </xsl:choose>
+                 </default-value>
+                 </xsl:if>
+               <xsl:if test="return-value != ''"><return-value><xsl:value-of select="return-value"/></return-value></xsl:if>
+               <xsl:if test="field/display-format != ''"><format><xsl:value-of select="field/display-format"/></format></xsl:if>
+               <xsl:if test="field/decimals != ''"><format><xsl:attribute name="decimals"><xsl:value-of select="field/decimals"/></xsl:attribute></format></xsl:if>
+               <xsl:if test="field/trim = 't'"><filter type="zak_form_element_filter_trim"></filter></xsl:if>
+               <xsl:if test="field/obligatory = 't'"><validator type="zak_form_element_validator_notempty"></validator></xsl:if>
+               <xsl:if test="field/@type = 'datetime' and field/display-format != ''"><validator type="zak_form_element_validator_date"><xsl:value-of select="field/display-format"/></validator></xsl:if>
+         </element>
+       </xsl:for-each>
+  </zakform>
+</xsl:template>
+
+</xsl:stylesheet>