Challenge Case 1

Barringer, Kerry kerrybarringer at BBG.ORG
Wed Nov 28 14:47:45 CET 2001


        Attached are the files for a partial solution to the first Challenge
case.  I have deliberately left out the XSLT code that capitalizes the first
letter in a sentence and eliminates the comma before the period.  The stuff
I have written is awkward and embarassing and I will try to come up with a
more elegant way that can be used for general formatting of the nodes.

        This DTD corrects some of the typos in the DTD posted yesterday.
The XML file should validate against this DTD.  I commented out the DOCTYPE
line in the XML because the Xalan parser is fussy about how the file
location is cited and I wanted one file to test with all the parsers.

        The XSLT code runs correctly using Microsoft, Sablotron, Saxon, and
Xalan parsers in XMLCooktop.  The resulting html file is also attached.  I
had to do this because the code does not run properly under MS Internet
Explorer 5.5.  This could be a namespace problem.  I will look into it.

        Unfortunately, I did this coding before I saw Kevin Thiele's Nov 27
posting.  That posting contains some good ideas about markup that I want to
incorporate in this DTD.  I especially like his handling of 'shrub' as a
character state, not a name.  Like Kevin, I nest characters. There are many
small differences in the two approaches.  The most notable is the handling
of numeric characters and ranges. My approach may be too simple for anything
but natural language output.

        As a side challenge, I would like to try to develop code that would
produce a tabular description from this markup. The table should have blank
cells for missing data. This will help determine if it is necessary to code
missing characters as part of the description, or if we can get by with only
coding the character we know. I think the later approach is most practical.
This will also help determine if nested characters can be  used.

        Kerry


^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Kerry Barringer (Curator of the Herbarium)

Herbarium                     718-623-7318 (office)
Brooklyn Botanic Garden 718-941-4774 (fax)
1000 Washington Avenue  718-623-7312 (herbarium)
Brooklyn, NY 11225-1099   U.S.A.

kbarringer at bbg.org      http://www.bbg.org/
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


------_=_NextPart_000_01C17845.8CA00B60
Content-Type: application/octet-stream;
        name="DescrKB112801.dtd"
Content-Disposition: attachment;
        filename="DescrKB112801.dtd"

<!--

DTD for Descriptive data

modified from Taxonomic Document Markup, 27 Nov 2001
modifications based on:
         L. Dodds, SDD maillist 23 Nov 2001
         G. Rouse, SDD maillist 23 Nov 2001

Description
        Heading
        Character
                CharName
                        codedCharName
                        textCharName
                State
                        Connector
                        Qualifier
                        codedStateName
                        textStateName
                        Comment
                Comment
                Character

