Jump to content

Redefinition of a any field in a complextype.


Recommended Posts

Hi,I'm defining a webservice and therefor defined some types.One of the complex types I use is a paging list type see example:

	<xs:complexType name="pagedListType">		<xs:sequence>			<xs:element ref="pag:totalSize"/>			<xs:element ref="pag:pagingContext"/>			<xs:element name="dataItems" type="pag:listOfAnyType"/>		</xs:sequence>	</xs:complexType>	<xs:complexType name="listOfAnyType">		<xs:sequence minOccurs="0" maxOccurs="unbounded">			<xs:any processContents="lax"/>		</xs:sequence>	</xs:complexType>

The goal is to define a complextype where a specific field can be rewritten to a concrete type.In the example from a above I want to reuse the pagedListType.If type needs to return accounts I want to redefine just that particular field.This could be a list of accounts or a list of persons.Is this possible at all?Regards Dirk

Link to post
Share on other sites

There are the so called "abstract" types in XML Schemas, but they require alteration of the XML itself to define the concrete type.If this is OK for you, you can specify the abstract attribute on the complex type, make any derivatives you want off of it (e.g. accounts, persons) where you get more specific, and when creating the XML document, add the type in a fashion similar to the one described here.

Link to post
Share on other sites

Hi Thanks for your reply which helps me further.The only question which rise where I couldn't found a answer.In the code example I created a simple paged list with a abstract element 'dataItems'.I created 2 concrete elements of dataItems: car and plane.Can I define a concrete pagedList where only cars are alowed an another pagedList where only planes are alowed?I can imagine this is not possible but couldn't find an anwer on the net.Thanks in advance Dirk

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">	<xs:element name="dataItems" abstract="true"/>	<xs:element name="totalSize" type="xs:int"/>	<xs:complexType name="pagedListType">		<xs:sequence>			<xs:element ref="totalSize"/>			<xs:element ref="dataItems"/>		</xs:sequence>	</xs:complexType>	<xs:element name="car" type="xs:string" substitutionGroup="dataItems"/>	<xs:element name="plane" type="xs:string" substitutionGroup="dataItems"/>	<xs:element name="carsPagedList" type="pagedListType"/></xs:schema>

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...