Scott Daley wrote:
> I'm creating a new schema and CSS and want to be able to have tables a 
> part of it.  How is the best way to do this?  Given that a lot of effort 
> has gone into the table functionality in xxe's docbook support it would 
> be good if I could draw on this by including/import the relevant bits.  
> Is this possible?
> 
> I have found information on how to restrict docbook using DTD's, but in 
> this case I would prefer to use a schema.

There is no easy way to do what you want:

[1] Get a W3C XML Schema for DocBook either from oasis or by converting 
the DTD to a schema using the dtdtoxsd tool included in XXE distribution.

[2] Using a text editor, extract all the element types used to build 
DocBook/CALS tables. This step is more or less messy depending on the 
modularity of the schema you found.

[3] Merge the CALS content model for tables by including it or importing 
it in your own XML schema.

[4] Write an XXE configuration file for your XML schema.

This XXE configuration file must contain (extracted from 
XXE_install_dir/config/docbook/docbook.xxe):

---
   <load location="docbook.jar" />
---
(docbook.jar contains, among other things, all the support code for 
DocBook/CALS tables.)

and (extracted from XXE_install_dir/config/docbook/common.incl):

---
   <command name="zzz.tableColumn">
     <class>com.xmlmind.xmleditapp.docbook.TableColumn</class>
   </command>
   <command name="zzz.tableRow">
     <class>com.xmlmind.xmleditapp.docbook.TableRow</class>
   </command>

   <menu label="ZZZ" mnemonic="Z">
     <item label="Insert Column Before" mnemonic="B"
           icon="icons/ColumnInsertBefore16.gif"
           command="zzz.tableColumn" parameter="insertBefore"/>
     <item label="Insert Column After" mnemonic="A"
           icon="icons/ColumnInsertAfter16.gif"
           command="zzz.tableColumn" parameter="insertAfter"/>
     <item label="Delete Column" mnemonic="D"
           icon="icons/ColumnDelete16.gif"
           command="zzz.tableColumn" parameter="delete"/>
     <separator />
     <item label="Insert Row Before" mnemonic="I"
           icon="icons/RowInsertBefore16.gif"
           command="zzz.tableRow" parameter="insertBefore"/>
     <item label="Insert Row After" mnemonic="s"
           icon="icons/RowInsertAfter16.gif"
           command="zzz.tableRow" parameter="insertAfter"/>
     <item label="Delete Row" mnemonic="e"
           icon="icons/RowDelete16.gif"
           command="zzz.tableRow" parameter="delete"/>
   </menu>
---

The CSS style sheet for your XML schema must contain (extracted from 
XXE_install_dir/config/docbook/css/docbook2.imp):

---
/* =====================================
    Tables
===================================== */

/*
  * "black" is the color used to draw a border around the table and its 
cells
  * based on values of attributes such as frame, rowsep and colsep.
  *
  * "rgb(238,238,224)" (a very light gray) is the color used to draw
  * a border around each cell whether the cell actually has borders or not.
  * Remove this parameter if this ``cell footprint'' disturbs you.
  *
  * For more information about table support for DocBook, see
  * Power User's Guide.
  */
@extension "com.xmlmind.xmleditapp.docbook.TableSupport black 
rgb(238,238,224)";

table,
informaltable {
     display: block;
     margin: 1.33ex 0;
}

table > title {
     display: block;
     font-style: italic;
     font-weight: normal;
     text-align: center;
     /* keep margin because tgroup has no margin */
}

colspec,
spanspec {
     display: table-column;
     collapsed: yes;
}

tgroup {
     display: table;
     border-style: solid;
     border-width: 1;
}

thead,
tfoot {
     display: table-row-group;
     font-weight: bold;
}

tbody {
     display: table-row-group;
}

row {
     display: table-row;
}

entry {
     display: table-cell;
     border-style: solid;
     border-width: 1;
     padding: 2;
}

entry > *:first-child {
     margin-top: 0;
     margin-bottom: 0;
}

entrytbl {
     display: subtable;
     border-style: solid;
     border-width: 1;
}
---

All the support code written for DocBook should work whatever is the 
namespace choosen for CALS tables (i.e. entry or foo:entry or 
bar:entry). If this is not the case, simply tell us and we will fix this 
bug ASAP.


---
PS: CALS tables are *horrible* to use. You may consider using XHTML 
tables instead.

---
PS2: If you just need simple tables, it is much easier to design your 
own from scratch, style them using plain CSS, and provide no special 
commands to edit them. (Just provide a few named element templates for 
commonly used tables.)


Reply via email to