You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Kaspar Fischer <fi...@inf.ethz.ch> on 2007/11/07 23:59:39 UTC
Validation using local copy of DTD
Hi!
I am using the Xerces parser to validate XHTML files input by the
user (via
the WYSIWYG editor TinyMCE). So I am dealing with documents that look
like
this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv ="Content-Type" content="text/html;
charset=utf-8" />
<title>Ttile</title>
</head>
<body>Something.</body>
</html>
I turn on validation using
parser.setFeature("http://xml.org/sax/features/validation", true);
parser.setFeature("http://apache.org/xml/features/validation/
schema", true);
parser.setFeature("http://apache.org/xml/features/validation/
schema-full-checking",true);
This works like a charm and I am very pleased with the results. Only one
thing is not so good: The parser loads the DTD from w3.org everytime. I
therefore downloaded the file
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
(is it the right one?) and set
parser.setFeature("http://apache.org/xml/features/honour-all-
schemaLocations", true);
parser.setProperty("http://apache.org/xml/properties/schema/
external-schemaLocation",
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd alfresco/
module/org.icarbasel.module.KnowledgeCenter/validation/xhtml1-
strict.dtd");
in the hope that the parser would load my local copy of the file.
Unfortunately, it does not.
Can anybody help me?
(The parser is run from within tomcat, by the way.)
Looking forward to any hint,
many thanks,
Kaspar
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: Validation using local copy of DTD
Posted by Jacob Kjome <ho...@visi.com>.
Normally, you'd either use an EntityResolver or at least provide a valid URL.
Assuming the "alfresco" directory is at the root of the file system, you'd do...
file:/alfresco/module/org/icarbasel/module/KnowledgeCenter/validation/xhtml1-strict.dtd
Jake
Kaspar Fischer wrote:
> Hi!
>
> I am using the Xerces parser to validate XHTML files input by the user (via
> the WYSIWYG editor TinyMCE). So I am dealing with documents that look like
> this:
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
> <head>
> <meta http-equiv ="Content-Type" content="text/html; charset=utf-8" />
> <title>Ttile</title>
> </head>
> <body>Something.</body>
> </html>
>
> I turn on validation using
>
> parser.setFeature("http://xml.org/sax/features/validation", true);
> parser.setFeature("http://apache.org/xml/features/validation/schema",
> true);
>
> parser.setFeature("http://apache.org/xml/features/validation/schema-full-checking",true);
>
>
> This works like a charm and I am very pleased with the results. Only one
> thing is not so good: The parser loads the DTD from w3.org everytime. I
> therefore downloaded the file
>
> http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
>
> (is it the right one?) and set
>
>
> parser.setFeature("http://apache.org/xml/features/honour-all-schemaLocations",
> true);
>
> parser.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation",
>
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
> alfresco/module/org.icarbasel.module.KnowledgeCenter/validation/xhtml1-strict.dtd");
>
>
> in the hope that the parser would load my local copy of the file.
> Unfortunately, it does not.
>
> Can anybody help me?
>
> (The parser is run from within tomcat, by the way.)
>
> Looking forward to any hint,
> many thanks,
> Kaspar
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: Validation using local copy of DTD
Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Kaspar,
You can redirect to a local copy of the DTD with an XML Catalog [1] or your
own custom EntityResolver (which Jacob suggested).
Note that the
"http://apache.org/xml/properties/schema/external-schemaLocation" property
and many of the other features you're setting only apply to XML Schema
validation. They have no impact on DTD processing.
Thanks.
[1] http://xerces.apache.org/xerces2-j/faq-xcatalogs.html
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
Kaspar Fischer <fi...@inf.ethz.ch> wrote on 11/07/2007 05:59:39 PM:
> Hi!
>
> I am using the Xerces parser to validate XHTML files input by the
> user (via
> the WYSIWYG editor TinyMCE). So I am dealing with documents that look
> like
> this:
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
> www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
> <head>
> <meta http-equiv ="Content-Type" content="text/html;
> charset=utf-8" />
> <title>Ttile</title>
> </head>
> <body>Something.</body>
> </html>
>
> I turn on validation using
>
> parser.setFeature("http://xml.org/sax/features/validation", true);
> parser.setFeature("http://apache.org/xml/features/validation/
> schema", true);
> parser.setFeature("http://apache.org/xml/features/validation/
> schema-full-checking",true);
>
> This works like a charm and I am very pleased with the results. Only one
> thing is not so good: The parser loads the DTD from w3.org everytime. I
> therefore downloaded the file
>
> http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
>
> (is it the right one?) and set
>
> parser.setFeature("http://apache.org/xml/features/honour-all-
> schemaLocations", true);
> parser.setProperty("http://apache.org/xml/properties/schema/
> external-schemaLocation",
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd alfresco/
> module/org.icarbasel.module.KnowledgeCenter/validation/xhtml1-
> strict.dtd");
>
> in the hope that the parser would load my local copy of the file.
> Unfortunately, it does not.
>
> Can anybody help me?
>
> (The parser is run from within tomcat, by the way.)
>
> Looking forward to any hint,
> many thanks,
> Kaspar
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org