home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / database.xml < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  7.4 KB  |  179 lines

  1. <?xml version="1.0"?>
  2. <!--
  3.   Copyright 1999-2004 The Apache Software Foundation
  4.  
  5.   Licensed under the Apache License, Version 2.0 (the "License");
  6.   you may not use this file except in compliance with the License.
  7.   You may obtain a copy of the License at
  8.  
  9.       http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11.   Unless required by applicable law or agreed to in writing, software
  12.   distributed under the License is distributed on an "AS IS" BASIS,
  13.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.   See the License for the specific language governing permissions and
  15.   limitations under the License.
  16. -->
  17. <root>
  18.    <connection>personnel</connection>
  19.    <!-- this is only used when no connection is specified in sitemap -->
  20.  
  21.    <!-- a table consists of key attributes and plain values, keys are
  22.         handled differently on operations. Most significantly when
  23.         inserting a new row, we need to determine if a value needs to
  24.         be set by the action or wheter it's an autoincrement. Next,
  25.         autoincrements work differently on different DBMSs, so we need
  26.         special support to find out about the value set by the DBMS.
  27.    -->
  28.    <table name="user" alias="user">
  29.       <!-- @name is the table's name in the DB -->
  30.       <!-- @alias is used instead (if present) for those weirdos that put -->
  31.       <!-- complex queries into @name ;-) You obviously loose all but select -->
  32.       <!-- functionality, although this is not enforced. -->
  33.       <keys>
  34.          <key name="uid" type="int" autoincrement="true">
  35.             <!-- @name is the column's name -->
  36.             <!-- @type is the column's jdbc type -->
  37.             <!-- @autoincrement : column value is determined by special component -->
  38.             <mode name="auto"  type="autoincr"/>
  39.             <!-- this entry says:
  40.             when inserting a new column into a autoincrement column
  41.             (@type="autoincr"), use the module named "auto" to find out about
  42.             how to handle this column. All other operations use the default
  43.             mode.  
  44.             There are two distinct mode types: "autoincr" for insert
  45.             operations on autoincrement columns and "others" for all other
  46.             (delete, update, select) operations on autoincrement columns and
  47.             all operations on other columns. 
  48.             -->
  49.          </key>
  50.       </keys>
  51.       <values>
  52.          <value name="name"      type="string"></value>
  53.          <value name="firstname" type="string"></value>
  54.          <value name="uname"     type="string"></value>
  55.       </values>   
  56.    </table>
  57.  
  58.    <table name="user_groups">
  59.       <keys>
  60.          <key name="uid" type="int">
  61.             <!-- Next we have two different modes: "request" and
  62.             "attrib". See below for explanation. -->
  63.             <mode name="request-param" type="request"/>
  64.             <mode name="request-attr" type="attrib">
  65.                <parameter>org.apache.cocoon.components.modules.output.OutputModule:user.uid[0]</parameter>
  66.                <!-- use a different parameter name to query than the automatically
  67.                     generated one (here "user_groups.uid") This is a feature of 
  68.                     the "request-attr" input module but widely available.
  69.                     Another option would be to use the SimpleMappingMetaModule
  70.                     instead.
  71.                -->
  72.             </mode>
  73.             <!--  note here, that the actual parameter has a row index
  74.             to it. We don't expect to insert more than one user plus
  75.             her groups at any time, so we append just "[0]". However,
  76.             if that would be the case, we could let this column be
  77.             part of a set and ask for "[*]" instead. Might be tricky
  78.             to find the associated groups, though, if we insert x
  79.             users plus y_1, y_2, ... , y_x groups.... -->
  80.          </key>
  81.          <key name="gid" type="int" set="master">
  82.             <!-- now, this is tricky: when we need to insert multiple
  83.             rows, those attributes that differ in these rows are
  84.             marked to belong to a "set". One column is marked to be
  85.             the "master" while all others need to be "slaves". A
  86.             master is used to obtain a sorted set of index values for
  87.             these rows. These will then be used to get the actual
  88.             values for the master and slave columns. Note that it is
  89.             not necessary to have the master be a key column. Note too, that an
  90.             autoincrement column may not serve as a master here.
  91.  
  92.             This attribute may be specified on a column level or on a
  93.             mode level to allow different behavious. Mode level @set
  94.             is only considered if @set is not present on column level.
  95.  
  96.             Plus, as deletes and selects consider only key attributes while
  97.             updates  consider values as well, there's no harm having a single
  98.             set for these three actions. In this case the set master needs to
  99.             be a key column, though.
  100.  
  101.             -->
  102.             <!-- special mode type "all" is used for all operations -->
  103.             <mode name="request-param" type="all"/>
  104.          </key>
  105.       </keys>
  106.    </table>
  107.  
  108.    <table name="groups">
  109.       <keys>
  110.          <key name="gid" type="int" autoincrement="true">
  111.             <mode name="auto" type="autoincr"/>
  112.          </key>
  113.       </keys>
  114.       <values>
  115.          <value name="gname" type="string"/>
  116.       </values>   
  117.    </table>
  118.    
  119.    <table name="media">
  120.       <keys>
  121.          <key name="id" type="int" autoincrement="true">
  122.             <mode name="auto" type="autoincr"/>
  123.          </key>
  124.       </keys>
  125.       <values>
  126.          <value name="image" type="binary">
  127.            <mode name="raw-request-param" type="add"/>
  128.            <!-- for multipart form uploads it is important to use the raw-request-param
  129.                 module since that does not cast the parameter to String and does no
  130.                 encoding conversions.
  131.            -->
  132.          </value>
  133.          <value name="mimetype" type="string">
  134.            <mode name="jxpath" type="add">
  135.               <parameter>mimeType</parameter>
  136.               <input-module name="raw-request-param" parameter="media.image"/>
  137.            </mode>
  138.          </value>
  139.       </values>   
  140.    </table>
  141.  
  142.    <!-- the existing DB actions try to work on all tables listed in
  143.         this descriptor file. Just like some other newer actions this
  144.         one also allows for table-sets. If no set is found, it
  145.         defaults to the previous behaviour. Note though, that the
  146.         syntax is slightly different from the "old" DB actions file. -->
  147.  
  148.  
  149.    <table-set name="user">
  150.       <table name="user"/>
  151.    </table-set>
  152.  
  153.    <table-set name="groups">
  154.       <table name="groups"/>
  155.    </table-set>
  156.  
  157.    <table-set name="media">
  158.       <table name="media" others-mode="add"/>
  159.    </table-set>
  160.  
  161.    <table-set name="user+groups">
  162.       <table name="user"/>
  163.       <table name="user_groups" others-mode="attrib"/>
  164.       <!-- below we have another table set that inserts data into
  165.       user_groups. When inserting into user_groups alone, we'd know
  166.       the uid before hand, but when inserting a new user as well, we
  167.       need to find out the autoincrement value first. Therefore we
  168.       need a different approach to obtain that value. So we can
  169.       instruct the action to use a different type (here "attrib") which reads
  170.       the result from the first insert operation. 
  171.       -->
  172.    </table-set>
  173.  
  174.    <table-set name="user_groups">
  175.       <table name="user_groups" others-mode="request"/>
  176.    </table-set>
  177.  
  178. </root>
  179.