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

XSD derive by restriction via UML

  • From: John Dziurlaj <john@hiltonroscoe.com>
  • To: xml-dev@lists.xml.org
  • Date: Wed, 14 Mar 2018 11:13:11 -0400

XSD derive by restriction via UML

Hello,

 

I’m working on a proof of concept to generate XML schemas from idiomatic UML class diagrams (PIM). The current generator supports the XSD concept of derivation by extension, but not restriction. Extension is archived by the extending class E to generalize the base class B. The extending class can specify additional attributes that will transform into XSD attributes or elements, as directed by stereotypes/tags placed upon it.

 

Derivation by restriction is more difficult. It seems that using a generalization between the restricting class R to the base class B would imply inheritance of the base class’s attributes, which is undesirable. My best guess is to place a specific associative property from R to B (say “derived by restriction from”), and then allow attributes of B to be defined in R to inherit the attributes and cardinality. If a minimum cardinality restriction is required, the attribute must {subsets baseAttribute}. If a maximum cardinality restriction is required, the attribute must {redefines baseAttribute}.

 

I'm looking for someone who knows both UML and XSD to provide feedback on this approach or suggest another. An example follows:

 

UML Model

 

B

--------------------------

-attributeA: string [0..1]

-attributeB: string [1..5]

-attributeC: string [2..3]

 

R

--------------------------

-attributeA: string [0..1]

-attributeB: string [2..5] {subsets attributeB}

-attributeC: string [2] {redefined attributeC}

 

Association:derived by restriction from[::R -> ::B]

 

Should transform into

 

```xsd

<?xml version="1.0" encoding="UTF-8"?>

<xsd:schema xmlns="_18_5_3_43701b0_1521039686632_995340_5448" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="_18_5_3_43701b0_1521039686632_995340_5448" elementFormDefault="qualified" version="1.0">             

              <xsd:complexType name="B">

                             <xsd:sequence>

                                           <xsd:element name="attributeA" minOccurs="0"/>

                                           <xsd:element name="attributeB" type="xsd:string" maxOccurs="5"/>

                                           <xsd:element name="attributeC" type="xsd:string" minOccurs="2" maxOccurs="3"/>

                             </xsd:sequence>

              </xsd:complexType>

              <xsd:complexType name="R">

                             <xsd:complexContent>

                                           <xsd:restriction base="B">

                                                          <xsd:sequence>

                                                                        <xsd:element name="attributeA" minOccurs="0"/>

                                                                        <xsd:element name="attributeB" type="xsd:string" minOccurs="2" maxOccurs="5"/>

                                                                        <xsd:element name="attributeC" type="xsd:string" minOccurs="2" maxOccurs="2"/>

                                                          </xsd:sequence>

                                           </xsd:restriction>

                             </xsd:complexContent>

              </xsd:complexType>

</xsd:schema>

```

 

(yes, the attributes in the UML transformed into elements on the XSD side)

 

Thanks,

 

John Dziurlaj



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.