Relax NG Compact Question
Posted: Sat Nov 17, 2007 2:23 am
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:
Here's what I've got so far:
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?
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:
- 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.
- 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.
- Courses should be recursive.
- 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.
- 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.
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}?
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?