以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 DTD/XML Schema 』  (http://bbs.xml.org.cn/list.asp?boardid=23)
----  choice中对其中元素中包含的相同element认为重复,请问如何解决?谢谢!  (http://bbs.xml.org.cn/dispbbs.asp?boardid=23&rootid=&id=26637)


--  作者:waynezhu
--  发布时间:1/20/2006 10:07:00 AM

--  choice中对其中元素中包含的相同element认为重复,请问如何解决?谢谢!
如下定义中,在验证时提示xa:correlatedNotifications、xa:additionalText重复,主要是因为choice中出现了包含它们的两个group,这很奇怪,有没有办法解决?谢谢


<group name="NotifyNewAlarmBodyElements">
  <sequence>
   <element ref="xa:probableCause"/>
   <element ref="xa:perceivedSeverity"/>
   <element ref="xa:alarmType"/>
   <choice>
    <group ref="xa:StandardNotifyNewAlarmBodyElements"/>
    <group ref="xa:SecurityNotifyNewAlarmBodyElements"/>
   </choice>
   <element ref="xa:alarmID"/>
  </sequence>
 </group>
 <group name="StandardNotifyNewAlarmBodyElements">
  <sequence>
   <element name="specificProblem" type="string" minOccurs="0"/>
   <element ref="xa:correlatedNotifications" minOccurs="0"/>
   <element name="backedUpStatus" type="boolean" minOccurs="0"/>
   <element name="backupObject" type="xe:DN" minOccurs="0"/>
   <element name="trendIndication" type="xa:TrendIndicator" minOccurs="0"/>
   <element name="thresholdInfo" type="xa:ThresholdInfo" minOccurs="0"/>
   <element name="stateChangeDefinition" type="xa:AttributeValueChangeSet" minOccurs="0"/>
   <element name="monitoredAttributes" type="xa:AttributeValueSet" minOccurs="0"/>
   <element name="proposedRepairActions" type="string" minOccurs="0"/>
   <element ref="xa:additionalText" minOccurs="0"/>
   <element ref="xa:additionalInformation" minOccurs="0"/>
  </sequence>
 </group>
 <group name="SecurityNotifyNewAlarmBodyElements">
  <sequence>
   <element ref="xa:correlatedNotifications" minOccurs="0"/>
   <element ref="xa:additionalText" minOccurs="0"/>
   <element name="serviceUser" type="string"/>
   <element name="serviceProvider" type="string"/>
   <element name="securityAlarmDetector" type="string"/>
  </sequence>
 </group>


--  作者:98900969r
--  发布时间:1/25/2006 7:18:00 PM

--  
写schema一定得遵守所谓的unambigious原则,即要让验证器看到当前标签(而不用往下看)就知道接下来可以出现什么,不能出现什么。你的例子中确实有违背这一原则的地方,那就是,当处理NotifyNewAlarmBodyElements元素时,走到
   <choice>
    <group ref="xa:StandardNotifyNewAlarmBodyElements"/>
    <group ref="xa:SecurityNotifyNewAlarmBodyElements"/>
   </choice>
这里,如果碰到的是xa:correlatedNotifications,这时处理器不能确定现在是一个xa:StandardNotifyNewAlarmBodyElements,还是一个xa:SecurityNotifyNewAlarmBodyElements。除非接着往下看。但是XML Schema规定了这样的schema就是ambigious的,不允许出现。

为什么会有这个unambigious原则呢?因为XML Schema的制定者相信,要往后看2次以上的话,验证器的效率就会很低。


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
1,054.688ms