Why do I get errors for multiple @xmlns on /html element?

Questions about XML that are not covered by the other forums should go here.

Why do I get errors for multiple @xmlns on /html element?

Postby Zearin » Tue Nov 13, 2007 8:05 pm

So, I've got the following:
Code: Select all
<html
   xmlns="http://www.w3.org/1999/xhtml"
   xmlns:doap="http://usefulinc.com/ns/doap#"
   xmlns:foaf="http://xmlns.com/foaf/0.1/"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:xf="http://www.w3.org/2002/xforms"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">


…and so on and so forth. But for every @xmlns except the default (XHTML), I'm getting the following error:
E [Xerces] Attribute "xmlns:rdf" must be declared for element type "html".

The same error for every namespace prefix in the list. I've just listed the RDF error for brevity.

Why is this?

I haven't really used multiple @xmlns on an XHTML document before, so I'm not sure where to go from here. I'm currently using a 1.0 Strict DocType.
-- Zearin
Zearin
 
Posts: 107
Joined: Mon Jul 30, 2007 11:31 pm
Location: College Park, MD, United States

Postby sorin » Wed Nov 14, 2007 4:05 pm

Hello,

The XHTML 1.0 Strict DTD allows only the first xmlns attribute that you used:

Code: Select all
<!ATTLIST html
  %i18n;
  id          ID             #IMPLIED
  xmlns       %URI;          #FIXED 'http://www.w3.org/1999/xhtml'
  >

You can modify the XHTML DTD or you can use one of the Relax NG equivalents of the XHTML DTDs available in [oXygen-install-folder]/frameworks/xhtml/relaxng: xhtml.rng, xhtml-basic.rng, xhtml-strict.rng. You associate a schema with the edited document by applying the action Associate Schema available on the toolbar Document and the menu Document -> XML Document.


Regards,
Sorin
sorin
 
Posts: 4003
Joined: Fri Mar 28, 2003 2:12 pm

Re: Why do I get errors for multiple @xmlns on /html element?

Postby sampablokuper » Fri Sep 12, 2008 6:28 pm

I'm getting similar errors.

Here are the first few lines of my document:
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
 xmlns:dc="http://purl.org/dc/elements/1.1/">
 <head>
  <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8"/>
  <title>foo</title>
 </head>


I'm getting the following errors in Oxygen when I attempt to validate the document:

Attribute "xmlns:rdf" must be declared for element type "html".
Attribute "xmlns:owl" must be declared for element type "html".
Attribute "xmlns:rdfs" must be declared for element type "html".
Attribute "xmlns:dc" must be declared for element type "html".

I'd be glad of any insights anyone can offer!

Many thanks,

Sam
sampablokuper
 
Posts: 22
Joined: Tue Apr 08, 2008 1:41 pm

Re: Why do I get errors for multiple @xmlns on /html element?

Postby sorin » Mon Sep 15, 2008 11:23 am

Hello,

sampablokuper wrote:I'm getting the following errors in Oxygen when I attempt to validate the document:

Attribute "xmlns:rdf" must be declared for element type "html".
Attribute "xmlns:owl" must be declared for element type "html".
Attribute "xmlns:rdfs" must be declared for element type "html".
Attribute "xmlns:dc" must be declared for element type "html".

I'd be glad of any insights anyone can offer!

Many thanks,

Sam


The declarations of the namespace prefixes are reported as validation errors because the XHTML DTD specified in your XML document (xhtml-rdfa-1.dtd) and used for validating your document does not allow these declarations on the root element html. In the case of DTD the namespace declarations allowed on an element are strictly controlled by the DTD.

In the case of an XML Schema used for validating a document you can insert any namespace declaration on an element. You should consider using an XML Schema instead of a DTD.


Regards,
Sorin
sorin
 
Posts: 4003
Joined: Fri Mar 28, 2003 2:12 pm

Re: Why do I get errors for multiple @xmlns on /html element?

Postby sampablokuper » Mon Sep 15, 2008 3:57 pm

Dear Sorin,

Thanks for your quick reply. It seems that Oxygen's validator works differently to the W3C's validator. For instance, the following RDFa document (copied from Wikipedia):

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
    "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:foaf="http://xmlns.com/foaf/0.1/"
    xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">
    <head>
        <title>John's Home Page</title>
        <base href="http://example.org/john-d/"/>
        <meta property="dc:creator" content="Jonathan Doe"/>
    </head>
    <body>
        <h1>John's Home Page</h1>
        <p>My name is <span property="foaf:nick">John D</span> and I like <a
                href="http://www.neubauten.org/" rel="foaf:interest" xml:lang="de">Einstürzende
                Neubauten</a>.</p>
        <p>My <span rel="foaf:interest" resource="urn:ISBN:0752820907">favorite book</span> is the
            inspiring <span about="urn:ISBN:0752820907"><cite property="dc:title">Weaving the
                Web</cite> by <span property="dc:creator">Tim Berners-Lee</span></span>.</p>
    </body>
