From 79d4bb04e9c6fa44e9583d225f5d5775a793e576 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Thu, 15 Jan 2009 16:35:55 -0600 Subject: [PATCH] More descriptive XML errors --- basis/xml/errors/errors-tests.factor | 23 +++++++++------ basis/xml/errors/errors.factor | 42 +++++++++++++++++++--------- basis/xml/tokenize/tokenize.factor | 13 ++++----- basis/xml/xml-docs.factor | 17 ++++++++--- 4 files changed, 61 insertions(+), 34 deletions(-) diff --git a/basis/xml/errors/errors-tests.factor b/basis/xml/errors/errors-tests.factor index e72e465f0d..426ef57736 100644 --- a/basis/xml/errors/errors-tests.factor +++ b/basis/xml/errors/errors-tests.factor @@ -6,22 +6,27 @@ IN: xml.errors.tests '[ _ string>xml ] swap '[ _ = ] must-fail-with ; T{ no-entity f 1 10 "nbsp" } " " xml-error-test -T{ mismatched f 1 8 T{ name f "" "x" "" } T{ name f "" "y" "" } -} "" xml-error-test +T{ mismatched f 1 8 T{ name f "" "x" "" } T{ name f "" "y" "" } } + "" xml-error-test T{ unclosed f 1 4 V{ T{ name f "" "x" "" } } } "" xml-error-test T{ nonexist-ns f 1 5 "x" } "" xml-error-test T{ unopened f 1 5 } "" xml-error-test -T{ not-yes/no f 1 41 "maybe" } "" xml-error-test +T{ not-yes/no f 1 41 "maybe" } + "" xml-error-test T{ extra-attrs f 1 32 V{ T{ name f "" "foo" f } } } "" xml-error-test -T{ bad-version f 1 28 "5 million" } "" xml-error-test +T{ bad-version f 1 28 "5 million" } + "" xml-error-test T{ notags f } "" xml-error-test T{ multitags } "" xml-error-test -T{ bad-prolog f 1 26 T{ prolog f "1.0" "UTF-8" f } -} "" xml-error-test +T{ bad-prolog f 1 26 T{ prolog f "1.0" "UTF-8" f } } + "" xml-error-test T{ capitalized-prolog f 1 6 "XmL" } "" -xml-error-test + xml-error-test T{ pre/post-content f "x" t } "x" xml-error-test T{ versionless-prolog f 1 8 } "" xml-error-test -T{ bad-instruction f 1 11 T{ instruction f "xsl" } -} "" xml-error-test +T{ bad-instruction f 1 11 T{ instruction f "xsl" } } + "" xml-error-test +T{ unclosed-quote f 1 13 } " } "." } @@ -324,6 +321,15 @@ HELP: state-parse HELP: pre/post-content { $class-description "describes the error where a non-whitespace string is used before or after the main tag in an XML document. Contains two slots: string contains the offending string, and pre? is t if it occured before the main tag and f if it occured after" } ; +HELP: unclosed-quote +{ $class-description "describes the error where a quotation for an attribute value is opened but not closed before the end of the document." } ; + +HELP: bad-name +{ $class-description "describes the error where a name is used, for example in an XML tag or attribute key, which is invalid." } ; + +HELP: quoteless-attr +{ $class-description "describes the error where an attribute of an XML tag is missing quotes around a value." } ; + HELP: entities { $description "a hash table from default XML entity names (like & and <) to the characters they represent. This is automatically included when parsing any XML document." } { $see-also html-entities } ; @@ -444,6 +450,9 @@ ARTICLE: { "xml" "errors" } "XML parsing errors" { $subsection expected } { $subsection no-entity } { $subsection pre/post-content } + { $subsection unclosed-quote } + { $subsection bad-name } + { $subsection quoteless-attr } "Additionally, most of these errors delegate to " { $link parsing-error } " in order to provide more information" $nl "Note that, in parsing an XML document, only the first error is reported." ; @@ -456,7 +465,7 @@ ARTICLE: { "xml" "entities" } "XML entities" { $subsection with-html-entities } ; ARTICLE: "xml" "XML parser" -"The " { $vocab-link "xml" } " vocabulary implements the XML 1.1 standard, converting strings of text into XML and vice versa." +"The " { $vocab-link "xml" } " vocabulary implements the XML 1.0 and 1.1 standards, converting strings of text into XML and vice versa." { $subsection { "xml" "reading" } } { $subsection { "xml" "writing" } } { $subsection { "xml" "classes" } }