开发者

XSD Key/KeyRef and how to reference

开发者 https://www.devze.com 2023-02-07 13:35 出处:网络
We use XML to define a model which we later use to generate code. The file looks something like this:

We use XML to define a model which we later use to generate code. The file looks something like this:

<def xmlns="http://tempuri.org/schema.xsd" xmlns:xsi="http://tempuri.org/schema.xsd"&开发者_StackOverflow中文版gt;
  <ns xmlns=""  name="asd">
    <alias name="NicknameType" ref="String" />
    <alias name="SomethingType" ref="o3" />

    <obj1 name="o1">
       <element name="Nick" ref="NicknameType" />
    </obj1 >

    <obj2 name="o2">
        <action name="a1">
            <attribute name="TheObject1" ref="o1" />
        </action>
    </obj2 >

    <obj3 name="o3">
        <element name="SomeText" ref="int32" />
    </obj3 >
  </ns>
</def>

What I would really like to enforce is that the ref-attribute of any tag matches the name tag of either an alias-tag, an obj1-tag or an obj2 tag or some predefined values such as String or int32. I already defined the general structure that the file has to have in XSD. Is what I would like to achieve even possible with XSD?

Thanks


It's possible in XSD 1.1, using assertions, but not in XSD 1.0.

The latest releases of the schema processors in Saxon and Xerces both have support for assertions.

0

精彩评论

暂无评论...
验证码 换一张
取 消