PDA

View Full Version : Help with schema


jfindon
05-15-2006, 06:13 PM
Before anyone says anything about me asking for homework help, once again I bought this book to try to learn XML by myself. Rather than try to explain it I figure I would just post a picture of the exercise I'm trying right now along with code that I did in the exercise before this. I would just like to know how this relates to the supplied code, because the code I am posting was explained in the book every step of the way. Now they throw you into this one and don't tell you anything and I can't piece the terms together.

I only see the global elements clearly I think, that looks like what I have in the code I already did. The derived data types are throwing me off though and I don't know where to put those.

http://img125.imagevenue.com/loc277/th_61933_100NIKON_DSCN4113_DSCN4113.JPG (http://img125.imagevenue.com/img.php?loc=loc277&image=61933_100NIKON_DSCN4113_DSCN4113.JPG)

<?xml version="1.0" encoding="UTF-8"?>
<!-- Schema for breast cancer studies -->

<xsd:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://uhosp/studies/ns"
targetNamespace="http://uhosp/studies/ns">

<xsd:element name="Study">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Name">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Title" />
<xsd:element name="Subtitle" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="PI" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>

</xsd:schema>

KC-Luck
05-15-2006, 06:58 PM
you want to make them global simple types, that you can then point to from other elements, attribute @types.


<xsd:simpleType name="PType">
<xsd:restriction base="xs:int">
<xsd:minInclusive="1"/>
<xsd:maxInclusive="3"/>
</xsd:restriction>
</xsd:simpleType>

used other places in schema like:
<xsd:attribute name="type" type="PType" use="required"/>

This PIType could just as easily been a xsd pattern restriction where [1-3] is the value.