</html>


is declared valid by the W3C validator whereas Oxygen's response to it is:

Attribute "xmlns:foaf" must be declared for element type "html".
Attribute "xmlns:dc" must be declared for element type "html".

My guess is that Oxygen may need to be updated so that it is capable of handling RDFa documents. Alternatively, there is something wrong with the W3C validator, but that seems unlikely.

I would glad to know your thoughts,

Sam
sampablokuper
 
Posts: 22
Joined: Tue Apr 08, 2008 1:41 pm

Re: Why do I get errors for multiple @xmlns on /html element?

Postby george » Mon Sep 15, 2008 4:56 pm

Hi Sam,

oXygen performs a validation of that document against the specified DTD. That is not valid for sure as the referred DTD does not define the xmlns:dc and xmlns:foaf as attributes of the html element. Sure, these are namespace declarations but DTDs are not namespace aware and the namespace declarations need to be defined inside the DTD as normal attributes.

I do not know what the W3C validator does exactly but it does not check the file against the http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd DTD.

For example, if you validate the file with oXygen using the External Validation action and you specify the http://www.w3.org/MarkUp/SCHEMA/xhtml-rdfa-1.xsd schema in the XML Schema tab then oXygen will report that the document is valid against this schema. You can eventually make the association inside the document like below:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
    "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.w3.org/1999/xhtml http://www.w3.org/MarkUp/SCHEMA/xhtml-rdfa-1.xsd"
 xmlns:dc="http://purl.org/dc/elements/1.1/"
 xmlns="http://www.w3.org/1999/xhtml"
 xmlns:foaf="http://xmlns.com/foaf/0.1/"
 xml:lang="en">
    <head>
        <title>John's Home Page</title>
        <base href="http://example.org/john-d/" />
        <meta property="dc:creator" content="Jonathan Doe" />
    </head>
    <body>
        <h1>John's Home Page</h1>
        <p>My name is <span property="foaf:nick">John D</span> and I like
            <a href="http://www.neubauten.org/" rel="foaf:interest"
                xml:lang="de">Einstürzende Neubauten</a>.</p>
        <p>My <span rel="foaf:interest" resource="urn:ISBN:0752820907">favorite
            book</span> is the inspiring <span about="urn:ISBN:0752820907"><cite
                property="dc:title">Weaving the Web</cite> by
                <span property="dc:creator">Tim Berners-Lee</span></span>.</p>
    </body>
</html>



If you want to stay with the DTD then you can define the two namespace declarations inside the internal subset like below:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
    "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"[   
    <!ATTLIST html xmlns:foaf CDATA #IMPLIED>
    <!ATTLIST html xmlns:dc CDATA #IMPLIED>
    ]>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:foaf="http://xmlns.com/foaf/0.1/"
    xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">
    <head>
        <title>John's Home Page</title>
        <base href="http://example.org/john-d/" />
        <meta property="dc:creator" content="Jonathan Doe" />
    </head>
    <body>
        <h1>John's Home Page</h1>
        <p>My name is <span property="foaf:nick">John D</span> and I like
            <a href="http://www.neubauten.org/" rel="foaf:interest"
                xml:lang="de">Einstürzende Neubauten</a>.</p>
        <p>My <span rel="foaf:interest" resource="urn:ISBN:0752820907">favorite
            book</span> is the inspiring <span about="urn:ISBN:0752820907"><cite
                property="dc:title">Weaving the Web</cite> by
                <span property="dc:creator">Tim Berners-Lee</span></span>.</p>
    </body>
</html>


and then the document will be valid against the DTD.

Best Regards,
George
George Cristian Bina
george
Site Admin
 
Posts: 2076
Joined: Thu Jan 09, 2003 2:58 pm

Re: Why do I get errors for multiple @xmlns on /html element?

Postby sampablokuper » Tue Sep 16, 2008 1:32 pm

Dear George,

Thanks for your reply. This is extremely helpful! :D

The only issue I'm now faced with - and it's a nice problem to have! - is that I'm now spoiled for choice! :) If you or anyone else has any thoughts about the pros and cons of the two valid methods, I'd be grateful to know them.

Many thanks,

Sam
sampablokuper
 
Posts: 22
Joined: Tue Apr 08, 2008 1:41 pm

Re: Why do I get errors for multiple @xmlns on /html element?

Postby george » Tue Sep 16, 2008 5:21 pm

Hi Sam,

I would go with a schema (XML Schema or Relax NG) simply because DTDs are not namespace aware and the RDFa needs namespaces.

Best Regards,
George
George Cristian Bina
george
Site Admin
 
Posts: 2076
Joined: Thu Jan 09, 2003 2:58 pm

