local schema for listitem

Tim Bergsma tbergsma at kbs.msu.edu
Tue Dec 17 10:17:28 PST 2002


Hi.  Got a nasty schema problem that I can't seem to solve.

EML requires that a listitem contain text only in paragraphs.  That's
fine for EML, but gets really hard on the eyes when authoring.

I have a local schema kbsml_text.xsd that subsets and arranges html so
that it converts easily to eml.  I figured I'd let local listitem
authors omit the paragraph tags if they only wanted to write a simple
string of text.  Then, my eml style sheet would check for the presence
of the paragraph tag, and supply it if missing.  Essentially I want
"paragraph without the tags" as an alternative content model for
listitem.

Unfortunately, paragraph itself is mixed model, whereas listitem content
is otherwise strict.  But I only get to specify "mixed" on the
complexType as a whole, which allows (validates) stray text even when
the strict model is followed:

<xs:complexType name="ListType">
  <!--12-17-2002 Tim Bergsma.  Adding a simple string as
    an alternative to highly structured 'li' content.-->
   <xs:sequence>
    <xs:element name="li"  minOccurs="1" maxOccurs="unbounded">
    <xs:complexType mixed="true">
      <xs:choice minOccurs="1" maxOccurs="1">
        <xs:choice minOccurs="1" maxOccurs="unbounded">
        <xs:element name="p" type="ParagraphType"/>
        <xs:element name="ul" type="ListType"/>
        <xs:element name="ol" type="ListType"/>
      </xs:choice>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="em" type="xs:string"/>
        <xs:element name="sub" type="SubSuperScriptType"/>
        <xs:element name="sup" type="SubSuperScriptType"/>
        <xs:element name="img" type="ImageType"/>
        <xs:element name="a" type="AnchorType"/>
      </xs:choice>
    </xs:choice>
    </xs:complexType>
    </xs:element>
   </xs:sequence>
  </xs:complexType>

Choice of independent complexTypes doesn't work, since the content of
choice must be element, choice, group, sequence, etc.  Using an element
doesn't work, because name is required, and therefore, tags (e.g.
paragraph wrapper).  I tried creating two listItemTypes, and invoking
them higher up with a choice of two types having the same name; but the
names in a list of choices must be unique.  

Any ideas?

Thanks,

Tim

P.S.  I haven't shown the whole schema, but a valid instance follows.

<kbsml_text>
<p>
<ol>
<li>This is a bad place for text. I wish it would not validate.
<p>this is text in a paragraph.
</p>
</li>
<li>
<p>This is more text <em>in</em> a paragraph.
</p>
</li>
<li>this is some text <em>not</em> in a paragraph.</li>
</ol>
</p>
</kbsml_text>
-- 
Tim Bergsma
LTER Information Manager
W.K. Kellogg Biological Station
Michigan State University
Hickory Corners, MI   49060
629/671-2337
tbergsma at kbs.msu.edu
http://lter.kbs.msu.edu



More information about the Eml-dev mailing list