From: Michael Lake (mikel_at_speleonics.com.au)
Date: Sun Feb 18 2001 - 03:25:42 CET
Received: (from mdom_at_localhost) by karto.ethz.ch (8.9.3/8.9.3/SuSE Linux 8.9.3-0.1) id EAA27867 for cavexml-outgoing; Sun, 18 Feb 2001 04:04:45 +0100 Received: from iggy.triode.net.au (IDENT:root_at_iggy.triode.net.au [203.63.235.1]) by karto.ethz.ch (8.9.3/8.9.3/SuSE Linux 8.9.3-0.1) with ESMTP id EAA27863 for <cavexml_at_cartography.ch>; Sun, 18 Feb 2001 04:04:43 +0100 Received: from speleonics.com.au (mikel_at_dm1-20.triode.net.au [203.63.34.21]) by iggy.triode.net.au (8.11.1/8.10.1) with ESMTP id f1I37ah32185 for <cavexml_at_cartography.ch>; Sun, 18 Feb 2001 14:07:37 +1100 Message-ID: <3A8F32A6.49472575@speleonics.com.au> Date: Sun, 18 Feb 2001 13:25:42 +1100 From: Michael Lake <mikel_at_speleonics.com.au> X-Mailer: Mozilla 4.73 [en] (X11; I; Linux 2.2.14 i686) X-Accept-Language: en To: cavexml_at_cartography.ch Subject: IDs and IDREFs. was Re: defaulting units for measurements References: <20010213184652.HJOD19514.t21mta02-app.talk21.com_at_t21mtaV-lrs> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-cavexml_at_karto.baug.ethz.ch Precedence: bulk Reply-To: cavexml_at_cartography.ch
martinl_at_talk21.com wrote:
>
> Richard Knapp suggested a sample XML fragment using IDs and IDREFs.
> I also point a problem with IDs, and to the related concept of XSL keys.
......
> where the DTD or Schema identify attribute station of the from and to
> elements as of type IDREF and attribute name of element station as of
> type ID. A corresponding DTD would include:
> <!DOCTYPE survey [
> ...
> <!ELEMENT from >
> <!ATTLIST from station IDREF >
> <!ELEMENT to >
> <!ATTLIST to station IDREF >
> <!ELEMENT station >
> <!ATTLIST station name ID >
> ]>
> 2 There is a problem identified long
> ago by Mike Lake in that IDs should be valid XML Names which means (amongst other
> things) that they MUST begin with a letter; this example is ok, but all those
> surveys with integer station numbers (as recently suggested) would be invalid.
> (Of course, you could get round this with prefixes ...)
and it limits you even more...
John Halleck wrote:
> Another problem is that ID's aren't typed.
> If you have ID's in station names, and ID's in something else (ratings for
> example), then "A1" as a station name ID also becomes something that an IDREF in ratings
> would point to.
and it limits you even more and more.....
All such IDs must be UNIQUE within an XML
document. When I wanted to do things like:
<SERIES name="main drag">
<STN name="1"/>
<STN name="2"/>
<SHOT from="1" to="2" dist="5.0" azim="180" elev="+43" />
<SHOT from="2" to="3" dist="2.0" AZIM="260" elev="+22" />
<SERIES name="extension">
<STN name="1"/>
<STN name="2"/>
<SHOT from="1" to="2" dist="3.0" azim="330" elev="+22" />
<SHOT from="2" to="3" dist="1.0" azim=" 30" elev="+2" />
</SERIES>
</SERIES>
ie just like survex where this would be recorded as:
*begin main
1 2 5.0 180 43
2 3 2.0 260 22
*begin extension
1 2 3.0 330 22
2 3 1.0 30 2
*end extension
*end main
If the station names could have been of type ID then the FROM and TO
attribute types could have been be IDREF which means that the value must
match the value of an ID attribute for an element in the document---in
this case a STN element. Hence you can't have shots to/from stations
that dont exist.
Maybe one can get around this with name spaces and things but that
complicates the DTD and schema and will make it harder for software
developers to write converters for their own format.
I gave up in using ID's in the XML file.
> 3 XSLT has a key() function which selects elements according to their content
> once the <xsl:key> element has been used to define values for use in subsequent
> processing. The difference from IDs is that keys (as used here) do not have to
> be unique. See an example of it in use at.....
Mike
-- -------------------------------------------------------------------- Michael Lake Active caver, Linux enthusiast and interested in anything technical. Safety Convenor, Australian Speleological Federation Owner, Speleonics (Australia) --------------------------------------------------------------------
This archive was generated by hypermail 2b30 : Thu Mar 01 2001 - 18:00:01 CET