Skip to content
This repository
Browse code

Treat unsupported namespaces differently from unknown ones.

Add a specific warning for namespaces that are in use but unsupported
by the validator. Point to the specification.
  • Loading branch information...
commit 921197340058e313a81b6e63c12dc00c8d33a7fb 1 parent aaf55a4
Joseph Walton josephw authored
26 docs-xml/warning/UnsupportedNamespace.xml
... ... @@ -0,0 +1,26 @@
  1 +<fvdoc>
  2 +<div xmlns='http://www.w3.org/1999/xhtml'>
  3 +<div id='message'>
  4 +<p>Unable to validate namespace: <code>http://namespace.uri/</code>. See the <i>foo</i> specification at <code>http://namespace.uri/specification</code></p>
  5 +</div>
  6 +<div id='explanation'>
  7 +<p>Even though the feed validator has build in support for quite a
  8 +<a href="../howto/declare_namespaces.html">large number</a>
  9 +of popular namespaces, you somehow managed to have found one that the
  10 +feed validator does not (yet) support.</p>
  11 +</div>
  12 +<div id='solution'>
  13 +<p>The feed validator is unable to verify the correct usage of this namespace.
  14 +Either it is not well-specified, there are no test cases to demonstrate
  15 +correct use or it just hasn't been implemented.</p>
  16 +<p>Please consult the specification for correct use of this namespace.</p>
  17 +<p>If you know of a namespace that you feel that the feed validator should
  18 +support, <a href="http://groups.google.com/group/feedvalidator-users">let us
  19 +know</a>. Please include in your request a pointer to the documentation for
  20 +the namespace. Such documentation should describe the XML elements and
  21 +attributes defined for this namespace. More information and the status of
  22 +current requests can be found on the <a
  23 +href="http://code.google.com/p/feedvalidator/wiki/ExtensionNamespaces">wiki</a>.</p>
  24 +</div>
  25 +</div>
  26 +</fvdoc>
1  docs/index.html
@@ -295,6 +295,7 @@
295 295 <li><a href="warning/UnknownNamespace.html">Use of unknown namespace: <code>http://namespace.uri/</code></a></li>
296 296 <li><a href="warning/UnregisteredAtomLinkRel.html">Unregistered <code>link</code> relationship: <code>foo</code></a></li>
297 297 <li><a href="warning/UnsupportedItunesFormat.html">Format <code>foo</code> is not supported by iTunes</a></li>
  298 +<li><a href="warning/UnsupportedNamespace.html">Unable to validate namespace: <code>http://namespace.uri/</code>. See the <i>foo</i> specification at <code>http://namespace.uri/specification</code></a></li>
298 299 <li><a href="warning/UseOfExtensionAttr.html">Use of extension attribute on RSS 2.0 core element: <code>(namespace,name)</code></a></li>
299 300 <li><a href="warning/UseZeroForMidnight.html">Use zero for midnight</a></li>
300 301 </ul>
83 docs/warning/UnsupportedNamespace.html
... ... @@ -0,0 +1,83 @@
  1 +<?xml version="1.0" encoding="ISO-8859-1"?>
  2 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3 +<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  4 +<head>
  5 +<title>Unable to validate namespace: http://namespace.uri/. See the foo specification at http://namespace.uri/specification</title>
  6 +<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  7 +<link rel="icon" href="http://www.feedvalidator.org/favicon.ico" />
  8 +<link rel="shortcut icon" href="http://www.feedvalidator.org/favicon.ico" />
  9 +<style type="text/css" media="screen">@import "../../css/common.css";
  10 +@import "../../css/documentation.css";</style>
  11 +<script type="text/javascript"><!-- --></script>
  12 +<link rel="start" href="http://feedvalidator.org/docs/" title="Home" />
  13 +</head>
  14 +<body>
  15 +<div id="logo">
  16 +<h1><a href="../../"><span id="feed"><span id="f">F</span><span id="e1">E</span><span id="e2">E</span></span><span id="d">D</span> Validator</a></h1>
  17 +<p>Documentation</p>
  18 +<a class="skip" href="#startnavigation">Jump to navigation</a>
  19 +</div> <!--logo-->
  20 +
  21 +<div id="main">
  22 +<h2>Message</h2>
  23 +<div class="docbody">
  24 +<p>Unable to validate namespace: <code>http://namespace.uri/</code>. See the <i>foo</i> specification at <code>http://namespace.uri/specification</code></p>
  25 +</div>
  26 +<h2>Explanation</h2>
  27 +
  28 +<div class="docbody">
  29 +<p>Even though the feed validator has build in support for quite a
  30 +<a href="../howto/declare_namespaces.html">large number</a>
  31 +of popular namespaces, you somehow managed to have found one that the
  32 +feed validator does not (yet) support.</p>
  33 +</div>
  34 +<h2>Solution</h2>
  35 +<div class="docbody">
  36 +<p>The feed validator is unable to verify the correct usage of this namespace.
  37 +Either it is not well-specified, there are no test cases to demonstrate
  38 +correct use or it just hasn't been implemented.</p>
  39 +<p>Please consult the specification for correct use of this namespace.</p>
  40 +<p>If you know of a namespace that you feel that the feed validator should
  41 +support, <a href="http://groups.google.com/group/feedvalidator-users">let us
  42 +know</a>. Please include in your request a pointer to the documentation for
  43 +the namespace. Such documentation should describe the XML elements and
  44 +attributes defined for this namespace. More information and the status of
  45 +current requests can be found on the <a
  46 +href="http://code.google.com/p/feedvalidator/wiki/ExtensionNamespaces">wiki</a>.</p>
  47 +</div>
  48 +<h2>Not clear? Disagree?</h2>
  49 +<div class="docbody">
  50 +<p>You might be able to find help in one of <a href="../howto/resources.html">these fine resources</a>.</p>
  51 +</div>
  52 +
  53 +</div><!--main-->
  54 +<div class="centered">
  55 +<a name="startnavigation" id="startnavigation"></a>
  56 +<div class="navbarWrapper">
  57 + <div class="navbarContent">
  58 + <img class="borderTL" src="../../images/borderTL.gif" alt="" width="14" height="14" />
  59 + <img class="borderTR" src="../../images/borderTR.gif" alt="" width="14" height="14" />
  60 +
  61 +<p>
  62 +<a href="../../">Home</a> &middot;
  63 +<a href="../../about.html">About</a> &middot;
  64 +<a href="../../news/">News</a> &middot;
  65 +<a href="../../docs/">Docs</a> &middot;
  66 +<a href="../../terms.html">Terms</a>
  67 +</p>
  68 +
  69 + <div class="roundedCornerSpacer">&nbsp;</div>
  70 + </div><!-- .content -->
  71 + <div class="bottomCorners">
  72 + <img class="borderBL" src="../../images/borderBL.gif" alt="" width="14" height="14" />
  73 + <img class="borderBR" src="../../images/borderBR.gif" alt="" width="14" height="14" />
  74 + </div><!-- .bottomCorners -->
  75 +</div><!-- .contentWrapper -->
  76 +</div><!-- .centered -->
  77 +
  78 +<div class="centered">
  79 +<address>Copyright &copy; 2002-4 <a href="http://diveintomark.org/">Mark Pilgrim</a> and <a href="http://www.intertwingly.net/blog/">Sam Ruby</a></address>
  80 +</div>
  81 +
  82 +</body>
  83 +</html>
