cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject cvs commit: cocoon-2.1/src/blocks/woody/samples/resources def2binding.xsl
Date Mon, 08 Sep 2003 20:41:12 GMT
sylvain     2003/09/08 13:41:12

  Added:       src/blocks/woody/samples/resources def2binding.xsl
  Extract a binding file from a form definition. First step at merging the files
  Revision  Changes    Path
  1.1                  cocoon-2.1/src/blocks/woody/samples/resources/def2binding.xsl
  Index: def2binding.xsl
  <?xml version="1.0"?>
    Transforms a form definition file into a binding file. This is an attempt at merging
    these two files in only one.
    To use it, simply load the form bindings from a cocoon: pipeline that applies this stylesheet
    on a form definition. Next step will by to rewrite this directly into Woody's binding
    The binding is created according to the following rules :
    - wb:* attributes on widget definitions lead to the creation of
      - <wb:context> if a @wb:context attribute is found
      - <wb:simple-repeater> if a @wb:parent-path is found on a <wd:repeater>
      - <wb:value> if a @wb:path is found on any wd:* element    
    - if a <wd:binding> is present, its content is copied as is with the @id of the
enclosing widget
    @author Sylvain Wallez
    @version CVS $Id: def2binding.xsl,v 1.1 2003/09/08 20:41:12 sylvain Exp $
  <xsl:template match="wd:*[@wb:context]">
    <wb:context path="{@wb:context}">
      <xsl:for-each select="@*[(local-name(.) != 'context') and (namespace-uri() = '')]">
        <xsl:attribute name="{local-name(.)}"><xsl:value-of select="."/></xsl:attribute>
  <xsl:template match="wd:*[@wb:path]">
    <wb:value id="{@id}">
      <xsl:for-each select="@*[namespace-uri() = '']">
        <xsl:attribute name="{local-name(.)}"><xsl:value-of select="."/></xsl:attribute>
  <xsl:template match="wd:repeater[@wb:parent-path]">
    <wb:simple-repeater id="{@id}">
      <xsl:for-each select="@*[namespace-uri() = '']">
        <xsl:attribute name="{local-name(.)}"><xsl:value-of select="."/></xsl:attribute>
  <xsl:template match="wd:*[wd:binding]">
    <!-- copy the binding element -->
    <xsl:variable name="binding" select="wd:binding/wb:*[1]"/>
    <xsl:element name="{local-name($binding)}" namespace="{namespace-uri($binding)}">
      <xsl:copy-of select="$binding/@*"/>
      <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
      <xsl:copy-of select="$binding/node()"/>
      <!-- and recurse in the widgets while in the binding element -->
  <!-- avoid copying text -->
  <xsl:template match="text()|@*"/>

View raw message