OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Problem with simple type restriction in schema

[ Lists Home | Date Index | Thread Index ]
  • To: <xml-dev@lists.xml.org>
  • Subject: Problem with simple type restriction in schema
  • From: "Volker Luedeling" <v.luedeling@brox.de>
  • Date: Fri, 4 Apr 2003 15:33:06 +0200
  • Thread-index: AcL6rrm8lxn8Y16TRQiolx85PgCM1Q==
  • Thread-topic: Problem with simple type restriction in schema

Hi all,

I am stuck with an XSD schema problem. I'm not sure if this is the right
place to ask, but maybe some of you can help me anyway.

I need to create an XML structure to configure Java classes with
parameters of different data types. Each parameter has a set of
attributes which are the same for all data types. Also, each parameter
has a value of the associated data type.

Here's what I have in mind for the resulting XML:

  <StringParameter Name="Param1" ... >(some string
  <FloatParameter Name="Param2" ... >(some float value)</FloatParameter>
  <DateParameter Name="Param3" ... >(some date value)</DateParameter>

To take advantage of the unique features of XML schemas, I want to have
all parameters defined in a common base type, and I want to have strong
type validation of the parameter values (FloatParameter, for example,
can only contain float values). 

So, what I need to do is derive subtypes from a base class ("Parameter")
which inherit all attributes, but constrain the element content to be of
type "int", "float", "date", "string" and so on.

I tried to do it in Altova's XML Spy, but I didn't find a way. With some
trial-and-error, I was able to write a schema which allowed validation
in Apache Xerces. However, XML Spy was unable to parse the schema and
delivered an error.

My base type definition:

  <xs:complexType name="Parameter">
      <xs:extension base="xs:anySimpleType">
        <xs:attribute name="Name" type="xs:string" use="required"/>
        <xs:attribute name="Comment" type="xs:string" use="optional"/>
        <xs:attribute name="Comment" type="xs:string" use="optional"/>

Definition of element "DateParameter":

  <xs:element name="DateParameter">
        <xs:restriction base="Parameter">
            <xs:restriction base="xs:date"></xs:restriction>

To me, this looks a little awkward, deriving a simpleContent from a
complexType, but it works for Xerces. Can anyone tell me if this
declaration is valid, or, if not, whether there is a "legal" way to
solve my problem?

Thanks in advance for any help you can offer.



News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS