0

我有一个这样的 xml 文档:

<root>
   <text>
       <ID>01</ID>
       <weight>1</weight>
       <word>attend</word>
       <note>important</note> 
   </text>  
   <text>
       <note>very important</note> 
       <ID>01</ID>
       <weight>1</weight>
       <word>slow</word>
   </text>

规则是:id、weight、word必须按顺序作为text节点的子节点出现,note节点可以出现在id节点之前或之后。所以我的DTD是:

<!ELEMENT text (note?, ID, weight, word, note?)>

但是 xml 编辑器说“这不是决定论”。为什么?

4

1 回答 1

0

使用此XML文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE root SYSTEM "test.dtd">
<root>
    <text>
        <ID>01</ID>
        <weight>1</weight>
        <word>attend</word>
        <note>important</note> 
    </text>  
    <text>
        <note>very important</note> 
        <ID>01</ID>
        <weight>1</weight>
        <word>slow</word>
    </text>
</root>

这个DTD文件:

<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT root (text+) >
<!ELEMENT text (note?, ID, weight, word, note?)>
<!ELEMENT note (#PCDATA) >
<!ELEMENT ID (#PCDATA) >
<!ELEMENT weight (#PCDATA) >
<!ELEMENT word (#PCDATA) >

文档有效,没有错误(Oxygen Xml Editor 14.2)

于 2013-09-25T08:31:35.587 回答