xml editor

Products

Features

  EPUB
Supported platforms

Supports Windows 7 & Mac OS X Lion

Ready for XML Editor data server software
W3C Member

validate XHTML doc with DTD and schema

This should cover W3C XML Schema, Relax NG and DTD related problems.

validate XHTML doc with DTD and schema

Postby maglid » Thu Apr 14, 2011 12:04 am

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
maglid
 
Posts: 12
Joined: Mon Sep 28, 2009 8:10 am

Re: validate XHTML doc with DTD and schema

Postby george » Fri Apr 15, 2011 5:20 pm

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
george
Site Admin
 
Posts: 2033
Joined: Thu Jan 09, 2003 2:58 pm


Return to XML Schemas

Who is online

Users browsing this forum: No registered users and 0 guests

cron
XML Editor | XML Author | WYSIWYG Editors | Schema Editor | XSD Documentation | XSL/XSLT Editor | XQuery | XML Databases | SVN Client
© 2002-2011 SyncRO Soft Ltd. All rights reserved. | Sitemap | Privacy Policy | This website was created & generated with <oXygen/>® XML Editor