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