2 Replies Latest reply on Aug 6, 2012 5:15 AM by lfryc

    CDK templates and XML validation (data-* and aria-*)

    lfryc

      Currently, we see lot of errors in *.template.xml files because XML are not valid.

      This is caused by CDK XML schemas not being in sync with new CDK features.

       

      I have already synchronized schemas

       

      but I would like to discuss one important change:

       

      validation errors caused by non-HTML attributes like data-* and aria-*

       

      For aria-* attributes, it is simple, since we could import XHTML schema extension:

      http://www.w3.org/MarkUp/SCHEMA/aria-attributes-1.xsd

       

      But with data-*, it is problematic, since this HTML5 attribute disallows proper XML validation.

       

      What we could:

       

      1) namespacing data-* attributes to own namespace, which would be processed with separate CDK processor (e.g. data:data-trigger="..." or data:trigger="...")

      2) allow any attribute in all HTML elements - this would disallow validation, since any attribute could be provided then

      3) there is no other option: http://calavera.info/v2/blog/2010/02/16/html-5-xml-compatibility.xml

        • 1. Re: CDK templates and XML validation (data-* and aria-*)
          paul.dijou

          I guess I would go with option 2). You are talking about "data-*" attributes, but I think HTML5 is about allowing to use any kind of attributes. So maybe we can found "whateveryouwant" attribute used by a jQuery UI plugin tomorrow for example. We are writing HTML more than XML, isn't it?

           

          By the way, I don't know if it's about XML validation or my personnal settings on Eclipse, but I also got errors around wildcards:

           

          DescriptionResourcePathLocationType
          cvc-attribute.3: The value 'on*' of attribute 'cdk:passThrough' on element 'a' is not valid with respect to its type, 'null'.buttonDropdown.template.xml/bootstrap-ui/src/main/templates/org/richfaces/bootstrapline 19XML Problem

           

          And using c:forEach inside a ul since the validator was looking for a li:

           

          DescriptionResourcePathLocationType
          cvc-complex-type.2.4.a: Invalid content was found starting with element 'c:forEach'. One of '{"http://jboss.org/schema/richfaces/cdk/xhtml-el":li, "http://jboss.org/schema/richfaces/cdk/core":body, "http://jboss.org/schema/richfaces/cdk/jstl/core":if, "http://jboss.org/schema/richfaces/cdk/jstl/core":choose, "http://jboss.org/schema/richfaces/cdk/core":call, "http://jboss.org/schema/richfaces/cdk/core":switch, "http://jboss.org/schema/richfaces/cdk/core":object}' is expected.commandButton.template.xml/bootstrap-ui/src/main/templates/org/richfaces/bootstrapline 120XML Problem

           

          Fragments causing problems since they were not specified as child of the root element:

           

          DescriptionResourcePathLocationType
          cvc-complex-type.2.4.d: Invalid content was found starting with element 'cdk:fragment'. No child element is expected at this point.commandButton.template.xml/bootstrap-ui/src/main/templates/org/richfaces/bootstrapline 29XML Problem

           

          A few other ones:

           

          DescriptionResourcePathLocationType
          cvc-complex-type.3.2.2: Attribute 'cast' is not allowed to appear in element 'cdk:object'.blockquote.template.xml/bootstrap-ui/src/main/templates/org/richfaces/bootstrapline 22XML Problem

           

          DescriptionResourcePathLocationType
          cvc-complex-type.3.2.2: Attribute 'varStatus' is not allowed to appear in element 'c:forEach'.tabbable.template.xml/bootstrap-ui/src/main/templates/org/richfaces/bootstrapline 19XML Problem
          • 2. Re: CDK templates and XML validation (data-* and aria-*)
            lfryc

            Paul Dijou wrote:

             

            I guess I would go with option 2). You are talking about "data-*" attributes, but I think HTML5 is about allowing to use any kind of attributes. So maybe we can found "whateveryouwant" attribute used by a jQuery UI plugin tomorrow for example. We are writing HTML more than XML, isn't it?

            I must agree here, just consider that validation is pretty handy CDK feature, which can avoid typos or misunderstandings.

             

            CDK does not validate only enumeration of attributes but also their content where possible.

             

            But I agree this is opposito to where HTML5 specs are going.

             

             

            Paul Dijou wrote:

             

            By the way, I don't know if it's about XML validation or my personnal settings on Eclipse, but I also got errors around wildcards:

             

            ...

             



            /bootstrap-ui/src/main/templates/org/richfaces/bootstrapline 19XML Problem

             

            And using c:forEach inside a ul since the validator was looking for a li:

             

            ...

             

            Fragments causing problems since they were not specified as child of the root element:

             

            ...

             

            A few other ones:

            Yeah, those are ones I have fixed on develop, but right now, your IDE is validating gainst schemas uploaded to pernament location.

             

            You can import catalog.xml which imports development versions of schemas:

            https://github.com/richfaces/cdk/blob/develop/generator/src/main/resources/META-INF/schema/catalog.xml

             

            From Eclipse - File > Import > XML Catalog