Re: table setup

Sam Carleton <sam@linux-info.net> writes:

> On Mon, Jun 30, 2003 at 10:13:41AM +0100, Henry S. Thompson wrote:
> > Sam Carleton <sam@linux-info.net> writes:
> > 
> > > Opps, I had the layout wrong.  This is what I have:
> > 
> > Too bad -- we could have done the first one (with key/keyref), but the
> > second one is not possible in W3C XML Schema, which doesn't do
> > run-time-constrained typing (which is what you're asking for).
>  
> Henry,
> 
> After some thought I have decided to be flexable:)  I will adapt the
> XML to the form in which it can be done.  Would you mind enlighten
> me as to how?

Sure, see below.

> Again, here is the format:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <doc>
>         <colInfo>
>                 <columnDef name="col1">1st Column</columnDef> 
>                 <columnDef name="col2">2nd Column</columnDef>
>                 <columnDef name="col3">3rd Column</columnDef>
>         </colInfo>
>         <data>
>                 <item>
>                         <name>an item</name>
>                         <column name="col1">something</column>  
>                         <column name="col2">something</column>
>                         <column name="col3">something</column>  
>                 </item>

<snip/>

Include

<xs:key name="colDef">
 <xs:select xpath="colInfo/columnDef"/>
 <xs:field xpath="@name"/>
</xs:key>

and

<xs:keyref name="col" refer="colDef">
 <xs:select xpath="data/item/column"/>
 <xs:field xpath="@name"/>
</xs:keyref>

to the element declaration for doc

and 

<xs:key name="colK">
 <xs:select xpath="column"/>
 <xs:field xpath="@name"/>
</xs:key

to the element declaration for item.

The first two make sure every column references one of the columnDefs
with its name.  The third makes sure they are all different.  Can't
force them to be in order, sorry.

Hope this helps

ht
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
                      Half-time member of W3C Team
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
	    Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
		     URL: http://www.ltg.ed.ac.uk/~ht/
 [mail really from me _always_ has this .sig -- mail without it is forged spam]

Received on Monday, 30 June 2003 09:35:00 UTC