1 ! Copyright (C) 2005, 2009 Daniel Ehrenberg
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: help.markup help.syntax ;
8 : $xml-error ( element -- )
9 "Bad XML document for the error" $heading $code ;
14 { $class-description "XML parsing error describing the case where there is more than one main tag in a document." }
15 { $xml-error "<a/>\n<b/>" } ;
18 { $class-description "XML parsing error describing the case where an XML document contains no main tag, or any tags at all" }
19 { $xml-error "<?xml version='1.0'?>" } ;
22 { $class-description "XML parsing error describing the case where the XML prolog (" { $snippet "<?xml ...?>" } ") contains attributes other than the three allowed ones, " { $snippet "standalone" } ", " { $snippet "version" } " and " { $snippet "encoding" } ". Contains one slot, " { $snippet "attrs" } ", which is a hashtable of all the extra attributes' names. This is a subclass of " { $link xml-error-at } "." }
23 { $xml-error "<?xml version='1.0' reason='because I said so'?>\n<foo/>" } ;
26 { $class-description "XML parsing error describing the case where a namespace doesn't exist but it is used in a tag. Contains one slot, " { $snippet "name" } ", which contains the name of the undeclared namespace, and is a subclass of " { $link xml-error-at } "." }
27 { $xml-error "<a:b>c</a:b>" } ;
30 { $class-description "XML parsing error used to describe the case where standalone is set in the XML prolog to something other than " { $snippet "yes" } " or " { $snippet "no" } ". This is a subclass of " { $link xml-error-at } " and contains one slot, text, which contains offending value." }
31 { $xml-error "<?xml version='1.0' standalone='maybe'?>\n<x/>" } ;
34 { $class-description "XML parsing error used to describe the case where the XML document contains classes which are not closed by the end of the document. Contains one slot, " { $snippet "tags" } ", a sequence of names." }
35 { $xml-error "<x>some text" } ;
38 { $class-description "XML parsing error describing mismatched tags. Contains two slots: " { $snippet "open" } " is the name of the opening tag and " { $snippet "close" } " is the name of the closing tag. This is a subclass of " { $link xml-error-at } " showing the location of the closing tag" }
39 { $xml-error "<a></c>" } ;
42 { $class-description "XML parsing error describing when an expected token was not present. Delegates to " { $link xml-error-at } ". Contains two slots, " { $snippet "should-be" } ", which has the expected string, and " { $snippet "was" } ", which has the actual string." } ;
45 { $class-description "XML parsing error describing the use of an undefined entity. This is a subclass of " { $link xml-error-at } ". Contains one slot, thing, containing a string representing the entity." }
46 { $xml-error "<x>&foo;</x>" } ;
49 HELP: pre/post-content
50 { $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: " { $snippet "string" } " contains the offending string, and " { $snippet "pre?" } " is " { $snippet "t" } " if it occured before the main tag and " { $snippet "f" } " if it occured after." }
51 { $xml-error "hello\n<main-tag/>" } ;
54 { $class-description "Describes the error where a name is used, for example in an XML tag or attribute key, which is invalid." }
55 { $xml-error "<%>\n</%>" } ;
58 { $class-description "Describes the error where an attribute of an XML tag is missing quotes around a value." }
59 { $xml-error "<tag foo=bar/>" } ;
62 { $class-description "Describes the error where a disallowed character occurs in an XML document." } ;
65 { $class-description "Describes the error where a particular closing token is missing." } ;
68 { $class-description "Describes the error where a document unexpectedly ends, and the XML parser expected it to continue." } ;
71 { $class-description "Describes the error where there is more than one attribute of the same key." }
72 { $xml-error "<tag value='1' value='2'/>" } ;
75 { $class-description "Describes the error where CDATA is used outside of the main tag of an XML document." }
76 { $xml-error "<x>y</x>\n<![CDATA[]]>" } ;
79 { $class-description "Describes the error where a text node contains the literal string " { $snippet "]]>" } " which is disallowed." }
80 { $xml-error "<x>Here's some text: ]]> there it was</x>" } ;
83 { $class-description "Describes the error where an attribute value contains the literal character " { $snippet "<" } " which is disallowed." }
84 { $xml-error "<x value='bar<baz'/>" } ;
86 HELP: misplaced-directive
87 { $class-description "Describes the error where an internal DTD directive is used outside of a DOCTYPE or DTD file, or where a DOCTYPE occurs somewhere other than before the main tag of an XML document." }
88 { $xml-error "<x><!ENTITY foo 'bar'></x>" } ;
91 { $class-description "The exception class that all parsing errors in XML documents are in." } ;
93 ARTICLE: "xml.errors" "XML parsing errors"
94 "The " { $vocab-link "xml.errors" } " vocabulary provides a rich and highly inspectable set of parsing errors. All XML errors are described by the union class " { $link xml-error } "."
95 { $subsection multitags }
96 { $subsection notags }
97 { $subsection extra-attrs }
98 { $subsection nonexist-ns }
99 { $subsection not-yes/no }
100 { $subsection unclosed }
101 { $subsection mismatched }
102 { $subsection expected }
103 { $subsection no-entity }
104 { $subsection pre/post-content }
105 { $subsection unclosed-quote }
106 { $subsection bad-name }
107 { $subsection quoteless-attr }
108 { $subsection disallowed-char }
109 { $subsection missing-close }
110 { $subsection unexpected-end }
111 { $subsection duplicate-attr }
112 { $subsection bad-cdata }
113 { $subsection text-w/]]> }
114 { $subsection attr-w/< }
115 { $subsection misplaced-directive }
116 "Additionally, most of these errors are a kind of " { $link xml-error-at } " which provides more information about where the error occurred."
118 "Note that, in parsing an XML document, only the first error is reported." ;