[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
Re: [xml-dev] Micro XSD for Micro XML?
- From: Stephen Green <stephen.green@documentengineeringservices.com>
- To: xml-dev@lists.xml.org
- Date: Tue, 21 Dec 2010 14:54:41 +0000
Updated, a potential MicroXSD schema for a potential MicroXSD schema language
as a not-so-strictly-valid MicroXML subset of XSD (W3C XML Schema):
(proof of concept?)
<schema xmlns="http://www.w3.org/2001/XMLSchema">
<element name="schema">
<complexType>
<group ref="global_group" minOccurs="0" maxOccurs="unbounded"/>
</complexType>
</element>
<element name="element">
<complexType>
<group ref="elementtype_group" minOccurs="0" maxOccurs="unbounded"/>
<attribute ref="ref" use="optional"/>
<attribute ref="name" use="optional"/>
<attribute ref="type" use="optional"/>
<attribute ref="minOccurs" use="optional"/>
<attribute ref="maxOccurs" use="optional"/>
</complexType>
</element>
<element name="attribute">
<complexType>
<group ref="attributetype_group" minOccurs="0" maxOccurs="unbounded"/>
<attribute ref="use" use="optional"/>
<attribute ref="ref" use="optional"/>
<attribute ref="name" use="optional"/>
<attribute ref="type" use="optional"/>
</complexType>
</element>
<element name="choice">
<complexType>
<group ref="choice_group" minOccurs="0" maxOccurs="unbounded"/>
</complexType>
</element>
<element name="group">
<complexType>
<group ref="group_group" minOccurs="0" maxOccurs="unbounded"/>
<attribute ref="ref" use="optional"/>
<attribute ref="name" use="optional"/>
<attribute ref="minOccurs" use="optional"/>
<attribute ref="maxOccurs" use="optional"/>
</complexType>
</element>
<element name="complexType">
<complexType>
<group ref="complexType_group" minOccurs="0" maxOccurs="unbounded"/>
<attribute ref="mixed" use="optional"/>
</complexType>
</element>
<element name="simpleType">
<complexType>
<group ref="simpleType_group" minOccurs="0" maxOccurs="unbounded"/>
</complexType>
</element>
<element name="restriction">
<complexType>
<group ref="restriction_group" minOccurs="0" maxOccurs="unbounded"/>
<attribute ref="base" use="optional"/>
<attribute ref="value" use="optional"/>
</complexType>
</element>
<element name="enumeration">
<complexType>
<attribute ref="value" use="optional"/>
</complexType>
</element>
<group name="global_group">
<choice>
<element ref="element"/>
<element ref="attribute"/>
<element ref="group"/>
</choice>
</group>
<group name="elementtype_group">
<choice>
<element ref="complexType"/>
<element ref="simpleType"/>
</choice>
</group>
<group name="attributetype_group">
<choice>
<element ref="simpleType"/>
</choice>
</group>
<group name="enumeration_group">
<choice>
<element ref="enumeration"/>
</choice>
</group>
<group name="restriction_group">
<choice>
<group ref="enumeration_group"/>
</choice>
</group>
<group name="group_group">
<choice>
<element ref="choice"/>
</choice>
</group>
<group name="choice_group">
<choice>
<element ref="element"/>
<element ref="group"/>
</choice>
</group>
<group name="complexType_group">
<choice>
<element ref="attribute"/>
<element ref="group"/>
</choice>
</group>
<group name="simpleType_group">
<choice>
<element ref="restriction"/>
</choice>
</group>
<attribute name="minOccurs">
<simpleType>
<restriction base="string">
<enumeration value="0"/>
<enumeration value="1"/>
</restriction>
</simpleType>
</attribute>
<attribute name="maxOccurs">
<simpleType>
<restriction base="string">
<enumeration value="1"/>
<enumeration value="unbounded"/>
</restriction>
</simpleType>
</attribute>
<attribute name="base">
<simpleType>
<restriction base="string">
<enumeration value="string"/>
<enumeration value="integer"/>
<enumeration value="datetime"/>
<enumeration value="decimal"/>
<enumeration value="list"/>
</restriction>
</simpleType>
</attribute>
<attribute name="ref" type="string"/>
<attribute name="use">
<simpleType>
<restriction base="string">
<enumeration value="optional"/>
<enumeration value="required"/>
</restriction>
</simpleType>
</attribute>
<attribute name="value" type="string"/>
<attribute name="name" type="string"/>
<attribute name="type">
<simpleType>
<restriction base="string">
<enumeration value="string"/>
<enumeration value="integer"/>
<enumeration value="datetime"/>
<enumeration value="decimal"/>
<enumeration value="list"/>
</restriction>
</simpleType>
</attribute>
<attribute name="mixed">
<simpleType>
<restriction base="string">
<enumeration value="true"/>
<enumeration value="false"/>
</restriction>
</simpleType>
</attribute>
</schema>
[Note some oddities such as singleton choices just help to keep
out the need for further constructs - to keep the subset minimal.]
BUT the inclusion of a schema namespace still introduces problems.
Including the prefix makes it no longer, I think, MicroXML in itself
(though perhaps still useful for validating MicroXML instances) but
adding prefixes makes it a valid XSD schema (for a potential MicroXSD):
[Note: differences in type enumerations when there is a normal XML
namespace/prefix]
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="schema">
<xs:complexType>
<xs:group ref="global_group" minOccurs="0" maxOccurs="unbounded"/>
</xs:complexType>
</xs:element>
<xs:element name="element">
<xs:complexType>
<xs:group ref="elementtype_group" minOccurs="0" maxOccurs="unbounded"/>
<xs:attribute ref="ref" use="optional"/>
<xs:attribute ref="name" use="optional"/>
<xs:attribute ref="type" use="optional"/>
<xs:attribute ref="minOccurs" use="optional"/>
<xs:attribute ref="maxOccurs" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="attribute">
<xs:complexType>
<xs:group ref="attributetype_group" minOccurs="0" maxOccurs="unbounded"/>
<xs:attribute ref="use" use="optional"/>
<xs:attribute ref="ref" use="optional"/>
<xs:attribute ref="name" use="optional"/>
<xs:attribute ref="type" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="choice">
<xs:complexType>
<xs:group ref="choice_group" minOccurs="0" maxOccurs="unbounded"/>
</xs:complexType>
</xs:element>
<xs:element name="group">
<xs:complexType>
<xs:group ref="group_group" minOccurs="0" maxOccurs="unbounded"/>
<xs:attribute ref="ref" use="optional"/>
<xs:attribute ref="name" use="optional"/>
<xs:attribute ref="minOccurs" use="optional"/>
<xs:attribute ref="maxOccurs" use="optional"/>
</xs:complexType>
</xs:element>
<xs:group name="global_group">
<xs:choice>
<xs:element ref="element"/>
<xs:element ref="attribute"/>
<xs:element ref="group"/>
</xs:choice>
</xs:group>
<xs:group name="elementtype_group">
<xs:choice>
<xs:element ref="complexType"/>
<xs:element ref="simpleType"/>
</xs:choice>
</xs:group>
<xs:group name="attributetype_group">
<xs:choice>
<xs:element ref="simpleType"/>
</xs:choice>
</xs:group>
<xs:group name="enumeration_group">
<xs:choice>
<xs:element ref="enumeration"/>
</xs:choice>
</xs:group>
<xs:element name="complexType">
<xs:complexType>
<xs:group ref="complexType_group" minOccurs="0" maxOccurs="unbounded"/>
<xs:attribute ref="mixed" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="simpleType">
<xs:complexType>
<xs:group ref="simpleType_group" minOccurs="0" maxOccurs="unbounded"/>
</xs:complexType>
</xs:element>
<xs:element name="restriction">
<xs:complexType>
<xs:group ref="restriction_group" minOccurs="0" maxOccurs="unbounded"/>
<xs:attribute ref="base" use="optional"/>
<xs:attribute ref="value" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="enumeration">
<xs:complexType>
<xs:attribute ref="value" use="optional"/>
</xs:complexType>
</xs:element>
<xs:group name="restriction_group">
<xs:choice>
<xs:group ref="enumeration_group"/>
</xs:choice>
</xs:group>
<xs:group name="group_group">
<xs:choice>
<xs:element ref="choice"/>
</xs:choice>
</xs:group>
<xs:group name="choice_group">
<xs:choice>
<xs:element ref="element"/>
<xs:element ref="group"/>
</xs:choice>
</xs:group>
<xs:group name="complexType_group">
<xs:choice>
<xs:element ref="attribute"/>
<xs:element ref="group"/>
</xs:choice>
</xs:group>
<xs:group name="simpleType_group">
<xs:choice>
<xs:element ref="restriction"/>
</xs:choice>
</xs:group>
<xs:attribute name="minOccurs">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="0"/>
<xs:enumeration value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="maxOccurs">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="1"/>
<xs:enumeration value="unbounded"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="base">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="xs:string"/>
<xs:enumeration value="xs:integer"/>
<xs:enumeration value="xs:datetime"/>
<xs:enumeration value="xs:decimal"/>
<xs:enumeration value="xs:list"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="ref" type="xs:string"/>
<xs:attribute name="use">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="optional"/>
<xs:enumeration value="required"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="value" type="xs:string"/>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="type">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="xs:string"/>
<xs:enumeration value="xs:integer"/>
<xs:enumeration value="xs:datetime"/>
<xs:enumeration value="xs:decimal"/>
<xs:enumeration value="xs:list"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="mixed">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:schema>
Best regards
Steve
---
Stephen D Green
On 21 December 2010 12:41, Michael Kay <mike@saxonica.com> wrote:
> I think you're mixing several things here, and that makes the exercise
> confusing. I would start by trying to define an XML 1.0 syntax for a subset
> of XSD that can be used to describe XML 1.0 documents, namespaces and all.
>
> I think you've thrown out some babies with the bathwater. I think you need
> simple types including restrictions with facets, you need
> mixed="true|false", and you need complex-types-with-simple-content - though
> if we could avoid calling them that, we would be doing the world a favour!
> You also need to define optionality/repeatability for elements and
> attributes, and you need wildcards or open content.
>
> There are some strange things in your grammar: an empty choice, a singleton
> choice. So it's not always clear what you're trying to say.
>
> (Iit depends on your objectives of course. If you're just trying to
> reproduce the validation that's possible with DTDs, then it's true you don't
> need all the above - though you do still need enumeration types for
> attributes. But I've never seen any point in carefully defining a grammar
> for the markup, and saying nothing about the content.)
>
> Michael Kay
> Saxonica
>
> On 21/12/2010 12:05, Stephen Green wrote:
>>
>> Perhaps the idea is still unpopular but I've experimented some more with a
>> minimalistic 'Micro XSD' for MicroXML and come up with two possibilities.
>>
>> The first is as useful a subset of XSD I could produce which can pretty
>> much
>> be defined using itself (might not be error-free):
>>
>> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
>> <xs:element name="schema">
>> <xs:complexType>
>> <xs:group ref="general_group" minOccurs="0"
>> maxOccurs="unbounded"/>
>> </xs:complexType>
>> </xs:element>
>> <xs:element name="element">
>> <xs:complexType>
>> <xs:group ref="element_group" minOccurs="0"
>> maxOccurs="unbounded"/>
>> <xs:attribute name="ref" type="xs:string"/>
>> <xs:attribute name="name" type="xs:string"/>
>> <xs:attribute name="type" type="xs:string"/>
>> </xs:complexType>
>> </xs:element>
>> <xs:element name="attribute">
>> <xs:complexType>
>> <xs:group ref="attribute_group" minOccurs="0"
>> maxOccurs="unbounded"/>
>> <xs:attribute name="name" type="xs:string"/>
>> <xs:attribute name="type" type="xs:string"/>
>> </xs:complexType>
>> </xs:element>
>> <xs:element name="choice">
>> <xs:complexType>
>> <xs:group ref="choice_group" minOccurs="0"
>> maxOccurs="unbounded"/>
>> </xs:complexType>
>> </xs:element>
>> <xs:element name="group">
>> <xs:complexType>
>> <xs:group ref="group_group" minOccurs="0"
>> maxOccurs="unbounded"/>
>> <xs:attribute name="ref" type="xs:string"/>
>> <xs:attribute name="name" type="xs:string"/>
>> </xs:complexType>
>> </xs:element>
>> <xs:group name="general_group">
>> <xs:choice>
>> <xs:element ref="element"/>
>> <xs:element ref="group"/>
>> </xs:choice>
>> </xs:group>
>> <xs:group name="element_group">
>> <xs:choice>
>> <xs:element name="complexType">
>> <xs:complexType>
>> <xs:group ref="complexType_group"
>> minOccurs="0" maxOccurs="unbounded"/>
>> </xs:complexType>
>> </xs:element>
>> </xs:choice>
>> </xs:group>
>> <xs:group name="attribute_group">
>> <xs:choice/>
>> </xs:group>
>> <xs:group name="group_group">
>> <xs:choice>
>> <xs:element ref="choice"/>
>> </xs:choice>
>> </xs:group>
>> <xs:group name="choice_group">
>> <xs:choice>
>> <xs:element ref="element"/>
>> <xs:element ref="group"/>
>> </xs:choice>
>> </xs:group>
>> <xs:group name="complexType_group">
>> <xs:choice>
>> <xs:element ref="attribute"/>
>> <xs:element ref="group"/>
>> </xs:choice>
>> </xs:group>
>> </xs:schema>
>>
>> But this still has a namespace/prefix.
>>
>> The second tries to do the above while keeping it to what I think
>> we so far understand as MicroXML by removing the namespace
>> prefix while keeping the 'xmlns' attribute (pointing it at the XSD
>> namespace as a kind of namespace hint).
>>
>> <schema xmlns="http://www.w3.org/2001/XMLSchema">
>> <element name="schema">
>> <complexType>
>> <group ref="general_group" minOccurs="0"
>> maxOccurs="unbounded"/>
>> </complexType>
>> </element>
>> <element name="element">
>> <complexType>
>> <group ref="element_group" minOccurs="0"
>> maxOccurs="unbounded"/>
>> <attribute name="ref" type="string"/>
>> <attribute name="name" type="string"/>
>> <attribute name="type" type="string"/>
>> </complexType>
>> </element>
>> <element name="attribute">
>> <complexType>
>> <group ref="attribute_group" minOccurs="0"
>> maxOccurs="unbounded"/>
>> <attribute name="name" type="string"/>
>> <attribute name="type" type="string"/>
>> </complexType>
>> </element>
>> <element name="choice">
>> <complexType>
>> <group ref="choice_group" minOccurs="0"
>> maxOccurs="unbounded"/>
>> </complexType>
>> </element>
>> <element name="group">
>> <complexType>
>> <group ref="group_group" minOccurs="0"
>> maxOccurs="unbounded"/>
>> <attribute name="ref" type="string"/>
>> <attribute name="name" type="string"/>
>> </complexType>
>> </element>
>> <group name="general_group">
>> <choice>
>> <element ref="element"/>
>> <element ref="group"/>
>> </choice>
>> </group>
>> <group name="element_group">
>> <choice>
>> <element name="complexType">
>> <complexType>
>> <group ref="complexType_group"
>> minOccurs="0" maxOccurs="unbounded"/>
>> </complexType>
>> </element>
>> </choice>
>> </group>
>> <group name="attribute_group">
>> <choice/>
>> </group>
>> <group name="group_group">
>> <choice>
>> <element ref="choice"/>
>> </choice>
>> </group>
>> <group name="choice_group">
>> <choice>
>> <element ref="element"/>
>> <element ref="group"/>
>> </choice>
>> </group>
>> <group name="complexType_group">
>> <choice>
>> <element ref="attribute"/>
>> <element ref="group"/>
>> </choice>
>> </group>
>> </schema>
>>
>>
>> I note that this does seem to break things in that an older XML editor
>> won't accept it.
>> The first XML Schema does at least work in an XML Editor while the
>> second is deemed
>> to be invalid XML and will not save. Is that correct? Does the way I'm
>> trying to implement
>> MicroXML (as it stands today) break XML compatibility?
>>
>> Regards
>>
>> ----
>> Stephen D Green
>>
>>
>>
>> On 17 December 2010 20:39, Stephen Green<stephengreenubl@gmail.com>
>> wrote:
>>>
>>> I agree that people might want a non-XML syntax for
>>> merely defining their Micro-markup but if there is going
>>> to be any validation in the Micro-parser I'd reckon they
>>> wouldn't want to go to the trouble of implementing two
>>> syntaxes (they will just have implemented MicroXML)
>>> - unless the schema syntax is incredibly simple or
>>> exists already (like JSON perhaps :-)
>>>
>>> I did some more rough work on a reduced 'XSD-like'
>>> language (defined using its own schema language)
>>> which could probably be mapped to XSD, to compact
>>> relaxN, etc
>>>
>>> <schema name="MicroSchema-draft" version="draft2">
>>> <element name="schema">
>>> <group>
>>> <element ref="element" maxOccurs="unbounded" />
>>> <element ref="group" maxOccurs="unbounded">
>>> </group>
>>> <attribute name="name" type="string" />
>>> <attribute name="version" type="string" />
>>> </element>
>>> <element name="element">
>>> <group maxOccurs="unbounded">
>>> <element ref="element" />
>>> <element ref="group" />
>>> </group>
>>> <attribute name="ref" type="string" />
>>> <attribute name="name" type="string" />
>>> <attribute name="type" type="string">
>>> <!-- enumeration = string | integer | decimal |
>>> date | sequence -->
>>> </attribute>
>>> </element>
>>> <element name="attribute">
>>> <attribute name="ref" type="string" />
>>> <attribute name="name" type="string" />
>>> <attribute name="type" type="string">
>>> <!-- enumeration = string | integer | decimal |
>>> date | sequence -->
>>> </attribute>
>>> </element>
>>> </schema>
>>>
>>>
>>>
>>>
>>> ----
>>> Stephen D Green
>>>
>>>
>>>
>> _______________________________________________________________________
>>
>> XML-DEV is a publicly archived, unmoderated list hosted by OASIS
>> to support XML implementation and development. To minimize
>> spam in the archives, you must subscribe before posting.
>>
>> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
>> Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
>> subscribe: xml-dev-subscribe@lists.xml.org
>> List archive: http://lists.xml.org/archives/xml-dev/
>> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
>>
>>
>
>
> _______________________________________________________________________
>
> XML-DEV is a publicly archived, unmoderated list hosted by OASIS
> to support XML implementation and development. To minimize
> spam in the archives, you must subscribe before posting.
>
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
> subscribe: xml-dev-subscribe@lists.xml.org
> List archive: http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
>
>
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]