XML Schema:特定元素的某些子元素的keyref

时间:2022-02-18 14:07:34

I need to write an XML Schema for this XML language:

我需要为这种XML语言编写一个XML Schema:

<wfInfo>
   <worflow name="wf1">
       <action name="act1" role="seller"/>
       <action name="act2" role="buyer"/>
       ...
   </workflow>

   <workflow  name="wf2">
       ...
   </workflow>

   <process workflow="wf1">
       <actionStatus action="act2" takenInCharge="true"/>
   </process> 

   <process ...> ... </process>
   ...
</wfInfo>

I managed to write almost every part of the schema, including most key and keyref elements. Anyway, there's one constraint i don't seem to be able to write. I want to make the attribute "action" of the element actionStatus point to the correct action, not any action in the document. I mean, in this case, in the validation process, it should be verified that action "act2" exists in workflow "wf1", not in any workflow. is it possible using W3C XML Schema language?

我设法编写了几乎所有模式的部分,包括大多数key和keyref元素。无论如何,有一个约束我似乎无法写。我想让元素actionStatus的属性“action”指向正确的操作,而不是文档中的任何操作。我的意思是,在这种情况下,在验证过程中,应该验证动作“act2”存在于工作流“wf1”中,而不是在任何工作流程中。是否可以使用W3C XML Schema语言?

Thanks, any answer will be much appreciated

谢谢,任何答案将不胜感激

1 个解决方案

#1


1  

You may be able to use key/keyref - but this would probably get quite messy.

你可能可以使用key / keyref - 但这可能会变得非常混乱。

A better approach may be to use another technology in addition to W3C XML Schema. Schematron, for example, can be useful in conjunction with schemas and is easy to add on and understand. Alternatively it would be easy to implement this dependency in code.

除了W3C XML Schema之外,更好的方法可能是使用另一种技术。例如,Schematron可以与模式结合使用,并且易于添加和理解。或者,在代码中实现这种依赖很容易。

Also, see: Restrict ID references to a particular element group

另请参阅:限制对特定元素组的ID引用

#1


1  

You may be able to use key/keyref - but this would probably get quite messy.

你可能可以使用key / keyref - 但这可能会变得非常混乱。

A better approach may be to use another technology in addition to W3C XML Schema. Schematron, for example, can be useful in conjunction with schemas and is easy to add on and understand. Alternatively it would be easy to implement this dependency in code.

除了W3C XML Schema之外,更好的方法可能是使用另一种技术。例如,Schematron可以与模式结合使用,并且易于添加和理解。或者,在代码中实现这种依赖很容易。

Also, see: Restrict ID references to a particular element group

另请参阅:限制对特定元素组的ID引用