AW: AW: XHTML representation

Hi Brett,

> In your specific case, you could simplify my schema of course,
> but not avoid the one shortcoming mentioned above for my generic schema
> regarding mixed content (if that's the issue you were referencing):

The issue we are facing is a bit different. In EXIforJSON we would like to be as precise as in XML.

In XML the example I sketched (person with “id” typed as number, a required “lastname” typed as string and an optional “firstname” typed as string) might look as follows

<person>
  <id>1</id>
  <lastname>Peintner</lastname>
  <firstname>Daniel</firstname>
</person>

with the following XML schema

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  <xs:element name="person">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="id" type="xs:unsignedInt "/>
        <xs:element name="lastname" type="xs:string"/>
        <xs:element name="firstname" type="xs:string" minOccurs="0"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

This accuracy allows us to to guarantee with a certain degree that the data we get is conformant to these rules and also allows for a much better compaction.

Our desire is to achieve the same for EXIforJSON.

I hope this makes the idea clear.

-- Daniel



________________________________
Von: Brett Zamir [brettz9@yahoo.com]
Gesendet: Freitag, 19. Februar 2016 02:29
An: Peintner, Daniel (ext); public-exi@w3.org
Betreff: Re: AW: XHTML representation

Hi Daniel,

On 2/18/2016 5:58 AM, Peintner, Daniel (ext) wrote:

I do understand the desire of having a readable format without CSS and/or XSLT and I think it is a valid approach.

Besides I think your approach suffers in a similar way as the current solution does. Our ultimate goal is to have an XML schema (or respectively EXI grammars) that describes the expected content. Assuming we have such a schema, EXI offers even better processing&compaction results.

In your mapping the element <dt> defines the key while <dd> is meant to hold the value. Correct?

Correct.

FYI, I've added a generic XML Schema for JHTML now at https://github.com/brettz9/jhtml/blob/master/jhtml.xsd<&smime=14.3.123.2https://github.com/brettz9/jhtml/blob/master/jhtml.xsd>

In order to provide as succinct a format as possible, I've chosen to represent strings without needing a parent element (unless the JSON is merely a string, in which case, the single element of the document will be a span element).

Due to limitations with XML Schema, however, I believe it is not possible, at least in XML Schema 1.0, to indicate that the elements (in our case, dd or li) must only allow for either text strings or child elements (in our case, text or i elements containing null/booleans/numbers). The current schema therefore must (mistakenly) allow for mixed content containing both text and elements.

With the assert element in XML Schema 1.1, however, I think it would be possible to use XPath to confirm that either text alone is present or elements without text are present but not both. I think the condition could be done with something like this:

    <xs:assert test="dd[not(./text() and *)]" />

(The online validators I have found are either 1.0 or apparently rely on Java being in the browser and no JavaScript libraries advertising 1.1 support.)

(One other limitation of JHTML...In order to maintain my design choices such as to avoid hidden attributes, and due to the removal from the CSS3 Selectors spec of the :contains() pseudo-class, there is currently no way to distinctively style null, boolean, or numbers from one another (all represented as the brief <i>), but that could easily be done, e.g., with XSLT adding some attributes.)

A "person" example could be the following:

<dl itemscope="" itemtype="http://brett-zamir.me/ns/microdata/json-as-html/2"<&smime=14.3.123.2http://brett-zamir.me/ns/microdata/json-as-html/2> xmlns="http:/www.w3.org/1999/xhtml"<&smime=14.3.123.2http:/www.w3.org/1999/xhtml>>
    <dt>id</dt>
    <dd><i>1</i></dd>
    <dt>lastname</dt>
    <dd>Peintner</dd>
    <dt>firstname</dt>
    <dd>Daniel</dd>
</dl>

Let’s assume one would like to restrict the content in a way so that it consist of a key “id” with a number, a required “lastname” typed as string and an optional “firstname” typed as string.

Please state me wrong but I think it is not possible to restrict the above XML instance in such a way by simply using XML schema constructs.
Do you see a possibility?


In your specific case, you could simplify my schema of course, but not avoid the one shortcoming mentioned above for my generic schema regarding mixed content (if that's the issue you were referencing):

<?xml version="1.0"?>
<xs:schema
  xmlns:xs="http://www.w3.org/2001/XMLSchema"<&smime=14.3.123.2http://www.w3.org/2001/XMLSchema>
  xmlns="http://www.w3.org/1999/xhtml"<&smime=14.3.123.2http://www.w3.org/1999/xhtml>
  targetNamespace="http://www.w3.org/1999/xhtml"<&smime=14.3.123.2http://www.w3.org/1999/xhtml>
  elementFormDefault="qualified">

<xs:attributeGroup name="rootAtts">
   <xs:attribute name="itemscope" type="xs:string" use="required" fixed=""/>
    <xs:attribute name="itemtype" type="xs:string" use="required" fixed="http://brett-zamir.me/ns/microdata/json-as-html/2"<&smime=14.3.123.2http://brett-zamir.me/ns/microdata/json-as-html/2>/>
</xs:attributeGroup>

<xs:simpleType name="decimal">
    <xs:restriction base="xs:decimal"/>
</xs:simpleType>

<xs:element name="dl">
    <xs:complexType>
        <xs:sequence minOccurs="3" maxOccurs="3">
            <xs:element name="dt" type="xs:string"/>
            <xs:element name="dd">
                <xs:complexType mixed="true">
                    <xs:choice>
                        <xs:element name="i" type="decimal" minOccurs="0"/>
                    </xs:choice>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
        <xs:attributeGroup ref="rootAtts"/>
  </xs:complexType>
</xs:element>

</xs:schema>

Best wishes,
Brett

Received on Monday, 22 February 2016 15:16:45 UTC