validate XHTML doc with DTD and schema

This should cover W3C XML Schema, Relax NG and DTD related problems.
maglid
Posts: 75
Joined: Mon Sep 28, 2009 8:10 am

validate XHTML doc with DTD and schema

Post by maglid »

How can I validate an XHTML doc that has an embedded W3C Schema namespace? I have the MadCap.xsd schema referenced below. (This is a MadCap Flare file.)

Here is the head of the XHTML file:

Code: Select all

<html xmlns="http://www.w3.org/1999/xhtml" 
xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd"
MadCap:lastBlockDepth="3" MadCap:lastHeight="723"
MadCap:lastWidth="792">
<head><title>IPv6 Test Parameters</title>
<link href="../spirent_univ.css" rel="stylesheet"
type="text/css" />
</head>
<body>
<h1>IPv6 Test Parameters (RFC 2544) </h1>
...
Thanks,
Mark
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Re: validate XHTML doc with DTD and schema

Post by george »

Hi Mark,

I cannot find any XML Schema document at that location: http://www.madcapsoftware.com/Schemas/MadCap.xsd so although that looks like a schema document it is just an identifier for their namespace.

The file is not XHTML valid against the XHTML DTD or schema. You have either the option to create a modified version of the XHTML DTD or schema (or ask Madcap for that) and then validate against that DTD or schema or you can use NVDL to filter the XHTML content and validate that with the XHTML schema and either ignore the other content (as you can see in the sample below) or validate that with another schema, if you have such a schema.
Below you can find a working sample that gathers all XHTML content and validates it while ignoring everything else:

test.nvdl

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0"
xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" startMode="html">
<!-- Triggers validations of XHTML -->
<mode name="html">
<namespace ns="http://www.w3.org/1999/xhtml">
<validate schema="http://www.w3.org/1999/xhtml/xhtml.rng" useMode="allXHTML"/>
</namespace>
</mode>
<!-- Attaches all XHTML sections, ignores everything else -->
<mode name="allXHTML">
<namespace ns="http://www.w3.org/1999/xhtml">
<attach/>
</namespace>
<anyNamespace match="attributes elements">
<unwrap/>
</anyNamespace>
</mode>
</rules>
test.xml

Code: Select all


<?oxygen NVDLSchema="test.nvdl"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd"
MadCap:lastBlockDepth="3" MadCap:lastHeight="723"
MadCap:lastWidth="792">
<head><title>IPv6 Test Parameters</title>
<link href="../spirent_univ.css" rel="stylesheet"
type="text/css" />
</head>
<body>
<h1>IPv6 Test Parameters (RFC 2544) </h1>
</body>
</html>
Best Regards,
George
George Cristian Bina
Post Reply