Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between xs:redefine and xs:override in XML schema 1.1

What is the difference between <xs::redefine> and <xs::override> in XML schema 1.1. I've got two books on XML Schema in front of me and I still can't tell the difference. The only thing that I'm sure of is that both are pervasive and that <xs::redefine> is deprecated.

like image 545
Olumide Avatar asked Feb 03 '14 10:02

Olumide


People also ask

What is Xs in XML schema?

1.1 The Schema Namespace ( xs ) The XML representation of schema components uses a vocabulary identified by the namespace name http://www.w3.org/2001/XMLSchema . For brevity, the text and examples in this specification use the prefix xs: to stand for this namespace; in practice, any prefix can be used.

What is complexType and simpleType in XSD?

XSD elements can be of type simpleType , complexType , or anyType . An element of type simpleType contains only text. It cannot have attributes and elements. An element of type complexType can contain text, elements, and attributes.

What is XS simpleType?

The xs:simpleType Component. Defines a simple type. A simple type definition is a set of constraints on strings and information about the values they encode, applicable to the normalized value of an attribute information item or of an element information item with no element children.

How do you define attributes for simple element in XSD?

Attributes are defined within an XSD as follows, having name and type properties. An Attribute can appear 0 or 1 times within a given element in the XML document. Attributes are either optional or mandatory (by default the are optional).


2 Answers

Using redefine you can extend or restrict a component (complex types, simple types, model groups and attribute groups). So, you reuse the original definition of the component and you extend or restrict it.

The override allows you to replace the definition of a component. So, you create a new component with the same name that replaces the original definition. You can override any top-level named component (complex types, simple types, element declarations, attributes declarations, model groups, attribute groups and notations).

You can read more about the override here: http://www.w3.org/TR/xmlschema11-1/#override-schema Or you can read the Roger Costello XML Schema 1.1 tutorial: http://www.xfront.com/xml-schema-1-1/index.html

I also recommend Priscilla Walmsley book: "Definitive XML Schema, 2nd Edition"

Regards, Octavian

like image 86
Octavian Avatar answered Sep 21 '22 17:09

Octavian


Excerpt from http://www.w3.org/TR/xmlschema11-1/#override-schema

The <redefine> construct defined in Including modified component definitions () (§4.2.4) is useful in schema evolution and versioning, when it is desirable to have some guaranteed restriction or extension relation between the old component and the redefined component. But there are occasions when the schema author simply wants to replace old components with new ones without any constraint. Also, existing XSD processors have implemented conflicting and non-interoperable interpretations of , and the <redefine> construct is ·deprecated·. The <override> construct defined in this section allows such unconstrained replacement.

Note: The redefinition feature described in the remainder of this section is ·deprecated· and may be removed from future versions of this specification. Schema authors are encouraged to avoid its use in cases where interoperability or compatibility with later versions of this specification are important.

<xs:redefine> puts constraints on already defined elements which is not compatible with some of the xml parsers. <xs:override> does essentially what <xs:redefine> had been doing but is more flexible in terms of changing the whole element definition without any regard to the already defined one. XML parsers need not to worry about checking the previously defined elements where <xs:override> is used, but not the case with <xs:redefine>.

like image 42
IndoKnight Avatar answered Sep 20 '22 17:09

IndoKnight