14 src/feedvalidator/base.py
@@ -84,6 +84,11 @@
84 84 "xri://$xrds": "xrds",
85 85 }
86 86
  87 +unsupported_namespaces = {
  88 + "http://schemas.google.com/g/2005": ("Google Data", "https://developers.google.com/gdata/docs/1.0/elements"),
  89 + "http://www.rawvoice.com/rawvoiceRssModule/": ("RawVoice", "http://www.rawvoice.com/services/tools-and-resources/rawvoice-rss-2-0-module-xmlns-namespace-rss2/")
  90 +}
  91 +
87 92 def near_miss(ns):
88 93 try:
89 94 return re.match(".*\w", ns).group().lower()
@@ -172,8 +177,13 @@ def startPrefixMapping(self, prefix, uri):
172 177 rule.setElement('xmlns:'+str(prefix), {}, self.handler_stack[-1][0])
173 178 rule.value=uri
174 179 if not uri or rule.validate():
175   - from logging import UnknownNamespace
176   - self.log(UnknownNamespace({'namespace':uri}))
  180 + if uri in unsupported_namespaces:
  181 + from logging import UnsupportedNamespace
  182 + (name, specification) = unsupported_namespaces[uri]
  183 + self.log(UnsupportedNamespace({'namespace': uri, 'name': name, 'specification': specification}))
  184 + else:
  185 + from logging import UnknownNamespace
  186 + self.log(UnknownNamespace({'namespace':uri}))
177 187
178 188 def namespaceFor(self, prefix):
179 189 return None
1  src/feedvalidator/i18n/en.py
@@ -254,6 +254,7 @@
254 254 UseZeroForUnknown: "Use zero for unknown length",
255 255 UnknownHost: "Unknown host",
256 256 UnknownNamespace: "Use of unknown namespace: %(namespace)s",
  257 + UnsupportedNamespace: "Unable to validate namespace: %(namespace)s. See the %(name)s specification at %(specification)s",
257 258 IntegerOverflow: "%(element)s value too large",
258 259 InvalidNSS: "Invalid Namespace Specific String: %(element)s",
259 260 SinceAfterUntil: "Since After until",
1  src/feedvalidator/logging.py
@@ -246,6 +246,7 @@ class MisplacedXHTMLContent(Warning): pass
246 246 class SchemeNotIANARegistered(Warning): pass
247 247 class AvoidNamespacePrefix(Warning): pass
248 248 class UnknownNamespace(Warning): pass
  249 +class UnsupportedNamespace(Warning): pass
249 250
250 251 class MissingRecommendedAttribute(Warning): pass
251 252
27 testcases/atom/6.1/unsupported-namespace.xml
... ... @@ -0,0 +1,27 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<!--
  3 +Description: Unsupported namespaces get a warning
  4 +Expect: UnsupportedNamespace{namespace:http://schemas.google.com/g/2005}
  5 +-->
  6 +
  7 +<feed xmlns="http://www.w3.org/2005/Atom"
  8 + xmlns:a="http://www.w3.org/2007/app">
  9 +
  10 + <title>Example Feed</title>
  11 + <link href="http://example.org/"/>
  12 + <updated>2003-12-13T18:30:02Z</updated>
  13 + <author>
  14 + <name>John Doe</name>
  15 + <email xmlns='http://schemas.google.com/g/2005'>user@example.test</email>
  16 + </author>
  17 + <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
  18 +
  19 + <entry>
  20 + <title>Atom-Powered Robots Run Amok</title>
  21 + <link href="http://example.org/2003/12/13/atom03"/>
  22 + <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
  23 + <updated>2003-12-13T18:30:02Z</updated>
  24 + <summary>Some text.</summary>
  25 + </entry>
  26 +
  27 +</feed>

0 comments on commit 9211973

Please sign in to comment.
Something went wrong with that request. Please try again.