开发者

Redefine xsd element

I am trying to redefine an element definition contained in an external xsd (that I cannot modify) which looks like this:

<xsd:element name="view-controller">
    <xsd:complexType>
        <xsd:attribute name="path" type="xsd:string" use="required" />
        <xsd:attribute name="view-name" type="xsd:string" />
    </xsd:complexType>
</xsd:element>

This defines elements such as:

<mvc:view-controller path="/path" view-name="server/view/etc" />

How do I extend it so that I can create elements with 2 additional attributes (foo and bar)?

See this example below for the end result I need:

<mvc:view-controller path="/path" view-name="server/view/etc" foo="stuff" bar="more stuff" />

What I tried:

<xsd开发者_开发知识库:redefine schemaLocation="http://www.domain.org/schema/correct-path.xsd">
    <xsd:simpleType name="view-controller">
        <xsd:complexContent>
            <xsd:extension base="view-controller">
                <xsd:attribute name="foo" type="xsd:string" />
                <xsd:attribute name="bar" type="xsd:string" />
            </xsd:extension>
        </xsd:complexContent>
    </xsd:simpleType>
</xsd:redefine>

However this doesn't work.

I cannot seem to find any resource detailing how to redefine an xsd:element containing attributes, which I believe is the problem here.

Please comment if more info is required.


You can't have a complexContent inside a simpleType, it doesn't make sense.

Also, the only things you can redefine are : simpleType, complexType, group, attributeGroup. So you can't redefine an element. You could change its type only if it has a named type, which doesn't seem to be the case in your example.

See http://www.w3.org/TR/xmlschema-0/#Redefine for more info.


@Razor, you mean you don't want to modify the existing xsd but want to create one more xsd which alters element properties??

if that is the case then I think its almost impossible! errors like definition already existstrouble ..

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