开发者

XSD Problem: How to only restrict an element/attribute to be used under another schema

I need to solve this and looks like I need help.

Here is the problem definition

We have an existing schema X [X is an industry standard schema] for which we are building some extensions in a new schema Y (with a different target namespace].

Now the problem is we want to restrict usage of the elements/attributes of Schema Y to be only as members of defined elements/types of X. [schema validation should fail in case of invalid usage].

How do we achieve this? What is the best way to do this?

开发者_JS百科

RM


I'd say it depends on how much you are modifying and what the schemas look like. One aspect will be if your extensions are near the root or near the leafs.

Here is a general approach for near the root.

X.xsd
element name=foo type=fooType

complexType fooType
  sequence
     element name=bar type=BarType

Y.xsd
import X.xsd namespace=xns

element name=foo type=foo2Type

complexType foo2Type
  sequence
     element name=bar type=xns:BarType
     element name=baz type=BazType

here you have added a new element baz of your own definition but bar will contain all the children required by the industry standard.

Import X into Y (with the import element).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