472,986 Members | 2,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,986 software developers and data experts.

problem with validating XHTML 1.1-documents

I'm trying to write a program for validating XHTML 1.1-documents
against the XHTML 1.1 DTD (which is actually the same as validating an
XML-file) but I always get a "(404) Not found" error.

This is the program itself [C#]:

************************************************** ******************
using System;
using System.Xml;
using System.Xml.Schema;

namespace ValidatorTest {
class SimpleValidator {
[STAThread]
static void Main(string[] args) {
string url="http://users.telenet.be/flotspe/test.xhtml";
XmlTextReader reader=new XmlTextReader(url);
reader.Normalization=true;
XhtmlResolver myResolver=new XhtmlResolver();
reader.XmlResolver=myResolver;
XmlValidatingReader valReader=new XmlValidatingReader(reader);
valReader.ValidationEventHandler+=new
ValidationEventHandler(valHandler);
valReader.ValidationType = ValidationType.DTD;
while (valReader.Read()) {
}
valReader.Close();
}
private static void valHandler(object sender,
System.Xml.Schema.ValidationEventArgs e) {
Console.WriteLine("***Validation error***");
Console.WriteLine("\tSeverity:{0}", e.Severity);
Console.WriteLine("\tMessage :{0}", e.Message);

}
}
public class XhtmlResolver:XmlUrlResolver {
public override Uri ResolveUri(Uri baseUri, String relativeUri) {
Uri resolved=base.ResolveUri(baseUri,relativeUri);
Console.WriteLine("[" + resolved.AbsoluteUri + "]");
return resolved;
}
}
}
************************************************** ******************
And this is the output from my program:

************************************************** ******************
[http://users.telenet.be/flotspe/test.xhtml]
[http://users.telenet.be/flotspe/test.xhtml]
[http://users.telenet.be/flotspe/test.xhtml]
[http://users.telenet.be/flotspe/-//W...TML%201.1//EN]
[http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd]
[http://www.w3.org/TR/xhtml-modulariz...nlstyle-1.mod]
[http://www.w3.org/TR/xhtml-modulariz...amework-1.mod]
[http://www.w3.org/TR/xhtml-modulariz...tations-1.mod]
[http://www.w3.org/TR/xhtml-modulariz...tatypes-1.mod]
[http://www.w3.org/TR/xhtml-modulariz...l-qname-1.mod]
[http://www.w3.org/TR/xhtml-modulariz...-events-1.mod]
[http://www.w3.org/TR/xhtml-modulariz...attribs-1.mod]
[http://www.w3.org/TR/xhtml-modulariz...1-model-1.mod]

Unhandled Exception: System.Net.WebException: The remote server
returned an erro
r: (404) Not Found.
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetResponse(IAsyncRes ult
asyncResult)
at System.Net.HttpWebRequest.GetResponse()
at System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri,
ICredentials crede
ntials)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials
credentials)

at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role,
Type ofO
bjectToReturn)
at System.Xml.Schema.DtdParser.HandlePERef()
at System.Xml.Schema.DtdParser.ParseDtdContent()
at System.Xml.Schema.DtdParser.ParseConditionalSect()
at System.Xml.Schema.DtdParser.ParseDtdContent()
at System.Xml.Schema.DtdParser.ParseConditionalSect()
at System.Xml.Schema.DtdParser.ParseDtdContent()
at System.Xml.Schema.DtdParser.ParseDocTypeDecl()
at System.Xml.Schema.DtdParser.Parse()
at System.Xml.XmlTextReader.ParseDtd(XmlScanner scanner)
at System.Xml.XmlTextReader.ParseTag()
at System.Xml.XmlTextReader.ParseRoot()
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlValidatingReader.ReadWithCollectText Token()
at System.Xml.XmlValidatingReader.Read()
at ValidatorTest.SimpleValidator.Main(String[] args) in
e:\flotspe\cs\visual
studio projects\validatortest\class1.cs:line 17
************************************************** ******************
<http://www.w3.org/TR/xhtml-modularization/DTD/xhtml11-model-1.mod>
doesn't exist, it should be
<http://www.w3.org/TR/xhtml11/DTD/xhtml11-model-1.mod>.
<http://www.w3.org/TR/xhtml-modularization/DTD/xhtml-framework-1.mod>
is listed as an absolute URL in
<http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd>.

<xhtml-notations-1.mod>, <xhtml-datatypes-1.mod>, <xhtml-qname-1.mod>,
<xhtml-events-1.mod>
and <xhtml-attribs-1.mod> are relative URL's in
<http://www.w3.org/TR/xhtml-modularization/DTD/xhtml-framework-1.mod>.

<xhtml11-model-1.mod> is also a relative URL but in
<http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd> but the program keeps
using <http://www.w3.org/TR/xhtml-modularization/DTD/> as the base URL
and hence the 404.
Can somebody tell me what I can do about this?

--
Joris "flotspe" Janssens *** http://inferno.xhtml.be/
gecontroleerd op virussen door m'n huisdokter

Nov 12 '05 #1
2 2585
Joris Janssens wrote:
Can somebody tell me what I can do about this?


I'd better download the DTD, fix it if needed and validate against this
local copy. This can be done with custom XmlResolver.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2
Oleg Tkachenko [MVP] schreef op 12/08/2004 :
Joris Janssens wrote:
Can somebody tell me what I can do about this?


I'd better download the DTD, fix it if needed and validate against this local
copy. This can be done with custom XmlResolver.

I just managed to "solve" it by using this custom XmlResolver:

public class Xhtml11Resolver:XmlUrlResolver {
public override Uri ResolveUri(Uri baseUri, string relativeUri) {
if (relativeUri.StartsWith("xhtml11")) {
baseUri=new Uri("http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd");
}
Uri resolved=base.ResolveUri(baseUri,relativeUri);
return resolved;
}
}

Although this is more an ugly hack than an elegant solution...

--
Joris "flotspe" Janssens *** http://inferno.xhtml.be/
The webmaster who says "ni"

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Tjerk Wolterink | last post by:
Hello i've an xsl stylesheet that must support xhtml entities, my solution: ---- <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE xsl:stylesheet > <xsl:stylesheet version="1.0"...
30
by: Toni Mcintyre | last post by:
i'm having 2 problems with the http://validator.w3.org 1. if i have: <meta http-equiv="Content-Script-Type" content="text/javascript"> then why do i need <script type=text/javascript>...
0
by: Lachlan Hunt | last post by:
Hi everyone, I've just discovered a registry hack to get around the Windows XP SP2 security bug that prevents files being uploaded as text/html, and thus unable to validate local html files using...
4
by: johkar | last post by:
When the output method is set to xml, even though I have CDATA around my JavaScript, the operaters of && and < are converted to XML character entities which causes errors in my JavaScript. I know...
9
by: rbronson1976 | last post by:
Hello all, I have a very strange situation -- I have a page that validates (using http://validator.w3.org/) as "XHTML 1.0 Strict" just fine. This page uses this DOCTYPE: <!DOCTYPE html PUBLIC...
2
by: Tjerk Wolterink | last post by:
I've a element definition like this: -- <xs:element name="content"> <xs:complexType> <xs:sequence> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:any...
2
by: Mike Bridge | last post by:
Hi- I've created an XHTML extension module which validates correctly using the W3C online schema validator, but fails when I use the .net 1.1 validator. It seems to be choking on an included W3C...
4
by: Enrika | last post by:
Greetings! I'm working on a CSS drop-down menu, which, to my surprise, is actually working, more-or-less, in both IE *and* Firefox (and Netscape). But there are two changes that I want to make that...
1
mickey0
by: mickey0 | last post by:
hello, validating this file on w3c I have many error: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html...
10
by: Robert Huff | last post by:
Can someone offer suggestions why, on the same server (Apache 2.2.8), this works <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html lang="en-US"> <head> <link rel=stylesheet...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.