-->
<!ELEMENT Example (Taxon+)>
<!ELEMENT Taxon (TaxonName+, Description+)>
<!ELEMENT TaxonName (#PCDATA)>

<!-- The two elements above should not be part of the standard. They are only here to allow the testing of real world examles -->

<!ELEMENT Description (Heading?, Character+)>
        <!ATTLIST Description
                Type CDATA #IMPLIED
                itemNumber CDATA #IMPLIED
                >

<!ELEMENT Character (CharName, State+, sComment*, Character*)>
        <!ATTLIST Character
                characterType CDATA #IMPLIED
                characterNumber CDATA #IMPLIED
                numberOfStates CDATA #IMPLIED
                reliability CDATA #IMPLIED
                weight CDATA #IMPLIED
                dependentOn CDATA #IMPLIED
                keyStates CDATA #IMPLIED
                linkTo CDATA #IMPLIED
                applicable CDATA #IMPLIED
        >

<!ELEMENT CharName (codedCharName?, textCharName?)>
        <!ELEMENT codedCharName (#PCDATA)>
        <!ELEMENT textCharName (#PCDATA)>

<!ELEMENT State (Qualifier*, textCharState+, codedCharState*, Connector?, sComment*)>
        <!ATTLIST State
                Type CDATA #IMPLIED
                numericType CDATA #IMPLIED
                defaultValue CDATA #IMPLIED
                allowedValues CDATA #IMPLIED
                Describes CDATA #IMPLIED
                source CDATA #IMPLIED
                measurementSystem CDATA #IMPLIED
        >
        <!ELEMENT codedCharState (#PCDATA)>
        <!ELEMENT textCharState (#PCDATA)>

        <!ELEMENT Connector (#PCDATA)>
        <!ELEMENT Qualifier (#PCDATA)>
        <!ELEMENT sComment (CommentText)>
        <!ELEMENT Heading (#PCDATA)>
        <!ELEMENT CommentText (#PCDATA)>

------_=_NextPart_000_01C17845.8CA00B60
Content-Type: application/octet-stream;
        name="TDWGSDDtext.xsl"
Content-Disposition: attachment;
        filename="TDWGSDDtext.xsl"

<xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


        <xsl:template match="/">
                <html>
                        <head>
                                <title>
                                        TDWG-SDD Challenge Case 1
                                </title>
                        </head>
                        <body>
                        <h2>TWD-SDD</h2>
                        <h1>Challenge Case 1</h1>
                        <hr/>
                                <xsl:apply-templates select="Example/Taxon"/>
                        </body>
                </html>
        </xsl:template>

        <xsl:template match="Taxon">
                <h3>
                <xsl:number/>
                <xsl:text>. &#0160;</xsl:text>
                <xsl:value-of select="TaxonName"/>
                </h3>
                <p>
                <xsl:apply-templates select="Description"/>
                </p>
        </xsl:template>

        <xsl:template match="Description">
                <xsl:value-of select="Heading"/>
                <xsl:apply-templates select="Character"/>
        </xsl:template>

        <xsl:template match="Character">
                <xsl:apply-templates select="CharName"/>
                <xsl:text>&#0160;</xsl:text>
                <xsl:apply-templates select="State"/>
                <xsl:text>.</xsl:text>
        </xsl:template>

        <xsl:template match="CharName">
                <xsl:value-of select="textCharName"/>
        </xsl:template>

        <xsl:template match="State">
                        <xsl:value-of select="Qualifier"/>
                        <xsl:text>&#0160;</xsl:text>
                        <xsl:value-of select="textCharState"/>
                        <xsl:if test="@Describes='length'">
                                <xsl:text>&#0160;long</xsl:text>
                        </xsl:if>
                        <xsl:if test="@Describes='width'">
                                <xsl:text>&#0160;wide</xsl:text>
                        </xsl:if>
                        <xsl:apply-templates select="sComment"/>
                        <xsl:text>,&#0160;</xsl:text>
        </xsl:template>

        <xsl:template match="sComment">
                <xsl:text>&#0160; &#0040;</xsl:text>
                <xsl:value-of select="CommentText"/>
                <xsl:text>&#0041;</xsl:text>
                <xsl:text>. &#0160;</xsl:text>
        </xsl:template>


</xsl:stylesheet>
------_=_NextPart_000_01C17845.8CA00B60
Content-Type: text/html;
        name="TDWGtest1.html"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
        filename="TDWGtest1.html"

<html>
<head>
<META http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3DUTF-16">
<title>

                                        TDWG-SDD Challenge Case 1

                                </title>
</head>
<body>
<h2>TWD-SDD</h2>
<h1>Challenge Case 1</h1>
<hr>
<h3>1. =A0Discaria pubescens</h3>
<p>shrub=A0=A0rigid,=A0=A0spreading,=A0=A0to c. 1m=A0long,=A0=A0to c. 1 =
cm=A0wide,=A0.stems=A0=A0glabrous,=A0.leaves=A0soon=A0deciduous=A0 =
(particularly on older plants). =A0,=A0+/-=A0oblong,=A0=A0(4-)6-10(-15) =
mm=A0long,=A0=A02-3 mm=A0wide,=A0.stipules=A0=A0dark =
reddish-brown,=A0=A0c. 1 mm=A0long,=A0often=A0shallowly joined around =
the node,=A0.spines=A0=A0stout,=A0=A01.5-4 cm=A0long,=A0.</p>
<h3>2. =A0Discaria nitida</h3>
<p>shrub=A0=A0slender,=A0=A0to 5 =
m,=A0.stems=A0=A0glabrous,=A0.leaves=A0rarely=A0deciduous,=A0=A0elliptic=
,=A0=A0(8-)10-20(-30) mm=A0long,=A0=A03-7 =
mm=A0wide,=A0=A0glabrous,=A0=A0shining,=A0.spines=A0=A0not developed at =
each node,=A0=A0to c. 1 cm=A0long,=A0.</p>
</body>
</html>

------_=_NextPart_000_01C17845.8CA00B60
Content-Type: application/octet-stream;
        name="TDWGtest1.xml"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
        filename="TDWGtest1.xml"

<?xml version=3D'1.0' encoding=3D'ISO-8859-1'?>
<!-- DOCTYPE Example SYSTEM "DescrKB112801.dtd" -->
<?xml-stylesheet type=3D"text/xsl" href=3D"TDWGSDDtext.xsl"?>
<Example>
   <Taxon>
      <TaxonName>Discaria pubescens</TaxonName>

      <Description>
         <Character>
            <CharName>
               <textCharName>shrub</textCharName>
            </CharName>

             <State Type=3D"Text" Describes=3D"texture">
               <textCharState>rigid</textCharState>
            </State>

            <State Type=3D"Text" Describes=3D"position">
               <textCharState>spreading</textCharState>
            </State>

            <State Describes=3D"length" Type=3D"Text" =
measurementSystem=3D"metric">
               <textCharState>to c. 1m</textCharState>
            </State>

            <State Type=3D"Text" Describes=3D"width" =
measurementSystem=3D"metric">
               <textCharState>to c. 1 cm</textCharState>
            </State>
         </Character>

         <Character>
            <CharName>
               <textCharName>stems</textCharName>
            </CharName>

            <State Type=3D"Text" Describes=3D"pubescence">
               <textCharState>glabrous</textCharState>
            </State>
         </Character>

         <Character>
            <CharName>
               <textCharName>leaves</textCharName>
            </CharName>

            <State Type=3D"Text" Describes=3D"longevity">
               <Qualifier>soon</Qualifier>

               <textCharState>deciduous</textCharState>

               <sComment><CommentText>particularly on older =
plants</CommentText></sComment>
            </State>

            <State Type=3D"Text" Describes=3D"PlaneShape">
               <Qualifier>+/-</Qualifier>

               <textCharState>oblong</textCharState>
            </State>

            <State Describes=3D"length" Type=3D"ContinuousNumeric" =
measurementSystem=3D"metric">
               <textCharState>(4-)6-10(-15) mm</textCharState>
            </State>

            <State Describes=3D"width" Type=3D"ContinuousNumeric" =
measurementSystem=3D"metric">
               <textCharState>2-3 mm</textCharState>
            </State>

            <Character>
               <CharName>
                  <textCharName>apex</textCharName>
               </CharName>

               <State Type=3D"Text" Describes=3D"PlaneShape">
                  <textCharState>obtuse</textCharState>

                  <textCharState>minutely mucronate</textCharState>

                  <Connector>or</Connector>
               </State>

               <State Type=3D"Text" Describes=3D"Location">
                  <textCharState>within an apical notch</textCharState>
               </State>

               <State Type=3D"Text" Describes=3D"pubescence">
                  <textCharState>glabrous</textCharState>

                  <textCharState>a few hairs present near =
tip</textCharState>

                  <Connector>or</Connector>
               </State>
            </Character>
         </Character>

         <Character>
            <CharName>
               <textCharName>stipules</textCharName>
            </CharName>

            <State Type=3D"Text" Describes=3D"Color">
               <textCharState>dark reddish-brown</textCharState>
            </State>

            <State Describes=3D"length" Type=3D"Text" =
measurementSystem=3D"metric">
               <textCharState>c. 1 mm</textCharState>
            </State>

            <State Type=3D"Text" Describes=3D"position">
               <Qualifier>often</Qualifier>

               <textCharState>shallowly joined around the =
node</textCharState>
            </State>
         </Character>

         <Character>
            <CharName>
               <textCharName>spines</textCharName>
            </CharName>

            <State Type=3D"Text" Describes=3D"3DShape">
               <textCharState>stout</textCharState>
            </State>

            <State Describes=3D"length" Type=3D"ContinuousNumeric" =
measurementSystem=3D"metric">
               <textCharState>1.5-4 cm</textCharState>
            </State>
         </Character>
      </Description>
   </Taxon>

   <Taxon>
      <TaxonName>Discaria nitida</TaxonName>

      <Description>
         <Character>
            <CharName>
               <textCharName>shrub</textCharName>
            </CharName>

            <State Type=3D"Text" Describes=3D"3DShape">
               <textCharState>slender</textCharState>
            </State>

            <State Type=3D"Text" measurementSystem=3D"metric" =
Describes=3D"height">
               <textCharState>to 5 m</textCharState>
            </State>
         </Character>

         <Character>
            <CharName>
               <textCharName>stems</textCharName>
            </CharName>

            <State Type=3D"Text" Describes=3D"pubescence">
               <textCharState>glabrous</textCharState>
            </State>
         </Character>

         <Character>
            <CharName>
               <textCharName>leaves</textCharName>
            </CharName>

            <State Type=3D"Text" Describes=3D"persistence">
               <Qualifier>rarely</Qualifier>

               <textCharState>deciduous</textCharState>

               <textCharState>persistent</textCharState>
            </State>

            <State Type=3D"Text" Describes=3D"PlaneShape">
               <textCharState>elliptic</textCharState>

               <textCharState>obovate</textCharState>

               <Connector>to</Connector>
            </State>

            <State Describes=3D"length" Type=3D"continuousNumeric" =
measurementSystem=3D"metric">
               <textCharState>(8-)10-20(-30) mm</textCharState>
            </State>

            <State Describes=3D"width" Type=3D"continuousNumeric" =
measurementSystem=3D"metric">
               <textCharState>3-7 mm</textCharState>
            </State>

            <State Type=3D"Text" Describes=3D"pubescence">
               <textCharState>glabrous</textCharState>
            </State>

            <State Type=3D"Text" Describes=3D"reflectance">
               <textCharState>shining</textCharState>
            </State>
         </Character>

         <Character>
            <CharName>
               <textCharName>spines</textCharName>
            </CharName>

            <State Type=3D"Text" Describes=3D"position">
               <textCharState>not developed at each =
node</textCharState>
            </State>

            <State Type=3D"Text" Describes=3D"length">
               <textCharState>to c. 1 cm</textCharState>
            </State>
         </Character>
      </Description>
   </Taxon>
</Example>



More information about the tdwg-content mailing list