Skip
repetitive navigational links
L-Soft  -  Home of  the  LISTSERV  mailing list  manager LISTSERV(R) 14.5
Skip repetitive navigational links
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (December 2004)Back to main MODS pageJoin or leave MODSReplyPost a new messageSearchProportional fontNon-proportional fontLog in
Date:         Fri, 10 Dec 2004 21:46:42 -0500
Reply-To:     Metadata Object Description Schema List <[log in to unmask]>
Sender:       Metadata Object Description Schema List <[log in to unmask]>
From:         Bruce D'Arcus <[log in to unmask]>
Subject:      RELAX NG vs. XML Schema, and alternative MADS suggestion
Comments: To: Metadata Object Description Schema List <[log in to unmask]>
Content-Type: text/plain; charset=US-ASCII; format=flowed

I just threw together a quick demo of my thinking about the structure of MADS, and of the beauty of RELAX NG (in contrast to XML Schema). So I use the compact syntax, because it's easier to work with than the verbose XML; so easy, in fact, that I can write the schema with the simplest of text editors. Anyway, here's the schema (again, just a demo): === default namespace = "http://www.loc.gov/mads" ## root is either a single mads element, or more than one MADS ## element wrapped in a madsCollection start = MADS | MADS_Collection ## there is only a single main element, with a choice between ## person and work here (but would be extended in a full schema) MADS = element mads { Person | Work } MADS_Collection = element madsCollection { MADS+ } ## person element contains all related content div { Person = element person { PersonName, Affiliation*, Address* } ## All main content is divided between a single authority (I'd prefer "primary" myself) ## element and zero or more variants PersonName = element name { Name-Authority, Name-Variant* } Name-Authority = element authority { NameParts-Person } Name-Variant = element variant { NameParts-Person, Variants-Attributes } NameParts-Person = NamePart-Given* & NamePart-Family* NamePart-Given = element givenname { text } NamePart-Family = element familyname { text } Affiliation = element affiliation { text } Address = element address { text } } ## Work div { Work = element work { Title } Title = element title { Title-Authority, Title-Variant* } Title-Authority = element authority { Titles } Title-Variant = element variant { Titles } Titles = TitleMain, SubTitle? TitleMain = element titleMain { text } SubTitle = element titleSub { text } } Variants-Attributes = attribute type { "abbreviation" | "alternate" | "equivalent" }? === Here's the same schema automatically converted to (compliant!) XML Schema via Trang: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.loc.gov/mads" xmlns:mads="http://www.loc.gov/mads"> <xs:element name="mads"> <xs:complexType> <xs:choice> <xs:element ref="mads:person"/> <xs:element ref="mads:work"/> </xs:choice> </xs:complexType> </xs:element> <xs:element name="madsCollection"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" ref="mads:mads"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="person"> <xs:complexType> <xs:sequence> <xs:element ref="mads:name"/> <xs:element minOccurs="0" maxOccurs="unbounded" ref="mads:affiliation"/> <xs:element minOccurs="0" maxOccurs="unbounded" ref="mads:address"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="name"> <xs:complexType> <xs:sequence> <xs:group ref="mads:Name-Authority"/> <xs:group minOccurs="0" maxOccurs="unbounded" ref="mads:Name-Variant"/> </xs:sequence> </xs:complexType> </xs:element> <xs:group name="Name-Authority"> <xs:sequence> <xs:element name="authority" type="mads:NameParts-Person"/> </xs:sequence> </xs:group> <xs:group name="Name-Variant"> <xs:sequence> <xs:element name="variant"> <xs:complexType> <xs:complexContent> <xs:extension base="mads:NameParts-Person"> <xs:attributeGroup ref="mads:Variants-Attributes"/> </xs:extension> </xs:complexContent> </xs:complexType> </xs:element> </xs:sequence> </xs:group> <xs:complexType name="NameParts-Person"> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element ref="mads:givenname"/> <xs:element ref="mads:familyname"/> </xs:choice> </xs:complexType> <xs:element name="givenname" type="xs:string"/> <xs:element name="familyname" type="xs:string"/> <xs:element name="affiliation" type="xs:string"/> <xs:element name="address" type="xs:string"/> <xs:element name="work" type="mads:Title"/> <xs:complexType name="Title"> <xs:sequence> <xs:element ref="mads:title"/> </xs:sequence> </xs:complexType> <xs:element name="title"> <xs:complexType> <xs:sequence> <xs:group ref="mads:Title-Authority"/> <xs:group minOccurs="0" maxOccurs="unbounded" ref="mads:Title-Variant"/> </xs:sequence> </xs:complexType> </xs:element> <xs:group name="Title-Authority"> <xs:sequence> <xs:element name="authority" type="mads:Titles"/> </xs:sequence> </xs:group> <xs:group name="Title-Variant"> <xs:sequence> <xs:element name="variant" type="mads:Titles"/> </xs:sequence> </xs:group> <xs:complexType name="Titles"> <xs:sequence> <xs:element ref="mads:titleMain"/> <xs:element minOccurs="0" ref="mads:titleSub"/> </xs:sequence> </xs:complexType> <xs:element name="titleMain" type="xs:string"/> <xs:element name="titleSub" type="xs:string"/> <xs:attributeGroup name="Variants-Attributes"> <xs:attribute name="type"> <xs:simpleType> <xs:restriction base="xs:token"> <xs:enumeration value="abbreviation"/> <xs:enumeration value="alternate"/> <xs:enumeration value="equivalent"/> </xs:restriction> </xs:simpleType> </xs:attribute> </xs:attributeGroup> </xs:schema> === And here's a simple example instance created against the above schema: <mads xmlns="http://www.loc.gov/mads" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/mads file:/Users/darcusb/Desktop/mads/mads-alt.xsd"> <person> <name> <authority> <givenname>John</givenname> <familyname>Doe</familyname> </authority> <variant type="alternate"> <givenname>Jonathan</givenname> <familyname>Doe</familyname> </variant> </name> </person> </mads> I think the structure of the schema more sense. Consider the xpath expression for the name authority: mads:mads/mads:person/mads:name/mads:authority ... and for all variants: mads:mads/mads:person/mads:name/mads:variant Also, the validation is MUCH tighter. From what I gather of the current MADS draft, it would be perfectly valid (though also perfectly wrong) to have an authority for a name, but a variant element that contained a title. With this structure, there is no such sloppiness; content is tailored to each top-level element. Consider the technical issues too: the RELAX NG source is much easier to work with (there's a reason why major schemas like OpenOffice and DocBook are developed in RELAX NG and not XML Schema), and the same source produces a clean XML Schema without the obvious bugs in XMLSpy. Bruce


Back to: Top of message | Previous page | Main MODS page

LISTSERV.LOC.GOV CataList email list search Powered by LISTSERV email list manager