Gronnie
Member
For some reason can't get this code to work. It looks correct to me, but Oxygen tells me it is not valid because:
If anyone could take a look at it and help me figure out what the heck is wrong I would appreciate it.
presentations2.xml
presentations2.rng
Closed at OP's request
Markbnj
Programming mod
Code:
Description: a group of attributes must not be repeatable
(section 7.1 of the RELAX NG specification requires that the simplified XML
form of the schema not contain any elements matching the path
oneOrMore//group//attribute)
Severity: Error
Engine name: Jing
Start location line: 79, column: 38
presentations2.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="presentations2.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<presentations>
<presentation date="2013-07-31" length="PT30M">
<topic genre="Music">PianoML</topic>
<presenters>
<name title="Mr." id="Y258">
<first>Elvis</first>
<middle>A</middle>
<last>Presley </last>
</name>
<name title="Miss" id="X365">
<first>Lady</first>
<last>Gaga</last>
</name>
</presenters>
</presentation>
<presentation date="2013-08-05" length="PT35M">
<topic genre="Science">AlienML</topic>
<presenters>
<name title="Mr." id="Y007">
<first>Will</first>
<last>Smith</last>
</name>
<name title="Mr." id="Y360">
<first>Tommy</first>
<first>Lee</first>
<last>Jones</last>
</name>
</presenters>
</presentation>
</presentations>
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Define namespaces and libraries -->
<grammar xmlns="http://relaxng.org/ns/structure/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<!-- Define date attribute of type date globally. -->
<define name="dateAtt">
<attribute name="date">
<data type="date"/>
</attribute>
</define>
<!-- Define length attribute of type string globally. -->
<define name="lengthAtt">
<attribute name="length">
<data type="string"/>
</attribute>
</define>
<!-- Define topic element with attribute genre globally. -->
<define name="topicElement">
<ref name="genreAtt"/>
</define>
<!-- Define name element with id and title attributes, one or more first name child elements, zero or one middle name child elements, and a last name child element globally. -->
<define name="nameElement">
<ref name="idAtt"/>
<ref name="titleAtt"/>
<oneOrMore>
<element name="first">
<data type="string"/>
</element>
</oneOrMore>
<optional>
<element name="middle">
<data type="string"/>
</element>
</optional>
<element name="last">
<data type="string"/>
</element>
</define>
<!-- Define title attribute globally. Restrict possible values to Mr. Mrs. Ms. or Miss -->
<define name="titleAtt">
<attribute name="title">
<choice>
<value type="token">Mr.</value>
<value type="token">Mrs.</value>
<value type="token">Ms.</value>
<value type="token">Miss</value>
</choice>
</attribute>
</define>
<!-- Define id attribute of type id globally. Must follow patter or an X or a Y follwed by three digits. -->
<define name="idAtt">
<attribute name="id">
<data type="token">
<param name="pattern">[XY]\d{3}</param>
</data>
</attribute>
</define>
<!-- Define genre attribute globally. Restrict possible values to the choics of Art, Music, Science, or Technology. -->
<define name="genreAtt">
<attribute name="genre">
<choice>
<value type="token">Art</value>
<value type="token">Music</value>
<value type="token">Science</value>
<value type="token">Technology</value>
</choice>
</attribute>
</define>
<!-- Put everything together. -->
<start>
<!-- Root element is presentations -->
<element name="presentations">
<!-- There are zero or more presentation elements each with attributes date and length and elements topic and presenters. -->
<zeroOrMore>
<element name="presentation">
<ref name="dateAtt"/>
<ref name="lengthAtt"/>
<ref name="topicElement"/>
<!-- The element presenters has one or more name elements. -->
<element name="presenters">
<oneOrMore>
<!-- Name element is defined globally and has children first middle and last. -->
<ref name="nameElement"/>
</oneOrMore>
</element>
</element>
</zeroOrMore>
</element>
</start>
</grammar>
Closed at OP's request
Markbnj
Programming mod
Last edited by a moderator: