W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > October to December 2011

Re: <time> values in HTML5

From: Pete Cordell <petexmldev@codalogic.com>
Date: Fri, 2 Dec 2011 16:55:17 -0000
Message-ID: <3AFAE082A65844D19736A7DE1E10FAAA@codalogic>
To: "C. M. Sperberg-McQueen" <cmsmcq@blackmesatech.com>, "Jeni Tennison" <jeni@jenitennison.com>
Cc: "C. M. Sperberg-McQueen" <cmsmcq@blackmesatech.com>, <www-xml-schema-comments@w3.org>, "HTML Data Task Force WG" <public-html-data-tf@w3.org>, "RDFa WG" <public-rdfa-wg@w3.org>, <public-html-xml@w3.org>
Original Message From: "C. M. Sperberg-McQueen"
> It would be an interesting exercise to specify both an extension type
> with its own value space and lexical mapping, and a type usable in
> processors which don't support the extension type.   I think the XML
> Schema WG might be interested in collaborating on a document with
> such a specification; if the WG isn't interested as a group, I expect that
> some individuals in the WG may be interested.  From the XML Schema
> WG's point of view, such a document would probably be interesting and
> worth working on even if some of those interested in HTML5 and RDF
> were to decide they don't care to use it.

In case you're looking for an 'automated' solution I came up with the 
following syntax.  My concern with Jeni's approach was that it was very good 
with parsing an XML value into it's component parts, and converting from one 
form to another, but I couldn't readily see how it worked for converting 
something like a Java object (e.g. class Date{ private int year; private int 
month;...};)  to an XML value.  But then maybe that's only a niche problem.

In the two examples below I've used the 'format' attribute to describe how a 
value should be formatted for output (based on C and Java format specifiers) 
and used the 'condition' attribute to indicate when a particular block of 
data should be output.

I've described it as an extension that can be plugged into an XSD.

HTH!

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xsdt="http://www.w3.org/2001/XMLSchemaDataTypes">
    <xs:simpleType name="date">
        <xs:restriction base="xs:string">
            <xsdt:compoundType>
                <xsdt:sequence>
                    <xsdt:value name='year' type='xs:int' format='04d'/>
                    <xsdt:literal value='-'/>
                    <xsdt:value name='month' format='02d'>
                        <xs:simpleType>
                            <xs:restriction base='xs:int'>
                                <xs:minInclusive value='1'/>
                                <xs:maxInclusive value='12'/>
                            </xs:restriction>
                        </xs:simpleType>
                    </xsdt:value>
                    <xsdt:literal value='-'/>
                    <xsdt:value name='day' format='02d'>
                        <xs:simpleType>
                            <xs:restriction base='xs:int'>
                                <xs:minInclusive value='1'/>
                                <xs:maxInclusive value='31'/>
                            </xs:restriction>
                        </xs:simpleType>
                    </xsdt:value>
                <xsdt:sequence>
            </xsdt:compoundType>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xsdt="http://www.w3.org/2001/XMLSchemaDataTypes">
    <xs:simpleType name="duration">
        <xs:restriction base="xs:string">
            <xsdt:compoundType name='duration'>
                <xsdt:sequence>
                    <xsdt:literal name='isNeg' value='-' minOccurs='0' 
condition='isNeg'/>
                    <xsdt:literal value='P'/>
                    <xsdt:sequence minOccurs='0'>
                        <xsdt:value name='years' type='xs:unsignedInt'/>
                        <xsdt:literal value='Y'/>
                    </xsdt:sequence>
                    <xsdt:sequence minOccurs='0'>
                        <xsdt:value name='months' type='xs:unsignedInt'/>
                        <xsdt:literal value='M'/>
                    </xsdt:sequence>
                    <xsdt:sequence minOccurs='0'>
                        <xsdt:value name='days' type='xs:unsignedInt'/>
                        <xsdt:literal value='D'/>
                    </xsdt:sequence>
                    <xsdt:sequence minOccurs='0' condition='hours>0 || 
minutes>0 || seconds>0'>
                        <xsdt:literal value='T'/>
                        <xsdt:sequence minOccurs='0' condition='hours>0'>
                            <xsdt:value name='hours' type='xs:unsignedInt'/>
                            <xsdt:literal value='H'/>
                        </xsdt:sequence>
                        <xsdt:sequence minOccurs='0' condition='minutes>0'>
                            <xsdt:value name='minutes' 
type='xs:unsignedInt'/>
                            <xsdt:literal value='M'/>
                        </xsdt:sequence>
                        <xsdt:sequence minOccurs='0' condition='seconds>0'>
                            <xsdt:value name='seconds' 
type='unsignedFloat'/>
                            <xsdt:literal value='M'/>
                        </xsdt:sequence>
                    </xsdt:sequence>
                </xsdt:sequence>
            </xsdt:compoundType>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>

Pete Cordell
Codalogic Ltd
Interface XML to C++ the easy way using C++ XML
data binding to convert XSD schemas to C++ classes.
Visit http://codalogic.com/lmx/ or http://www.xml2cpp.com
for more info
Received on Friday, 2 December 2011 16:56:01 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 2 December 2011 16:56:02 GMT