Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mark element as deprecated in XSD

Tags:

deprecated

xsd

I have an XSD that's going through a transition from one set of elements to another. During the transition, there'll be code expecting the new elements and code expecting the old elements. Therefore I need to keep the old elements in the XSD; I'm documenting them as deprecated (using free text in an xs:documentation element).

Is there a way of marking an element as deprecated such that a tool like xmllint will automatically warn if someone uses a deprecated element?

like image 963
mopoke Avatar asked Dec 23 '09 00:12

mopoke


People also ask

What does complexType mean in XSD?

Definition and Usage The complexType element defines a complex type. A complex type element is an XML element that contains other elements and/or attributes.

What is XS choice in XSD?

<xsd:choice> ElementAllows one and only one of the elements contained in the selected group to be present within the containing element. Copy. <choice id = ID maxOccurs= (nonNegativeInteger | unbounded) : 1 minOccurs= nonNegativeInteger : 1 {any attributes with non-schema Namespace}...> Content: (annotation?, (

What is annotation tag in XSD?

Definition and Usage The annotation element is a top level element that specifies schema comments. The comments serve as inline documentation.

How do you make an element required in XSD?

The "use" property in the XSD definition is used to specify if the attribute is optional or mandatory. To specify that an attribute must be present, use="required" (Note: use may also be set to "prohibited", but we'll come to that later).


1 Answers

Create a new schema, with a new namespace. Call this "version 2". If you choose to support version 1 XSD and version 2 XSD in your application that's fine, but keep them seperate and don't try to layer the two on top of each other - especially if you're going try to stop people from using the version 1.

This is worth looking at as it describes some of what you're dealing with: archive of http://www.pluralsight.com/community/blogs/tewald/archive/2006/04/19/22111.aspx

I realise, however, that doesn't really address your question. With regard to "is there a way to do this?" the answer is "no - not in a universally supported manner". I've seen people add their own doc annotations to give hints, but this isn't going to be universally understood by tooling.

Your best bet in the long run is to create come up with a versioning story for your schema(s) and keep version 2 seperate from version 1.

like image 79
Martin Peck Avatar answered Oct 04 '22 06:10

Martin Peck