If you take the last published schemas, (EMIX only) and work this smaller extract from Power against them, you can see the problem… And maybe propose the solution. Thanks tc " It is the theory that decides what can be observed ." - Albert Einstein Toby Considine Chair, OASIS oBIX Technical Committee U.S. National Inst. of Standards and Tech. Smart Grid Architecture Committee Facilities Technology Office University of North Carolina Chapel Hill, NC Email: Toby.Considine@ unc.edu Phone: (919)962-9073
http://www.oasis-open.org blog:
www.NewDaedalus.com From: Bartell, Bruce [mailto:
bbartell@xtensible.net] Sent: Monday, March 28, 2011 10:37 AM To: William Cox; EMIX TC Cc:
Toby.Considine@gmail.com Subject: RE: [emix] Trouble in Schema Town Toby, can you send the versions that are causing the problem? I thought changing the elementFormDefault to “unqualified” for both schemas might help, but with the imports that might make things worse. Bruce Bartell Xtensible Solutions Mobile: +1.321.258.6500
bbartell@xtensible.net www.xtensible.net From: William Cox [mailto:
wtcox@CoxSoftwareArchitects.com] Sent: Monday, March 28, 2011 10:13 AM To: EMIX TC Cc:
Toby.Considine@gmail.com Subject: Re: [emix] Trouble in Schema Town All -- This is similar to the solution using EmixBaseType where we have an abstract base type for all EMIX artifacts. The proposal is a common pattern; the only slight twist is that the abstract class is empty. I don't have a problem with that, as it simplifies the typing model (more later) so you can validate artifacts using shared schemas in the XML space efficiently rather than by evaluating constraint rules. So I like it. If anyone has a better suggestion for the XML, please speak up. Thanks! bill -- William Cox Email:
wtcox@CoxSoftwareArchitects.com Web:
http://www.CoxSoftwareArchitects.com +1 862 485 3696 mobile +1 908 277 3460 fax I am having an issue with cross-schema restrictions. I can work around it, but if anyone can suggest a solution, that would be nice. In EMIX.XSD we have < xs:element name =" itemBase " type =" emix:ItemBaseType " abstract =" true "/> < xs:complexType name =" ItemBaseType " abstract =" true " mixed =" false "> < xs:annotation > < xs:documentation > Abstract base class for units for EMIX Product delivery, measurement, and warrants. Item as in PO Item, Requisition Item, Invoice Item, Lading Item. Item does not include Quantity or Price, because a single product description or transaction may have multiple quantities or prices associated with a single item. </ xs:documentation > </ xs:annotation > < xs:sequence > < xs:element name =" itemDescription " type =" xs:string "/> < xs:element name =" itemUnits " type =" xs:string "/> < xs:element name =" scale " type =" emix:SiScaleType "/> </ xs:sequence > </ xs:complexType > In Power.XSd, we extend this (showing Power only) <!-- ==================================================== --> <!-- 9.9.5 Base Power Item Type --> <!-- ==================================================== --> < xs:element name =" powerItem " type =" power:PowerItemType "/> < xs:complexType name =" PowerItemType " abstract =" true " mixed =" false "> < xs:annotation > < xs:documentation > Denominations for the measurement of Power </ xs:documentation > </ xs:annotation > < xs:complexContent mixed =" false "> < xs:extension base =" emix:ItemBaseType "> < xs:sequence > < xs:element ref =" power:powerAttributes "/> </ xs:sequence > </ xs:extension > </ xs:complexContent > </ xs:complexType > <!-- ==================================================== --> < xs:element name =" powerAttributes " type =" power:PowerAttributesType "/> < xs:complexType name =" PowerAttributesType "> < xs:sequence > < xs:element name =" hertz " type =" xs:decimal "/> < xs:element name =" voltage " type =" xs:decimal "/> < xs:element name =" ac " type =" xs:boolean "/> </ xs:sequence > </ xs:complexType > And then restrict them as follows <!-- ==================================================== --> < xs:element name =" powerReal " type =" power:PowerRealType " substitutionGroup =" power:powerItem "/> < xs:complexType name =" PowerRealType " mixed =" false "> < xs:annotation > < xs:documentation > Real power measured in Watts (W) or Joules/second (J/s) </ xs:documentation > </ xs:annotation > < xs:complexContent mixed =" false "> < xs:restriction base =" power:PowerItemType "> < xs:sequence > < xs:element name =" itemDescription " type =" xs:string " fixed =" RealPower "/> < xs:element name =" itemUnits "> < xs:simpleType > < xs:restriction base =" xs:token "> < xs:enumeration value =" W "/> < xs:enumeration value =" J/s "/> </ xs:restriction > </ xs:simpleType > </ xs:element > < xs:element name =" scale " type =" emix:SiScaleType "/> < xs:element ref =" power:powerAttributes "/> </ xs:sequence > </ xs:restriction > </ xs:complexContent > </ xs:complexType > This should produce correct results. It validates in many tools, but not in XMLSpy. In XML Spy, this is invalid as it sees: Type 'power:PowerRealType' is not a valid restriction of type 'power:PowerItemType'. (see Details) Error location: xs:schema / xs:complexType / xs:complexContent / xs:restriction / @base Details rcase-NameAndTypeOK.1: The declarations' {name}s and {target namespace}s are not the same: restriction element is <xs:element name="itemDescription"> and base element is <xs:element name="itemDescription">. rcase-Recurse.2.2: Mandatory <xs:element name="itemDescription"> is missing in the <sequence>. Several other tools validate it as OK. It seems to be an edge case that was much discussed during the development of the current draft of XSD. I am not even certain that it is invalid. Still, if XMLspy is the tool folks will use to validate, this is a problem. For now, I can work around it by making Item a null abstract class, and doing all the typing inside Power. This will give correct XML that validates in XMLSpy, and I can fix it to be what I would prefer when someone suggests a work-around. Some of the examples shared on this list recently have been very informative. We have to shy away from non-recommended standards such as SAWSDL which are not fully conformant with WSDL 2. Perhaps we can accomplish the same type of semantic typing with CAM as we go forward. I would welcome a volunteer for that effort. tc “The single biggest problem in communication is the illusion that it has taken place.” – George Bernard Shaw. Toby Considine TC9, Inc TC Chair: oBIX & WS-Calendar TC Editor: EMIX, EnergyInterop U.S. National Inst. of Standards and Tech. Smart Grid Architecture Committee Email:
Toby.Considine@gmail.com Phone: (919)619-2104
http://www.tcnine.com/ blog:
www.NewDaedalus.com <?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:poo="
http://docs.oasis-open.org/poo" ; xmlns:emix="
http://docs.oasis-open.org/ns/emix" ; xmlns:xs="
http://www.w3.org/2001/XMLSchema" ; targetNamespace="
http://docs.oasis-open.org/poo" ; elementFormDefault="unqualified" attributeFormDefault="unqualified">
<xs:import namespace="
http://docs.oasis-open.org/ns/emix" ; schemaLocation="emix.xsd"/>
<!-- ==================================================== -->
<xs:element name="scale" type="poo:SiScaleType"/>
<xs:simpleType name="SiScaleType">
<xs:annotation>
<xs:documentation>Scale based on representations of SI scale</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="#P">
<xs:annotation>
<xs:documentation>Peta 10^^15</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="#T">
<xs:annotation>
<xs:documentation>Tera 10^^12</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="#G">
<xs:annotation>
<xs:documentation>Giga 10^^9</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="#M">
<xs:annotation>
<xs:documentation>Mega 10^^6</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="#k">
<xs:annotation>
<xs:documentation>kilo 10^^3</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="#h">
<xs:annotation>
<xs:documentation>hecto 10^^2</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="#da">
<xs:annotation>
<xs:documentation>deka 10^^1</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="#">
<xs:annotation>
<xs:documentation>10^^0 (1)</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="#d">
<xs:annotation>
<xs:documentation>deci 10^^-1</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="#c">
<xs:annotation>
<xs:documentation>centi 10^^-2</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="#m">
<xs:annotation>
<xs:documentation>milli 10^^-3</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="#u">
<xs:annotation>
<xs:documentation>microi 10^^-6</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="#n">
<xs:annotation>
<xs:documentation>nano 10^^-9</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="#p">
<xs:annotation>
<xs:documentation>pico 10^^-12</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="#f">
<xs:annotation>
<xs:documentation>femto 10^^-15</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="#a">
<xs:annotation>
<xs:documentation>atto 10^^-18</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
<!-- ==================================================== -->
<xs:element name="itemBase" type="poo:ItemBaseType" abstract="true"/>
<xs:complexType name="ItemBaseType" abstract="true" mixed="false">
<xs:annotation>
<xs:documentation>Abstract base class for units for EMIX Product delivery, measurement, and warrants. Item as in PO Item, Requisition Item, Invoice Item, Lading Item. Item does not include Quantity or Price, because a single product description or transaction may have multiple quantities or prices associated with a single item.</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="itemDescription" type="xs:string"/>
<xs:element name="itemUnits" type="xs:string"/>
<xs:element name="scale" type="poo:SiScaleType"/>
</xs:sequence>
</xs:complexType>
<!-- ==================================================== -->
<!-- ==================================================== -->
<!-- ==================================================== -->
<!-- ==================================================== -->
<xs:element name="powerItem" type="poo:PowerItemType" substitutionGroup="emix:itemBase"/>
<xs:complexType name="PowerItemType" abstract="true" mixed="false">
<xs:annotation>
<xs:documentation>Denominations for the measurement of Power</xs:documentation>
</xs:annotation>
<xs:complexContent mixed="false">
<xs:extension base="emix:ItemBaseType">
<xs:sequence>
<xs:element ref="poo:powerAttributes"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ==================================================== -->
<xs:element name="powerAttributes" type="poo:PowerAttributesType"/>
<xs:complexType name="PowerAttributesType">