xml - relaxng: invalid schema definition? -
i'm trying write schema xml documents using relax-ng, , when use jing, error message don't understand:
c:\tmp\xml>java -jar jing.jar -c list-test2.rnc list-test.xml c:\tmp\xml\list-test2.rnc:6:10: error: repeat of "string" or "data" element
can explain why , me workaround?
here sample document (contrived simplicity):
list-test.xml:
<?xml version="1.0" encoding="utf-8"?> <list-test> <list name="list1"> foo.bar.baz quux be.bop.a.loo.bop <hole name="somename" /> tutti.frutti abc678.foobar </list> <list name="list2"> test1 test2 test3 <hole name="hole1" /> <hole name="hole2" /> test4 <hole name="hole3" /> </list> </list-test>
here schema works ok:
list-test.rnc:
grammar { start = element list-test { list-test-content } list-test-content = (element list { list-content })* list-content = attribute name { text }, (text | hole-element)* hole-element = element hole { hole-content } hole-content = attribute name { text } }
but when try replace generic text
nodes specific text patterns, error.
list-test2.rnc:
grammar { start = element list-test { list-test-content } list-test-content = (element list { list-content })* list-content = attribute name { identifier }, (qualified-identifier | hole-element)* hole-element = element hole { hole-content } hole-content = attribute name { identifier } identifier = xsd:token { pattern="[a-za-z_][a-za-z_0-9]*" } qualified-identifier = xsd:token { pattern="[a-za-z_][a-za-z_0-9]*(\.[a-za-z_][a-za-z_0-9]*)*" } }
you've bumped against 1 of relax ng's basic limitations: element's content can complex (with text patterns, element patterns, sequence patterns, interleave patterns, , quantifier patterns) or simple (with data patterns, value patterns, , list patterns), not both @ same time. (of course, it's possible have choice between complex , simple content.)
you can't better use text here, , maybe write schematron rule or two.
Comments
Post a Comment