Cannot get extended XHTML to validate

This should cover W3C XML Schema, Relax NG and DTD related problems.
robcrom
Posts: 1

Cannot get extended XHTML to validate

Fri Jan 08, 2010 2:47 am

Hello,

I've been trying for the last few days to create a custom markup based on XHTML. I've tried, without success, using XML schema (xsd) and DTD schemas. Both examples I've used have been sourced directly from the w3c sites.

The first is "simpleml". All the code is laid out here:

http://www.w3.org/TR/xhtml-modularizati ... oping.html

Three files:
simpleml-1_0.xsd

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           targetNamespace="http://www.w3.org/1999/xhtml"
           xmlns:simpleml="http://www.example.com/xmlns/simpleml1"
           xmlns="http://www.w3.org/1999/xhtml"
           blockDefault="#all">

  <xs:annotation>
    <xs:documentation>
      This is the XML Schema Driver for new
      Document Type XHTML Basic 1.0 + SimpleML
      $Id: simpleml-1_0.xsd,v 1.5 2006/06/12 22:38:55 ahby Exp $
    </xs:documentation>
    <xs:documentation source="http://www.w3.org/MarkUp/SCHEMA/xhtml-copyright-1.xsd"/>
  </xs:annotation>
 
  <xs:import namespace="http://www.example.com/xmlns/simpleml1"
             schemaLocation="simpleml-module-1.xsd"/>
 
  <xs:redefine schemaLocation="http://www.w3.org/MarkUp/SCHEMA/xhtml-basic10.xsd">
    <xs:group name="xhtml.Misc.class">
      <xs:choice>
        <xs:group ref="xhtml.Misc.class"/>
        <xs:element ref="simpleml:element"/>
      </xs:choice>
    </xs:group>

    <xs:attributeGroup name="xhtml.img.attlist">
       <xs:attributeGroup ref="xhtml.img.attlist"/>
       <xs:attribute ref="simpleml:myattr"/>
    </xs:attributeGroup>     
  </xs:redefine>
   
</xs:schema>


simpleml-module-1.xsd

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.example.com/xmlns/simpleml1"
  xmlns="http://www.example.com/xmlns/simpleml1">
 
  <xs:annotation>
    <xs:documentation>
      This is the XML Schema module for module SimpleML
      $Id: simpleml-module-1.xsd,v 1.5 2006/06/12 22:38:55 ahby Exp $
    </xs:documentation>
    <xs:documentation source="http://www.w3.org/MarkUp/SCHEMA/xhtml-copyright-1.xsd"/>
  </xs:annotation>
 
  <xs:attributeGroup name="xhtml.Common.attrib">
    <xs:attribute name="id" type="xs:ID"/>
  </xs:attributeGroup>
 
  <xs:group name="otherelement.content">
    <xs:sequence/>
  </xs:group>
 
  <xs:attributeGroup name="otherelement.attlist">
    <xs:attributeGroup ref="xhtml.Common.attrib"/>   
  </xs:attributeGroup>
 
  <xs:complexType name="otherelement.type">
    <xs:group ref="otherelement.content"/>
    <xs:attributeGroup ref="otherelement.attlist"/>
  </xs:complexType>
 
  <xs:element name="otherelement" type="otherelement.type"/>
 
  <xs:group name="element.content">
    <xs:choice>
      <xs:element ref="otherelement" minOccurs="0" maxOccurs="unbounded"/>
    </xs:choice>
  </xs:group>
 
  <xs:attributeGroup name="element.attlist">
    <xs:attributeGroup ref="xhtml.Common.attrib"/>   
  </xs:attributeGroup>
 
  <xs:complexType name="element.type" mixed="true">
    <xs:group ref="element.content"/>
    <xs:attributeGroup ref="element.attlist"/>
  </xs:complexType>
 
  <xs:element name="element" type="element.type"/>
 
  <!-- Note: Global attribute -->
  <xs:attribute name="myattr" type="xs:string"/>
 
</xs:schema>


And the instance document:
simple-prefixed.xml

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:simpleml="http://www.example.com/xmlns/simpleml1"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.w3.org/1999/xhtml simpleml-1_0.xsd">
    <head>
        <title>An example using defaults</title>
    </head>
    <body>
        <p>This is content in the XHTML namespace</p>
        <simpleml:element>
            This is content in the SimpleML namespace.
            <simpleml:otherelement/>
        </simpleml:element>
        <p>
            <img src="missing" alt="Missing image" simpleml:myattr="value"/>
        </p>
    </body>
</html>


I get the following validation error:

SystemID: /simple-prefixed.xml
Engine name: Xerces
Severity: error
Description: cvc-elt.1: Cannot find the declaration of element 'html'.
Start location: 2:2
End location: 2:6
URL: http://www.w3.org/TR/xmlschema-1/#cvc-elt
Radu
Posts: 5382

Re: Cannot get extended XHTML to validate

Mon Jan 11, 2010 11:07 am

Hi,

Just try to add this to the simpleml-1_0.xsd schema:

Code: Select all

  <xs:element name="html" type="xhtml.html.type"/>


From what it seems the http://www.w3.org/MarkUp/SCHEMA/xhtml-basic10.xsd contains the type definition for html but not the element declaration.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Return to “XML Schemas”

Who is online

Users browsing this forum: No registered users and 0 guests