Re: Why do I get errors for multiple @xmlns on /html element?

Postby sampablokuper » Tue Sep 16, 2008 5:28 pm

george wrote:I would go with a schema (XML Schema or Relax NG) simply because DTDs are not namespace aware and the RDFa needs namespaces.

Thanks George,

In addition to your suggestion above, I found that the DTD version didn't render properly in all browsers. XSD version it is, then! (NB. I haven't tried Relax NG for this, because I'm working in a situation where I'm trying to keep the number of schema formats to a minimum - but thanks for suggesting Relax NG as another option.)

Many thanks,

Sam
sampablokuper
 
Posts: 22
Joined: Tue Apr 08, 2008 1:41 pm

Re: Why do I get errors for multiple @xmlns on /html element?

Postby kennedyzor » Thu Dec 11, 2008 7:34 pm

Hi george

Hello i'm new to this forum and i'll know about DTD & RDF. Could tell something about DTD & RDF ?

Thanks in advance.....

data conversion services india
kennedyzor
 
Posts: 1
Joined: Thu Dec 11, 2008 7:24 pm

Re: Why do I get errors for multiple @xmlns on /html element?

Postby aliman » Mon Dec 15, 2008 2:28 pm

Hi folks, thanks for this thread, really helpful.

I hit a couple of problems.

I tried using the implied attribute list with the DTD validation. That worked fine with Oxygen, but when I passed the document to the W3C validator it failed to recognise the document type correctly (it tried to validate as XHTML 1.0 transitional).

I then tried associating the XML schema, but got a really wierd validation error regarding the script tag and a complaint about an xml:space attribute that isn't there.

Here's my code...

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
       "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.w3.org/1999/xhtml http://www.w3.org/MarkUp/SCHEMA/xhtml-rdfa-1.xsd"
 xmlns:con="http://www.w3.org/2000/10/swap/pim/contact#"
 xmlns="http://www.w3.org/1999/xhtml"
 xmlns:rec="http://www.w3.org/2001/02pd/rec54#"
 xmlns:dct="http://purl.org/dc/terms/"
 xmlns:mat="http://www.w3.org/2002/05/matrix/vocab#"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
 xmlns:owl="http://www.w3.org/2002/07/owl#"
 xmlns:doc="http://www.w3.org/2000/10/swap/pim/doc#"
 xmlns:org="http://www.w3.org/2001/04/roadmap/org#">
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  <title>SKOS Simple Knowledge Organisation System Reference, Editors' Draft
  1 October 2008 $Revision: 1.38 $</title>
  <meta name="generator" content="Amaya 9.54, see http://www.w3.org/Amaya/" />
  <link href="extras.css" rel="stylesheet" type="text/css" />
  <link href="http://www.w3.org/StyleSheets/TR/base" rel="stylesheet"
  type="text/css" />
  <script type="text/javascript" src="extras.js"></script>
</head>


Here's the validation error, which occurs at the script tag...

Code: Select all
Severity and Description   Path   Resource   Location   Creation Time   Id
[Xerces] cvc-complex-type.3.2.2: Attribute 'xml:space' is not allowed to appear in element 'script'.
@see: http://www.w3.org/TR/xmlschema-1/#cvc-complex-type   w3c_WWW_2006_07_SWD_SKOS/reference/20081001   Overview.html   line 23   1229340320526   28150


Any help appreciated.
aliman
 
Posts: 1
Joined: Mon Dec 15, 2008 2:22 pm

Re: Why do I get errors for multiple @xmlns on /html element?

Postby george » Fri Dec 19, 2008 5:45 pm

If you have both a DTD specified and a schema oXygen will validate by default against the schema. That can be controlled from Options->Preferences -- XML / XML Parser -- XML Parser Properties -- "Ignore the DTD for validation if a schema is specified". However, the DTD is still used and the default attributes as specified in the DTD appear in the document before that is validated against the specified schema.

For instance if you remove the schemaLocation attribute and use the "Show definition" action from the contextual menu on the script element then oXygen will open the DTD module that defines the script element. That is
http://www.w3.org/MarkUp/DTD/xhtml-script-1.mod
and the relevant part is
Code: Select all
<!ENTITY % script.attlist  "INCLUDE" >
<![%script.attlist;[
<!ATTLIST %script.qname;
      %XHTML.xmlns.attrib;
     %id.attrib;
      xml:space    ( preserve )             #FIXED 'preserve'
      charset      %Charset.datatype;       #IMPLIED
      type         %ContentType.datatype;   #REQUIRED
      src          %URI.datatype;           #IMPLIED
      defer        ( defer )                #IMPLIED
>
<!-- end of script.attlist -->]]>


You can remove the DOCTYPE declaration and the xml:space will not be added automatically anymore. For example the following file is valid against the schema:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
       "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">-->
