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

RE: Genericity and XML-Schema

  • To: <xml-dev@l...>
  • Subject: RE: Genericity and XML-Schema
  • From: "Phil Fuhlman" <pfuhlman@D...>
  • Date: Fri, 8 Mar 2002 11:33:18 -0600
  • Thread-index: AcHGl14vaklQGoDETleUiehomZmDBAAKZd+Q
  • Thread-topic: Genericity and XML-Schema

notepad date annotation
A few moments from the trenches...

I think the answer to your question will be yes, but it may depend on
your opinion of how the "right" syntax might manifest itself.

Ex. Given an XML document fragment something like (indented and CR/LFed
for readability):

<!-- my Transaction Copyright (c) 2002 Thought You Had A Clue, LLC All
Rights Reserved VersionInfo Major(1) Minor(2) Patch(3) Build (4) -->

If you feel you've got some OO experience but your a schema neophyte
like me you might be tempted to set up a schema that looks something
like (sorry no identation):

<?xml version="1.0" encoding="utf-8"?>
<!-- Context=External -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:documentation xml:lang="en">
Schema for my Transaction Copyright (c) 2002 Thought You Had A Clue, LLC
All Rights Reserved
VersionInfo Major(1) Minor(2) Patch(3) Build(4)
<xsd:simpleType name="Address.CityType">
<xsd:documentation>name of city</xsd:documentation>
<xsd:restriction base="xsd:string">
<xsd:minLength value="0"/>
<xsd:maxLength value="50"/>
<xsd:complexType name="AddressClass">
<xsd:element name="City" type="Address.CityType" minOccurs="0"
maxOccurs="1" />
<xsd:complexType name="AddressContainer">
<!-- not used here but included for completeness -->
<xsd:element name="Address" type="AddressClass" minOccurs="0"
<xsd:complexType name="ShipToClass">
<xsd:element name="Address" type="AddressClass" minOccurs="1"
<xsd:complexType name="BillToClass">
<xsd:element name="Address" type="AddressClass" minOccurs="1"
<xsd:complexType name="TransactionClass">
<xsd:element name="ShipTo" type="ShipToClass" minOccurs="1"
<xsd:element name="BillTo" type="BillToClass" minOccurs="0"
<xsd:element name="Transaction" type="TransactionClass"/>

This can be expressed quite nicely in "legacy" C++ (a thousand apologies
in advance for not declaring everything with templates and streams and
I'd never do it this way<lol>):

	class Address
		int SaveAsXML ( std::string &a_sarg );
		int RestoreFromXML ( SomeParserTool &a_spt,
SomeLocalityRef &a_parentnode );

		std::string m_sCity;

	class Transaction
		int SaveAsXML ( std::string &a_sarg ) { ...;
m_ShipTo.SaveAsXML(out_stream); m_BillTo.SaveAsXML(out_stream); ...; };
		int RestoreFromXML ( std::string &a_sarg ); /* uses
parser tool */

		Address m_ShipTo;
		Address m_BillTo;

After assimilating the nuances of schema syntax, one steeped in the
traditions of object oriented design / programming and code reuse (you
might even generate it dynamically from an existing, er, "legacy", data
dictionary) might imagine a schema document like this.

A "generic" XML parser (oh, say like MSXML4) processes these two
documents with no errors.

Caveat(s): there are apparently a number of XML 'authoring tools' out
there today that choke on it because of the reuse of the "AddressClass"
(and might also choke on the period character in the "Address.CityType"
string). Thankfully VI and NOTEPAD are two of them. Both VI and NOTEPAD
can parse both documents with no errors :)

Otherwise it works really rather cool :)


-----Original Message-----
From: Andrew Goodchild [mailto:andrewg@d...]
Sent: Friday, March 08, 2002 5:53 AM
To: xml-dev@l...
Subject:  Genericity and XML-Schema


I know someone has probably asked this question before, but is
genericity/polymorphism supported in XML-Schema?  For example if I have
complex type for <list> and want to later on create a list of addressess
or a list of blood pressures.  Is genericity anything more than simply
creating a complex type which extends the <item> in the <list> as an
address or as a blood pressure?

thanks,  Andrew

The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
initiative of OASIS <http://www.oasis-open.org>

The list archives are at http://lists.xml.org/archives/xml-dev/

To subscribe or unsubscribe from this list use the subscription
manager: <http://lists.xml.org/ob/adm.pl>


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.
First Name
Last Name
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.