我正在尝试使用 RELAX-NG 为一些 XML 文档编写模式,当我将它与 jing 一起使用时,我收到一条我不明白的错误消息:
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
谁能解释为什么并帮助我解决问题?
这是一个示例文档(为简单起见而设计):
列表-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>
这是一个可以正常工作的架构:
列表-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 }
}
但是当我尝试text
用特定的文本模式替换通用节点时,我得到了错误。
列表-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]*)*" }
}