[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
Re: [xml-dev] Micro XSD for Micro XML?
- From: Stephen Green <stephengreenubl@gmail.com>
- To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
- Date: Tue, 21 Dec 2010 12:05:52 +0000
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
>
>
>
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]