Kwaff Examples

last update: $Date: 2005-06-17 12:23:47 +0900 (Fri, 17 Jun 2005) $
Table of Contents:

XHTML

README.kwaff
? encoding		= UTF-8
? doctype		= @xhtml

* html
  - lang		= en

  * head

    * title		= README
    * meta
      - http-equiv	= Content-Type
      - content		= text/xhtml

  * body

    * h1 = What is Kwaff?
    * p
      . Kwaff is a simplified and structured data format.
      . See examples directory for detail.
    * p
      . Name of 'Kwaff' is derived from "kwa's friendly formatter".

    * h1 = Installation
    * p
      . There are two ways to install Kwaff.
    * dl
      * dt = If you can be root user:
      * dd
        * pre = <<<END
          $ ruby setup.rb config
          $ ruby setup.rb setup
          $ su
          # ruby setup.rb install
          END
      * dt = If you cannot be root user:
      * dd
        * pre = <<<END
          ### copy command file to appropriate directory.
          $ cp bin/kwaff  $HOME/bin/
          ### copy library files to appropriate directory.
          $ mkdir -p $HOME/lib/ruby
          $ cp -r lib/kwaff* $HOME/lib/ruby
          ### set environment variable RUBYLIB
          $ export RUBYLIB=$HOME/lib/ruby
          END

    * h1 = Usage
    * p
      . You can convert Kwaff document into XML document.
    * pre
      . $ kwaff example.kwaff > example.xml
    * p
      . You can also convert XML document into Kwaff document.
    * pre
      . $ kwaff -r example.xml > example.kwaff
    * p
      . Type `kwaff -h' for detail.

    * h1 = Manifest
    * dl
      * dt = README.txt
      * dd =      This file.
      * dt = COPYING
      * dd =      GPL file.
      * dt = CangeLog.txt
      * dd =      Change log file.
      * dt = setup.rb
      * dd =      Setup file for installation.
      * dt = bin/kwaff
      * dd =      Command file.
      * dt = lib/kwaff.rb, lib/kwaff/*.rb
      * dd =      Library file.
      * dt = examples/*
      * dd =      Examples of Kwaff.
      * dt = doc/users-guide.html
      * dd =      Users' Guide.
      * dt = test/test.rb, test/ex*.*
      * dd =      Unit test script and test data.

    * h1 = License
    * p  = GPL (GNU General Public License) ver 2.

    * h1 = Author
    * p  = kwatch <kwa.at.kuwata-lab.com>
convert:
$ kwaff README.kwaff > README.xhtml
README.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en">

  <head>

    <title>README</title>
    <meta http-equiv="Content-Type" content="text/xhtml"/>

  </head>

  <body>

    <h1>What is Kwaff?</h1>
    <p>Kwaff is a simplified and structured data format.
See examples directory for detail.</p>
    <p>Name of 'Kwaff' is derived from "kwa's friendly formatter".</p>

    <h1>Installation</h1>
    <p>There are two ways to install Kwaff.</p>
    <dl>
      <dt>If you can be root user:</dt>
      <dd>
        <pre>$ ruby setup.rb config
$ ruby setup.rb setup
$ su
# ruby setup.rb install</pre>
      </dd>
      <dt>If you cannot be root user:</dt>
      <dd>
        <pre>### copy command file to appropriate directory.
$ cp bin/kwaff  $HOME/bin/
### copy library files to appropriate directory.
$ mkdir -p $HOME/lib/ruby
$ cp -r lib/kwaff* $HOME/lib/ruby
### set environment variable RUBYLIB
$ export RUBYLIB=$HOME/lib/ruby</pre>
      </dd>
    </dl>

    <h1>Usage</h1>
    <p>You can convert Kwaff document into XML document.</p>
    <pre>$ kwaff example.kwaff &gt; example.xml</pre>
    <p>You can also convert XML document into Kwaff document.</p>
    <pre>$ kwaff -r example.xml &gt; example.kwaff</pre>
    <p>Type `kwaff -h' for detail.</p>

    <h1>Manifest</h1>
    <dl>
      <dt>README.txt</dt>
      <dd>This file.</dd>
      <dt>COPYING</dt>
      <dd>GPL file.</dd>
      <dt>CangeLog.txt</dt>
      <dd>Change log file.</dd>
      <dt>setup.rb</dt>
      <dd>Setup file for installation.</dd>
      <dt>bin/kwaff</dt>
      <dd>Command file.</dd>
      <dt>lib/kwaff.rb, lib/kwaff/*.rb</dt>
      <dd>Library file.</dd>
      <dt>examples/*</dt>
      <dd>Examples of Kwaff.</dd>
      <dt>doc/users-guide.html</dt>
      <dd>Users' Guide.</dd>
      <dt>test/test.rb, test/ex*.*</dt>
      <dd>Unit test script and test data.</dd>
    </dl>

    <h1>License</h1>
    <p>GPL (GNU General Public License) ver 2.</p>

    <h1>Author</h1>
    <p>kwatch &lt;kwa.at.kuwata-lab.com&gt;</p>

  </body>

</html>

Servlet

web.kwaff
//
// example for web.xml of J2EE Application
//
? encoding   = ISO-8859-1
? doctype    = @web-app23

* web-app

  # Servlet Definition
  * servlet
    * servlet-name	= Hello
    * servlet-class	= my.HelloServlet
    * init-param
      * param-name	= request.encoding
      * param-value	= Windows-31J
      * description	= encoding of http request
  * servlet
    * servlet-name	= action
    * servlet-class	= org.apache.struts.action.ActionServlet
    * load-on-startup	= 2

  # Servlet Mappings
  * servlet-mapping
    * servlet-name	= Hello
    * url-pattern	= /hello
  * servlet-maping
    * servlet-name	= action
    * url-pattern	= *.do

  # Taglib
  * taglib
    * taglib-uri	= /tags/struts-bean
    * taglib-location	= /WEB-INF/struts-bean.tld
  * taglib
    * taglib-uri	= /tags/struts-tiles
    * taglib-location	= /WEB-INF/struts-tiles.tld

convert:
$ kwaff web.kwaff > web.xml
web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
	"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>

  <!-- Servlet Definition -->
  <servlet>
    <servlet-name>Hello</servlet-name>
    <servlet-class>my.HelloServlet</servlet-class>
    <init-param>
      <param-name>request.encoding</param-name>
      <param-value>Windows-31J</param-value>
      <description>encoding of http request</description>
    </init-param>
  </servlet>
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <load-on-startup>2</load-on-startup>
  </servlet>

  <!-- Servlet Mappings -->
  <servlet-mapping>
    <servlet-name>Hello</servlet-name>
    <url-pattern>/hello</url-pattern>
  </servlet-mapping>
  <servlet-maping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-maping>

  <!-- Taglib -->
  <taglib>
    <taglib-uri>/tags/struts-bean</taglib-uri>
    <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
  </taglib>
  <taglib>
    <taglib-uri>/tags/struts-tiles</taglib-uri>
    <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
  </taglib>

</web-app>

Ant

build.kwaff
//
// from http://ant.apache.org/manual/using.html#example
//
* project
  - name = MyProject
  - default = dist
  - basedir = .
  * description = simple example build file

  # set global properties for this build
  * property
    - name = src
    - location = src
  * property
    - name = build
    - location = build
  * property
    - name = dist
    - location = dist

  * target
    - name = init
    # Create the time stamp
    * tstamp
    # Create the build directory structure used by compile
    * mkdir
      - dir = ${build}

  * target
    - name = compile
    - depends = init
    - description = compile the source
    # Compile the java code from ${src} into ${build}
    * javac
      - srcdir = ${src}
      - destdir = ${build}

  * target
    - name = dist
    - depends = compile
    - description = generate the distribution
    # Create the distribution directory
    * mkdir
      - dir = ${dist}/lib
    # Put everything in ${build} into the MyProject-${DSTAMP}.jar file
    * jar
      - jarfile = ${dist}/lib/MyProject-${DSTAMP}.jar
      - basedir = ${build}

  * target
    - name = clean
    - description = clean up
    # Delete the ${build} and ${dist} directory trees
    * delete
      - dir = ${build}
    * delete
      - dir = ${dist}
convert:
$ kwaff build.kwaff > build.xml
build.xml
<?xml version="1.0"?>
<project name="MyProject" default="dist" basedir=".">
  <description>simple example build file</description>

  <!-- set global properties for this build -->
  <property name="src" location="src"/>
  <property name="build" location="build"/>
  <property name="dist" location="dist"/>

  <target name="init">
    <!-- Create the time stamp -->
    <tstamp/>
    <!-- Create the build directory structure used by compile -->
    <mkdir dir="${build}"/>
  </target>

  <target name="compile" depends="init" description="compile the source">
    <!-- Compile the java code from ${src} into ${build} -->
    <javac srcdir="${src}" destdir="${build}"/>
  </target>

  <target name="dist" depends="compile" description="generate the distribution">
    <!-- Create the distribution directory -->
    <mkdir dir="${dist}/lib"/>
    <!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
    <jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/>
  </target>

  <target name="clean" description="clean up">
    <!-- Delete the ${build} and ${dist} directory trees -->
    <delete dir="${build}"/>
    <delete dir="${dist}"/>
  </target>
</project>

Spring

applicationContext.kwaff
//
// from spring-framework-1.2.1/samples/jpetstore/war/WEB-INF/applicationContext.xml
//
? encoding = UTF-8
? doctype  = @spring-beans

* beans

  # Application context definition for JPetStore's business layer.
  # Contains bean references to the transaction manager and to the DAOs in
  # dataAccessContext-local/jta.xml (see web.xml's "contextConfigLocation").

  
  # ========================= GENERAL DEFINITIONS =========================

  # Configurer that replaces ${...} placeholders with values from properties files
  # (in this case, mail and JDBC related properties)
  * bean
    - id		= propertyConfigurer
    - class		= org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
    * property
      - name		= locations
      * list
        * value		= WEB-INF/mail.properties
        * value		= WEB-INF/jdbc.properties

  # MailSender used by EmailAdvice
  * bean
    - id		= mailSender
    - class		= org.springframework.mail.javamail.JavaMailSenderImpl
    * property
      - name		= host
      - value		= ${mail.host}


  # ========================= BUSINESS OBJECT DEFINITIONS ========================

  # Generic validator for Account objects, to be used for example by the Spring web tier
  * bean
    - id		= accountValidator
    - class		= org.springframework.samples.jpetstore.domain.logic.AccountValidator

  # Generic validator for Order objects, to be used for example by the Spring web tier
  * bean
    - id		= orderValidator
    - class		= org.springframework.samples.jpetstore.domain.logic.OrderValidator

  # AOP advice used to send confirmation email after order has been submitted
  * bean
    - id 		= emailAdvice
    - class		= org.springframework.samples.jpetstore.domain.logic.SendOrderConfirmationEmailAdvice
    * property
      - name		= mailSender
      * ref
        - local		= mailSender

  # Advisor encapsulating email advice
  * bean
    - id		= emailAdvisor
    - class		= org.springframework.aop.support.RegexpMethodPointcutAdvisor
    * constructor-arg
      * ref
        - local		= emailAdvice
    * property
      - name		= pattern
      * value		= .*insertOrder.*

  # A parent bean definition which is a base definition for transaction proxies.
  # It's marked as abstract, since it's not supposed to be instantiated itself.
  # We set shared transaction attributes here, following our naming patterns.
  # The attributes can still be overridden in child bean definitions.
  * bean
    - id		= baseTransactionProxy
    - class		= org.springframework.transaction.interceptor.TransactionProxyFactoryBean
    - abstract		= true
    * property
      - name		= transactionManager
      * ref
        - bean		= transactionManager
    * property
      - name		= transactionAttributes
      * props
        * prop		= PROPAGATION_REQUIRED
          - key		= insert*
        * prop		= PROPAGATION_REQUIRED
          - key		= update*
        * prop		= PROPAGATION_REQUIRED,readOnly
          - key		= *

  # JPetStore primary business object (default implementation), as an inner bean wrapped
  # by an outer transactional proxy. The two bean definitions could have been separate,
  # but this is cleaner as there is no need to ever access the unwrapped object.
  * bean
    - id		= petStore
    - parent		= baseTransactionProxy
    * property
      - name		= target
      * bean
        - class		= org.springframework.samples.jpetstore.domain.logic.PetStoreImpl
        * property
          - name	= accountDao
          * ref
            - bean	= accountDao
        * property
          - name	= categoryDao
          * ref
            - bean	= categoryDao
        * property
          - name	= productDao
          * ref
            - bean	= productDao
        * property
          - name	= itemDao
          * ref
            - bean	= itemDao
        * property
          - name	= orderDao
          * ref
            - bean	= orderDao
    # Uncomment the following in order to enable mail sending aspect
    * property
      - name		= postInterceptors
      * list
        * ref
          - local	= emailAdvisor


  # ========================= REMOTE EXPORTER DEFINITIONS ========================

  #  RMI exporter for the JPetStore OrderService
  #  Commented out by default to avoid conflicts with EJB containers
  * bean
    - id		= order-rmi
    - class		= org.springframework.remoting.rmi.RmiServiceExporter
    * property
      - name		= service
      * ref
        - local		= petStore
    * property
      - name		= serviceInterface
      * value		= org.springframework.samples.jpetstore.domain.logic.OrderService
    * property
      - name		= serviceName
      * value		= order
    * property
      - name		= registryPort
      * value		= 1099
convert:
$ kwaff applicationContext.kwaff > applicationContext.xml
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
	"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>

  <!-- Application context definition for JPetStore's business layer. -->
  <!-- Contains bean references to the transaction manager and to the DAOs in -->
  <!-- dataAccessContext-local/jta.xml (see web.xml's "contextConfigLocation"). -->


  <!-- ========================= GENERAL DEFINITIONS ========================= -->

  <!-- Configurer that replaces ${...} placeholders with values from properties files -->
  <!-- (in this case, mail and JDBC related properties) -->
  <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
      <list>
        <value>WEB-INF/mail.properties</value>
        <value>WEB-INF/jdbc.properties</value>
      </list>
    </property>
  </bean>

  <!-- MailSender used by EmailAdvice -->
  <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
    <property name="host" value="${mail.host}"/>
  </bean>


  <!-- ========================= BUSINESS OBJECT DEFINITIONS ======================== -->

  <!-- Generic validator for Account objects, to be used for example by the Spring web tier -->
  <bean id="accountValidator" class="org.springframework.samples.jpetstore.domain.logic.AccountValidator"/>

  <!-- Generic validator for Order objects, to be used for example by the Spring web tier -->
  <bean id="orderValidator" class="org.springframework.samples.jpetstore.domain.logic.OrderValidator"/>

  <!-- AOP advice used to send confirmation email after order has been submitted -->
  <bean id="emailAdvice" class="org.springframework.samples.jpetstore.domain.logic.SendOrderConfirmationEmailAdvice">
    <property name="mailSender">
      <ref local="mailSender"/>
    </property>
  </bean>

  <!-- Advisor encapsulating email advice -->
  <bean id="emailAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
    <constructor-arg>
      <ref local="emailAdvice"/>
    </constructor-arg>
    <property name="pattern">
      <value>.*insertOrder.*</value>
    </property>
  </bean>

  <!-- A parent bean definition which is a base definition for transaction proxies. -->
  <!-- It's marked as abstract, since it's not supposed to be instantiated itself. -->
  <!-- We set shared transaction attributes here, following our naming patterns. -->
  <!-- The attributes can still be overridden in child bean definitions. -->
  <bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true">
    <property name="transactionManager">
      <ref bean="transactionManager"/>
    </property>
    <property name="transactionAttributes">
      <props>
        <prop key="insert*">PROPAGATION_REQUIRED</prop>
        <prop key="update*">PROPAGATION_REQUIRED</prop>
        <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
      </props>
    </property>
  </bean>

  <!-- JPetStore primary business object (default implementation), as an inner bean wrapped -->
  <!-- by an outer transactional proxy. The two bean definitions could have been separate, -->
  <!-- but this is cleaner as there is no need to ever access the unwrapped object. -->
  <bean id="petStore" parent="baseTransactionProxy">
    <property name="target">
      <bean class="org.springframework.samples.jpetstore.domain.logic.PetStoreImpl">
        <property name="accountDao">
          <ref bean="accountDao"/>
        </property>
        <property name="categoryDao">
          <ref bean="categoryDao"/>
        </property>
        <property name="productDao">
          <ref bean="productDao"/>
        </property>
        <property name="itemDao">
          <ref bean="itemDao"/>
        </property>
        <property name="orderDao">
          <ref bean="orderDao"/>
        </property>
      </bean>
    </property>
    <!-- Uncomment the following in order to enable mail sending aspect -->
    <property name="postInterceptors">
      <list>
        <ref local="emailAdvisor"/>
      </list>
    </property>
  </bean>


  <!-- ========================= REMOTE EXPORTER DEFINITIONS ======================== -->

  <!-- RMI exporter for the JPetStore OrderService -->
  <!-- Commented out by default to avoid conflicts with EJB containers -->
  <bean id="order-rmi" class="org.springframework.remoting.rmi.RmiServiceExporter">
    <property name="service">
      <ref local="petStore"/>
    </property>
    <property name="serviceInterface">
      <value>org.springframework.samples.jpetstore.domain.logic.OrderService</value>
    </property>
    <property name="serviceName">
      <value>order</value>
    </property>
    <property name="registryPort">
      <value>1099</value>
    </property>
  </bean>

</beans>

Hibernate

hibernate.cfg.kwaff
//
// source: hibernate-3.0/etc/hibernate.cfg.xml
//
?doctype    = @hibernate-configuration30

* hibernate-configuration

  * session-factory
    - name		= foo
    * property		= true
      - name		= show_sql
    * mapping
      - resource	= org/hibernate/test/Simple.hbm.xml
    * class-cache
      - usage		= read-write
      - class		= org.hibernate.test.Simple
      - region		= Simple
User.hbm.kwaff
//
// source: hibernate-3.0/eg/org/hibernate/auction/User.hbm.xml
//
? doctype = @hibernate-mapping30

* hibernate-mapping
  - package = org.hibernate.auction

  * class
    - name = User
    - table = AuctionUser
    - lazy = true
    * comment = Users may bid for or sell auction items.

    * id
      - name = id
      * generator
        - class = native

    * natural-id
      - mutable = true
      * property
        - name = userName
        - length = 10

    * property
      - name = password
      - not-null = true
      - length = 15
      - column = `password`

    * property
      - name = email

    * component
      - name = name
      * property
        - name = firstName
        - length = 50
        - not-null = true
      * property
        - name = initial
        - column = `initial`
      * property
        - name = lastName
        - length = 50
        - not-null = true

    * bag
      - name = bids
      - inverse = true
      - cascade = save-update,lock
      * key
        - column = bidder
      * one-to-many
        - class = Bid

    * bag
      - name = auctions
      - inverse = true
      - cascade = save-update,lock
      * key
        - column = seller
      * one-to-many
        - class = AuctionItem
Bid.hbm.kwaff
//
// source: hibernate-3.0/eg/org/hibernate/auction/Bid.hbm.xml
//
?doctype		= @hibernate-mapping30

* hibernate-mapping
  - package		= org.hibernate.auction

  * class
    - name		= Bid
    - discriminator-value = N
    * comment		= A bid or "buy now" for an item.

    * id
      - name		= id
      * generator
        - class		= native

    * discriminator
      - type		= char
      * column
        - name		= isBuyNow
        * comment	= Y if a "buy now", N if a regular bid.

    * natural-id
      * many-to-one
        - name		= item
      * property
        - name		= amount

    * property
      - name		= datetime
      - not-null	= true
      - column		= `datetime`

    * many-to-one
      - name		= bidder
      - not-null	= true

    * subclass
      - name		= BuyNow
      - discriminator-value = Y
AuctionItem.hbm.kwaff
//
// source: hibernate-3.0/eg/org/hibernate/auction/AuctionItem.hbm.xml
//
?doctype		= @hibernate-mapping30

* hibernate-mapping
  - package		= org.hibernate.auction

  * import
    - class		= AuctionInfo

  * class
    - name		= AuctionItem
    * comment		= An item that is being auctioned.

    * id
      - name		= id
      * generator
        - class		= native

    * natural-id
      * many-to-one
        - name		= seller
      * property
        - name		= description
        - length	= 200

    * property
      - name		= ends

    * property
      - name		= condition

    * many-to-one
      - name		= successfulBid
      - outer-join	= false

    * bag
      - name		= bids
      - cascade		= all
      - inverse		= true
      * key
        - column	= item
      * one-to-many
        - class		= Bid
convert:
$ kwaff hibernate.cfg.kwaff > hibernate.cfg.xml
$ kwaff User.hbm.kwaff > User.hbm.xml
$ kwaff Bid.hbm.kwaff > Bid.hbm.xml
$ kwaff AuctionItem.hbm.kwaff > AuctionItem.hbm.xml
hibernate.cfg.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
	"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>

  <session-factory name="foo">
    <property name="show_sql">true</property>
    <mapping resource="org/hibernate/test/Simple.hbm.xml"/>
    <class-cache usage="read-write" class="org.hibernate.test.Simple" region="Simple"/>
  </session-factory>

</hibernate-configuration>
User.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.hibernate.auction">

  <class name="User" table="AuctionUser" lazy="true">
    <comment>Users may bid for or sell auction items.</comment>

    <id name="id">
      <generator class="native"/>
    </id>

    <natural-id mutable="true">
      <property name="userName" length="10"/>
    </natural-id>

    <property name="password" not-null="true" length="15" column="`password`"/>

    <property name="email"/>

    <component name="name">
      <property name="firstName" length="50" not-null="true"/>
      <property name="initial" column="`initial`"/>
      <property name="lastName" length="50" not-null="true"/>
    </component>

    <bag name="bids" inverse="true" cascade="save-update,lock">
      <key column="bidder"/>
      <one-to-many class="Bid"/>
    </bag>

    <bag name="auctions" inverse="true" cascade="save-update,lock">
      <key column="seller"/>
      <one-to-many class="AuctionItem"/>
    </bag>
  </class>

</hibernate-mapping>
Bid.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.hibernate.auction">

  <class name="Bid" discriminator-value="N">
    <comment>A bid or "buy now" for an item.</comment>

    <id name="id">
      <generator class="native"/>
    </id>

    <discriminator type="char">
      <column name="isBuyNow">
        <comment>Y if a "buy now", N if a regular bid.</comment>
      </column>
    </discriminator>

    <natural-id>
      <many-to-one name="item"/>
      <property name="amount"/>
    </natural-id>

    <property name="datetime" not-null="true" column="`datetime`"/>

    <many-to-one name="bidder" not-null="true"/>

    <subclass name="BuyNow" discriminator-value="Y"/>
  </class>

</hibernate-mapping>
AuctionItem.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.hibernate.auction">

  <import class="AuctionInfo"/>

  <class name="AuctionItem">
    <comment>An item that is being auctioned.</comment>

    <id name="id">
      <generator class="native"/>
    </id>

    <natural-id>
      <many-to-one name="seller"/>
      <property name="description" length="200"/>
    </natural-id>

    <property name="ends"/>

    <property name="condition"/>

    <many-to-one name="successfulBid" outer-join="false"/>

    <bag name="bids" cascade="all" inverse="true">
      <key column="item"/>
      <one-to-many class="Bid"/>
    </bag>
  </class>

</hibernate-mapping>

Seasar2

seasar2.kwaff
//
// from http://www.seasar.org/DIContainer.html#Example
//
? encoding		= Shift_JIS
? doctype		= @seasar2

* components

  # constructor injection
  * component
    - name		= hello
    - class		= examples.dicon.HelloConstructorInjection
    * arg		= "Hello World!"

  # setter injection
  * component
    - class		= examples.dicon.HelloSetterInjection
    * property		= "Hello World!"
      - name		= message

  # method injection
  * component
    - class		= examples.dicon.HelloMethodInjection
    * initMethod
      - name		= addMessage
      * arg		= "Hello "
    * initMethod	= #self.addMessage("World!")

  # auto binding with constructor injection
  * component
    - class		= java.util.HashMap
    * initMethod
      - name 		= put
      * arg		= "hello"
      * arg		= "Hello World!"
  * component
    - autoBinding	= auto
    - class		= examples.dicon.autobinding.AutoHelloConstructorInjection

  # auto binding with setter injection
  * component
    - class		= java.util.HashMap
    * initMethod
      - name		= put
      * arg		= "hello"
      * arg		= "Hello World!"
  * component
    - autoBinding	= auto
    - class		= examples.dicon.autobinding.AutoHelloSetterInjection

  # AOP
  * component
    - name		= traceInterceptor
    - class		= org.seasar.framework.aop.interceptors.TraceInterceptor
  * component
    - class		= java.util.ArrayList
    * aspect		= traceInterceptor
  * component
    - class		= java.util.Date
    * arg		= 0
    * aspect		= traceInterceptor
      - pointcut	= getTime, hashCode
convert:
$ kwaff seasar2.kwaff > seasar2.dicon
seasar2.dicon
<?xml version="1.0" encoding="Shift_JIS"?>
<!DOCTYPE components PUBLIC "-//SEASAR2.1//DTD S2Container//EN"
	"http://www.seasar.org/dtd/components21.dtd">
<components>

  <!-- constructor injection -->
  <component name="hello" class="examples.dicon.HelloConstructorInjection">
    <arg>"Hello World!"</arg>
  </component>

  <!-- setter injection -->
  <component class="examples.dicon.HelloSetterInjection">
    <property name="message">"Hello World!"</property>
  </component>

  <!-- method injection -->
  <component class="examples.dicon.HelloMethodInjection">
    <initMethod name="addMessage">
      <arg>"Hello "</arg>
    </initMethod>
    <initMethod>#self.addMessage("World!")</initMethod>
  </component>

  <!-- auto binding with constructor injection -->
  <component class="java.util.HashMap">
    <initMethod name="put">
      <arg>"hello"</arg>
      <arg>"Hello World!"</arg>
    </initMethod>
  </component>
  <component autoBinding="auto" class="examples.dicon.autobinding.AutoHelloConstructorInjection"/>

  <!-- auto binding with setter injection -->
  <component class="java.util.HashMap">
    <initMethod name="put">
      <arg>"hello"</arg>
      <arg>"Hello World!"</arg>
    </initMethod>
  </component>
  <component autoBinding="auto" class="examples.dicon.autobinding.AutoHelloSetterInjection"/>

  <!-- AOP -->
  <component name="traceInterceptor" class="org.seasar.framework.aop.interceptors.TraceInterceptor"/>
  <component class="java.util.ArrayList">
    <aspect>traceInterceptor</aspect>
  </component>
  <component class="java.util.Date">
    <arg>0</arg>
    <aspect pointcut="getTime, hashCode">traceInterceptor</aspect>
  </component>

</components>

Xi

bbs.kwaff
//
// from http://dock.baykit.org/xi13?Tutorial
//

* xi:program
  - xmlns:xi		= http://www.baykit.org/Xi/1.1

  # declare variable 'BBS-DATA' with initial data 
  * xi:variable
    - name		= BBS-DATA
    * bbs
      * message		= Welcom to mini-bbs

  # if file 'bbs.xml' is exists, then load it into 'BBS-DATA' 
  * xi:if
    - test		= $FS.exists('bbs.xml')
    * xi:set
      - out		= $BBS-DATA
      - select		= $IO.loadXml('bbs.xml')

  # if new_message is on param, add it to end of BBS-DATA 
  * xi:if
    - test		= $Web.parameters.new_message != ''
    * xi:set
      - out		= $BBS-DATA
      * bbs
        * xi:copy-of
          - select	= $BBS-DATA/bbs/*
        * message
          * xi:value-of
            - select	= $Web.parameters.new_message
    * xi:exec
      - select		= $IO.saveXml('bbs.xml', $BBS-DATA)

  * HTML
    * BODY

      # display bbs message. 
      * UL
        * xi:for-each
          - item	= message
          - select	= $BBS-DATA/bbs/*
          * LI
            * xi:value-of
              - select	= $message

      # FORM for posting bbs message. 
      * HR
      * FORM
        - METHOD	= post
        - ACTION	= bbs.xi
        . 
        .         Message to post: 
        * BR
        * TEXTAREA
          - NAME	= new_message
        * INPUT
          - TYPE	= submit
convert:
$ kwaff bbs.kwaff > bbs.xi
bbs.xi
<?xml version="1.0"?>
<xi:program xmlns:xi="http://www.baykit.org/Xi/1.1">

  <!-- declare variable 'BBS-DATA' with initial data  -->
  <xi:variable name="BBS-DATA">
    <bbs>
      <message>Welcom to mini-bbs</message>
    </bbs>
  </xi:variable>

  <!-- if file 'bbs.xml' is exists, then load it into 'BBS-DATA'  -->
  <xi:if test="$FS.exists('bbs.xml')">
    <xi:set out="$BBS-DATA" select="$IO.loadXml('bbs.xml')"/>
  </xi:if>

  <!-- if new_message is on param, add it to end of BBS-DATA  -->
  <xi:if test="$Web.parameters.new_message != ''">
    <xi:set out="$BBS-DATA">
      <bbs>
        <xi:copy-of select="$BBS-DATA/bbs/*"/>
        <message>
          <xi:value-of select="$Web.parameters.new_message"/>
        </message>
      </bbs>
    </xi:set>
    <xi:exec select="$IO.saveXml('bbs.xml', $BBS-DATA)"/>
  </xi:if>

  <HTML>
    <BODY>

      <!-- display bbs message.  -->
      <UL>
        <xi:for-each item="message" select="$BBS-DATA/bbs/*">
          <LI>
            <xi:value-of select="$message"/>
          </LI>
        </xi:for-each>
      </UL>

      <!-- FORM for posting bbs message.  -->
      <HR/>
      <FORM METHOD="post" ACTION="bbs.xi">
        Message to post: <BR/>
        <TEXTAREA NAME="new_message"/>
        <INPUT TYPE="submit"/>
      </FORM>

    </BODY>
  </HTML>

</xi:program>