Relax NG Compact Question

Questions about XML that are not covered by the other forums should go here.
Zearin
Posts: 107
Joined: Mon Jul 30, 2007 11:31 pm
Location: College Park, MD, United States

Relax NG Compact Question

Post by Zearin »

Hello,

I'm new to RelaxNG, and I love both the normal and the compact version. I'm using the compact version for now because it's…well, compact!

I'm working on a schema that defines 2 elements: course, and courses (for grouping multiple course elements).

Here are my design goals:
  1. This schema should be able to "mix in" well with other schemas. it is one component of a project I'm working on. This project uses several schemas. This is simply the one I am currently focused on.
  2. For the purposes of this schema, Courses will serve as the start element. However, in an XML document that uses this schema AND other schemas, Courses may not necessarily be the root element.
  3. Courses should be recursive.
  4. The @dept attribute…
    • Is a required attribute of Course elements
    • Is an optional attribute of Courses elements. If specified on a Courses element:
      • no further Courses elements can be nested within
      • All contained Course elements are now forbidden to specify their own @dept (it should be considered inherited from the container)
    • The @dept value should contain an IDREF an element specified elsewhere.
  5. Course elements can specify all of their values locally, or they may reference an already-declared Course element. If this referenced Course doesn't specify all of its attributes, then the "calling" Course can "fill these values in" if desired.
I'm only partially there, but I'm getting some errors I can't seem to shake. If you can fulfill all of the above, GREAT! If not, forget all that stuff about referencing predeclared elements and focus on the recursive Courses and the restrictions introduced when a Courses element specifies as @dept value.

Here's what I've got so far:

Code: Select all


namespace rng = "http://relaxng.org/ns/structure/1.0"
datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes"


start = element courses {
(
attribute dept {externalRef},
course+
) | courses*
}


course = element course {
course.attlist
}


course.attlist =
attribute dept {xsd:string},
attribute number {xsd:string},
attribute credits {xsd:nonNegativeInteger{} },
attribute grade {xsd:string{ minLength="1" maxLength="2"} }?,
attribute title {xsd:string}?,
attribute description {xsd:string}?
I'm getting an error both for the "externalRef" on courses/@dept and for a "reference to undefined pattern 'courses'". I'm not sure what that means, since this error exists right in the middle of specifying the courses pattern itself.

As you can see I haven't gotten around to the restrictions involved with @dept. I don't know how to proceed with this, but I would like to solve the other errors first if possible.

Does anybody know how to satisfy these conditions?
-- Zearin
Zearin
Posts: 107
Joined: Mon Jul 30, 2007 11:31 pm
Location: College Park, MD, United States

Bump

Post by Zearin »

Bump?
-- Zearin
Post Reply