<html xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.w3.org/1999/xhtml http://www.w3.org/MarkUp/SCHEMA/xhtml-rdfa-1.xsd"
    xmlns:con="http://www.w3.org/2000/10/swap/pim/contact#"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:rec="http://www.w3.org/2001/02pd/rec54#"
    xmlns:dct="http://purl.org/dc/terms/"
    xmlns:mat="http://www.w3.org/2002/05/matrix/vocab#"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
    xmlns:doc="http://www.w3.org/2000/10/swap/pim/doc#"
    xmlns:org="http://www.w3.org/2001/04/roadmap/org#">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <title>SKOS Simple Knowledge Organisation System Reference, Editors' Draft
            1 October 2008 $Revision: 1.38 $</title>
        <meta name="generator" content="Amaya 9.54, see http://www.w3.org/Amaya/" />
        <link href="extras.css" rel="stylesheet" type="text/css" />
        <link href="http://www.w3.org/StyleSheets/TR/base" rel="stylesheet"
            type="text/css" />
        <script type="text/javascript" src="extras.js"></script>
    </head>
    <body>
    </body>
</html>


Best Regards,
George
George Cristian Bina
george
Site Admin
 
Posts: 2076
Joined: Thu Jan 09, 2003 2:58 pm

Re: Why do I get errors for multiple @xmlns on /html element?

Postby sampablokuper » Mon Jan 05, 2009 7:31 am

It seems to be impossible to satisfy both the W3C validator and Oxygen's validator.

If the doctype is left in, Oxygen declares the document invalid (see Aliman's post) with the error, "Attribute 'xml:space' is not allowed to appear in element 'script'."

But if I apply the workaround you suggested - commenting out the doctype - then although Oxygen declares the file valid, the W3C validator declares it invalid and gives me the following error:

"No DOCTYPE found! Checking with default XHTML 1.0 Transitional Document Type."

Is there a solution - or maybe more than one solution - that will satisfy both validators?

If not, which validator is the best one to heed, and why? Also, if the W3C's validator is at fault and/or the XHTML+RDFa specs result in invalid XML, has anyone from Oxygen raised the matter with the W3C (e.g. filing a bug, etc)?

Many thanks indeed for all the help you've provided so far!
sampablokuper
 
Posts: 22
Joined: Tue Apr 08, 2008 1:41 pm

Re: Why do I get errors for multiple @xmlns on /html element?

Postby sampablokuper » Mon Jan 05, 2009 8:25 am

Hmm, I just noticed that opening http://www.w3.org/MarkUp/SCHEMA/xhtml-rdfa-1.xsd in Oxygen lists a lot of errors along the lines "src-resolve: Cannot resolve the name 'xhtml.dir.attrib' to a(n) 'attribute group' component."

Could this (i.e. faults in http://www.w3.org/MarkUp/SCHEMA/xhtml-rdfa-1.xsd) have anything to do with the problems we're encountering? Or am I barking up the wrong tree?

Thanks,

Sam
sampablokuper
 
Posts: 22
Joined: Tue Apr 08, 2008 1:41 pm

Re: Why do I get errors for multiple @xmlns on /html element?

Postby sampablokuper » Mon Jan 05, 2009 9:02 am

George wrote:
If you have both a DTD specified and a schema oXygen will validate by default against the schema. That can be controlled from Options->Preferences -- XML / XML Parser -- XML Parser Properties -- "Ignore the DTD for validation if a schema is specified". However, the DTD is still used and the default attributes as specified in the DTD appear in the document before that is validated against the specified schema.

This seems like a bug in Oxygen. Am I right about this? In other words, if the "Ignore the DTD for validation if a schema is specified" checkbox is ticked, then Oxygen should not use the DTD, and therefore it should not find the entry in http://www.w3.org/MarkUp/DTD/xhtml-script-1.mod that assigns an xml:space attribute to the <script> element. And if it doesn't find that entry, then Aliman's document should validate, right (assuming it's extended with a valid body and closing html tag)?

Basically, I'm trying to work out what's at fault here. Is it the XHTML code that Aliman and I have been trying to write, or is it the validator(s), or is it the XHTML+RDFa spec, or even some combination of these?

All I want is to be able to write an XHTML+RDFa document that:
  • validates in Oxygen, and
  • validates in the W3C validator, and
  • is capable of containing <style> and <script> elements and any other valid XHTML Strict elements (and, for that matter, XHTML Strict entities).
Is that too much to ask? :(

Sorry for expressing my frustration so frankly, but as you can see, I've been spending quite a bit of time on this!

Thanks again for all the help so far,

Sam
sampablokuper
 
Posts: 22
Joined: Tue Apr 08, 2008 1:41 pm

Next

Return to General XML Questions

Who is online

Users browsing this forum: No registered users and 0 guests

cron