[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

AW: alternate attribute types in xsd

Subject: AW: alternate attribute types in xsd
From: "Dr. Patrik Stellmann patrik.stellmann@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 7 Aug 2017 04:29:00 -0000
AW:  alternate attribute types in xsd
You can get the desired behavior already with the current capabilities - just
by providing alternative types for the res element:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
  <xs:element name="res" type="res-base">
    <xs:alternative test="@class = 'thing'" type="res-thing"/>
    <xs:alternative test="@class = 'being'" type="res-being"/>
  </xs:element>
  <xs:complexType name="res-base">
    <xs:attribute name="id"/>
    <xs:attribute name="class" type="class-type" use="required"/>
  </xs:complexType>
  <xs:complexType name="res-thing">
    <xs:complexContent>
      <xs:extension base="res-base">
        <xs:attribute name="type" type="thing-type"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="res-being">
    <xs:complexContent>
      <xs:extension base="res-base">
        <xs:attribute name="type" type="being-type"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:simpleType name="class-type">
    <xs:restriction base="xs:NMTOKEN">
      <xs:enumeration value="concept"/>
      <xs:enumeration value="thing"/>
      <xs:enumeration value="being"/>
      <xs:enumeration value="reference"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="thing-type">
    <xs:restriction base="xs:NMTOKEN">
      <xs:enumeration value="object"/>
      <xs:enumeration value="place"/>
      <xs:enumeration value="conveyor"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="being-type">
    <xs:restriction base="xs:NMTOKEN">
      <xs:enumeration value="mineral"/>
      <xs:enumeration value="vegetable"/>
      <xs:enumeration value="animal"/>
      <xs:enumeration value="spiritual"/>
    </xs:restriction>
  </xs:simpleType>
</xs:schema>


Patrik

>
------------------------------------------------------------------
Systemarchitektur & IT-Projekte
Tel: +49 40 33449-1142
Fax: +49 40 33449-1400
E-Mail: mailto:Patrik.Stellmann@xxxxxxxxx

-----UrsprC<ngliche Nachricht-----
> Von: Andre Cusson akhu01@xxxxxxxxx [mailto:xsl-list-
> service@xxxxxxxxxxxxxxxxxxxxxx]
> Gesendet: Freitag, 4. August 2017 21:59
> An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Betreff: Re:  alternate attribute types in xsd
>
> Hi Wolfgang,
>
> Thank you for your reply.
>
> It seems as if an element can have a type determined from a value of its
attributes,
> attributes in that element should also be able to have their types
determined by
> other attributes of the element.
>
> Here is a simple example. The key, and currently unsupported (cant
validated),
> type definition is the type-type simple type for the type attribute of the
res
> element, in the schema sample below..
>
> The exact syntax (ex: within an xs:restriction) is not that important, it is
really the
> fact that the attribute type is to be validated according to attribute
value(s) or
> xpath boolean function, in the element, just as is currently possible for
the element
> type.
>
> Of course, attribute types still need to be simple types, and the context is
defined
> by the enclosing element, just as for the element value.
>
> <xs:schema elementFormDefault="qualified"
> attributeFormDefault="unqualified" vc:minVersion="1.1">
>   <xs:element name="res">
>     <xs:complexType>
>       <xs:attribute name="id" type="identifier" use="required"/>
>       <xs:attribute name="class" type="class-type" use="required"/>
>       <xs:attribute name="type" type="type-type"/>
>       <xs:attribute name="description" type="xs:string"/>
>       <xs:anyAttribute/>
>     </xs:complexType>
>     <xs:simpleType name="identifier">
>       <xs:restriction base="xs:NMTOKEN">
>         <xs:pattern value="[0-1A-Za-z]\.[0-1A-Za-z]\.[0-1A-Za-z]"/>
>       </xs:restriction>
>     </xs:simpleType>
>     <xs:simpleType name="class-type">
>       <xs:restriction base="xs:NMTOKEN">
>         <xs:enumeration value="concept"/>
>         <xs:enumeration value="thing"/>
>         <xs:enumeration value="being"/>
>         <xs:enumeration value="reference"/>
>       </xs:restriction>
>     </xs:simpleType>
>     <xs:simpleType name="type-type">
>       <xs:restriction base="xs:NMTOKEN">
>         <xs:alternative test="@class = 'thing'" type="thing-type"/>
>         <xs:alternative test="@class = 'being'" type="being-type"/>
>       </xs:restriction>
>     </xs:simpleType>
>       <xs:simpleType name="thing-type">
>         <xs:restriction base="xs:NMTOKEN">
>           <xs:enumeration value="object"/>
>           <xs:enumeration value="place"/>
>           <xs:enumeration value="conveyor"/>
>         </xs:restriction>
>       </xs:simpleType>
>       <xs:simpleType name="being-type">
>         <xs:restriction base="xs:NMTOKEN">
>           <xs:enumeration value="mineral"/>
>           <xs:enumeration value="vegetable"/>
>           <xs:enumeration value="animal"/>
>           <xs:enumeration value="spiritual"/>
>         </xs:restriction>
>       </xs:simpleType>
>     </xs:element>
> </xs:schema>.
>
>
>
> 2017-08-03 22:43 GMT-05:00 Wolfgang Laun wolfgang.laun@xxxxxxxxx
> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>:
> > The definition of a simple type can make use of features such as union
> > and facets. It would help if you would provide an example of what you
> > are missing.
> >
> > -W
> >
> > On 4 August 2017 at 05:02, Andre Cusson akhu01@xxxxxxxxx
> > <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> >>
> >> Hi,
> >>
> >> I am reaching out to this list, as I did not succeed in finding the
> >> answer in the archives, the web or even in the specs, hoping that
> >> someone here, possibly having contributed to the specs, may know
> >> better.
> >>
> >> Please forgive me if either I have not found what I should have or if
> >> this question would have been better asked elsewhere.l
> >>
> >> Essencially, the question is something like " how can conditional
> >> (e.g. alternative) attribute types be defined in xsd.?
> >>
> >> If the answer is that "it just can't", or that "the feature is not
> >> supported", I would appreciate understanding "why?", especially as it
> >> seems that attribute nodes are nodes, that nodes can have types and
> >> that attributes types are types.
> >>
> >> There seems to be important use cases that would require the feature,
> >> as well as straight orthogonal design.
> >>
> >> Thank you,
> >>
> >> Akhu
> >>
> >
> > XSL-List info and archive
> > EasyUnsubscribe (by email)
>

GDV Dienstleistungs-GmbH
GlockengieCerwall 1
D-20095 Hamburg
www.gdv-dl.de

Sitz und Registergericht: Hamburg
HRB 145291
USt.-IdNr : DE 205183123

GeschC$ftsfC<hrer:
Dr. Jens Bartenwerfer
Michael Bathke
Fred di Giuseppe Chiachiarella
Thomas Fischer

Aufsichtsratsvorsitzender: Werner Schmidt

------------------------------------------------------------------
Diese E-Mail und alle AnhC$nge enthalten vertrauliche und/oder rechtlich
geschC<tzte Informationen. Wenn Sie nicht der richtige Adressat sind oder
diese E-Mail irrtC<mlich erhalten haben, informieren Sie bitte sofort den
Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie die
unbefugte Weitergabe der E-Mail ist nicht gestattet.

This e-mail and any attached files may contain confidential and/or privileged
information. If you are not the intended recipient (or have received this
e-mail in error) please notify the sender immediately and destroy this e-mail.
Any unauthorised copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.