diff --git a/basis/xml/autoencoding/summary.txt b/basis/xml/autoencoding/summary.txt new file mode 100644 index 0000000000..c7517b13d9 --- /dev/null +++ b/basis/xml/autoencoding/summary.txt @@ -0,0 +1 @@ +Implements the automatic detection of encodings of XML documents diff --git a/basis/xml/backend/backend.factor b/basis/xml/backend/backend.factor deleted file mode 100644 index 5dee38695d..0000000000 --- a/basis/xml/backend/backend.factor +++ /dev/null @@ -1,6 +0,0 @@ -! Copyright (C) 2008 Daniel Ehrenberg -! See http://factorcode.org/license.txt for BSD license. -IN: xml.backend - -! A stack of { tag children } pairs -SYMBOL: xml-stack diff --git a/basis/xml/char-classes/summary.txt b/basis/xml/char-classes/summary.txt new file mode 100644 index 0000000000..8f70bddc94 --- /dev/null +++ b/basis/xml/char-classes/summary.txt @@ -0,0 +1 @@ +XML-related character classes diff --git a/basis/xml/data/data.factor b/basis/xml/data/data.factor index 68e91743d3..8c024d938e 100644 --- a/basis/xml/data/data.factor +++ b/basis/xml/data/data.factor @@ -1,11 +1,16 @@ -! Copyright (C) 2005, 2006 Daniel Ehrenberg +! Copyright (C) 2005, 2009 Daniel Ehrenberg ! See http://factorcode.org/license.txt for BSD license. USING: kernel sequences sequences.private assocs arrays delegate.protocols delegate vectors accessors multiline -macros words quotations combinators slots fry ; +macros words quotations combinators slots fry strings ; IN: xml.data -TUPLE: name space main url ; +UNION: nullable-string string POSTPONE: f ; + +TUPLE: name + { space nullable-string } + { main string } + { url nullable-string } ; C: <name> name : ?= ( object/f object/f -- ? ) @@ -25,48 +30,7 @@ C: <name> name : assure-name ( string/name -- name ) dup name? [ <null-name> ] unless ; -TUPLE: opener name attrs ; -C: <opener> opener - -TUPLE: closer name ; -C: <closer> closer - -TUPLE: contained name attrs ; -C: <contained> contained - -TUPLE: comment text ; -C: <comment> comment - -TUPLE: directive ; - -TUPLE: element-decl < directive name content-spec ; -C: <element-decl> element-decl - -TUPLE: attlist-decl < directive name att-defs ; -C: <attlist-decl> attlist-decl - -TUPLE: entity-decl < directive name def pe? ; -C: <entity-decl> entity-decl - -TUPLE: system-id system-literal ; -C: <system-id> system-id - -TUPLE: public-id pubid-literal system-literal ; -C: <public-id> public-id - -TUPLE: doctype-decl < directive name external-id internal-subset ; -C: <doctype-decl> doctype-decl - -TUPLE: notation-decl < directive name id ; -C: <notation-decl> notation-decl - -TUPLE: instruction text ; -C: <instruction> instruction - -TUPLE: prolog version encoding standalone ; -C: <prolog> prolog - -TUPLE: attrs alist ; +TUPLE: attrs { alist sequence } ; C: <attrs> attrs : attr@ ( key alist -- index {key,value} ) @@ -105,7 +69,66 @@ M: attrs clone INSTANCE: attrs assoc -TUPLE: tag name attrs children ; +TUPLE: opener { name name } { attrs attrs } ; +C: <opener> opener + +TUPLE: closer { name name } ; +C: <closer> closer + +TUPLE: contained { name name } { attrs attrs } ; +C: <contained> contained + +TUPLE: comment { text string } ; +C: <comment> comment + +TUPLE: directive ; + +TUPLE: element-decl < directive + { name string } { content-spec string } ; +C: <element-decl> element-decl + +TUPLE: attlist-decl < directive + { name string } { att-defs string } ; +C: <attlist-decl> attlist-decl + +UNION: boolean t POSTPONE: f ; + +TUPLE: entity-decl < directive + { name string } + { def string } + { pe? boolean } ; +C: <entity-decl> entity-decl + +TUPLE: system-id { system-literal string } ; +C: <system-id> system-id + +TUPLE: public-id { pubid-literal string } { system-literal string } ; +C: <public-id> public-id + +UNION: id system-id public-id POSTPONE: f ; + +TUPLE: doctype-decl < directive + { name string } + { external-id id } + { internal-subset sequence } ; +C: <doctype-decl> doctype-decl + +TUPLE: notation-decl < directive name id ; +C: <notation-decl> notation-decl + +TUPLE: instruction { text string } ; +C: <instruction> instruction + +TUPLE: prolog + { version string } + { encoding string } + { standalone boolean } ; +C: <prolog> prolog + +TUPLE: tag + { name name } + { attrs attrs } + { children sequence } ; : <tag> ( name attrs children -- tag ) [ assure-name ] [ T{ attrs } assoc-like ] [ ] tri* @@ -137,7 +160,11 @@ MACRO: clone-slots ( class -- tuple ) M: tag clone tag clone-slots ; -TUPLE: xml prolog before body after ; +TUPLE: xml + { prolog prolog } + { before sequence } + { body tag } + { after sequence } ; C: <xml> xml CONSULT: sequence-protocol xml body>> ; diff --git a/basis/xml/data/summary.txt b/basis/xml/data/summary.txt new file mode 100644 index 0000000000..d8f0f0dc0a --- /dev/null +++ b/basis/xml/data/summary.txt @@ -0,0 +1 @@ +Contains XML data types and basic tools for manipulation diff --git a/basis/xml/dtd/summary.txt b/basis/xml/dtd/summary.txt new file mode 100644 index 0000000000..8b0745fcf4 --- /dev/null +++ b/basis/xml/dtd/summary.txt @@ -0,0 +1 @@ +Implements the parsing of directives in DTDs diff --git a/basis/xml/elements/summary.txt b/basis/xml/elements/summary.txt new file mode 100644 index 0000000000..c85b023211 --- /dev/null +++ b/basis/xml/elements/summary.txt @@ -0,0 +1 @@ +Implements the parsing of XML tags diff --git a/basis/xml/entities/summary.txt b/basis/xml/entities/summary.txt new file mode 100644 index 0000000000..4ff3e75e6c --- /dev/null +++ b/basis/xml/entities/summary.txt @@ -0,0 +1 @@ +Contains built-in XML entities diff --git a/basis/xml/errors/errors.factor b/basis/xml/errors/errors.factor index ea6eb51415..fe152e84c3 100644 --- a/basis/xml/errors/errors.factor +++ b/basis/xml/errors/errors.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: xml.data xml.writer kernel generic io prettyprint math debugger sequences xml.state accessors summary -namespaces io.streams.string xml.backend xml.writer.private ; +namespaces io.streams.string ; IN: xml.errors TUPLE: parsing-error line column ; diff --git a/basis/xml/errors/summary.txt b/basis/xml/errors/summary.txt new file mode 100644 index 0000000000..6bab35293b --- /dev/null +++ b/basis/xml/errors/summary.txt @@ -0,0 +1 @@ +XML parsing errors diff --git a/basis/xml/name/authors.txt b/basis/xml/name/authors.txt new file mode 100644 index 0000000000..f990dd0ed2 --- /dev/null +++ b/basis/xml/name/authors.txt @@ -0,0 +1 @@ +Daniel Ehrenberg diff --git a/basis/xml/name/summary.txt b/basis/xml/name/summary.txt new file mode 100644 index 0000000000..4a75904ec3 --- /dev/null +++ b/basis/xml/name/summary.txt @@ -0,0 +1 @@ +Implements parsing XML names diff --git a/basis/xml/state/state.factor b/basis/xml/state/state.factor index 80fb6be982..b00d723a1a 100644 --- a/basis/xml/state/state.factor +++ b/basis/xml/state/state.factor @@ -17,3 +17,9 @@ C: <spot> spot : set-next ( char -- ) spot get swap >>next drop ; : get-check ( -- ? ) spot get check>> ; : check ( -- ) spot get t >>check drop ; + +SYMBOL: xml-stack + +SYMBOL: prolog-data + +SYMBOL: depth diff --git a/basis/xml/state/summary.txt b/basis/xml/state/summary.txt new file mode 100644 index 0000000000..cfdd7228af --- /dev/null +++ b/basis/xml/state/summary.txt @@ -0,0 +1 @@ +Primitive device for storing the state of the XML parser diff --git a/basis/xml/tests/templating.factor b/basis/xml/tests/templating.factor index f0af650e4f..b35d7372e3 100644 --- a/basis/xml/tests/templating.factor +++ b/basis/xml/tests/templating.factor @@ -1,5 +1,5 @@ -USING: kernel xml sequences assocs tools.test io arrays namespaces -accessors xml.data xml.utilities xml.writer generic sequences.deep ; +USING: kernel xml sequences assocs tools.test io arrays namespaces fry +accessors xml.data xml.utilities xml.writer generic sequences.deep multiline ; IN: xml.tests : sub-tag @@ -20,24 +20,39 @@ M: object (r-ref) drop ; ! Example -: sample-doc ( -- string ) - { - "<html xmlns:f='http://littledan.onigirihouse.com/namespaces/replace'>" - "<body>" - "<span f:sub='foo'/>" - "<div f:sub='bar'/>" - "<p f:sub='baz'>paragraph</p>" - "</body></html>" - } concat ; +STRING: sample-doc +<html xmlns:f='http://littledan.onigirihouse.com/namespaces/replace'> +<body> +<span f:sub='foo'/> +<div f:sub='bar'/> +<p f:sub='baz'>paragraph</p> +</body></html> +; + +STRING: expected-result +<?xml version="1.0" encoding="UTF-8"?> +<html xmlns:f="http://littledan.onigirihouse.com/namespaces/replace"> + <body> + <span f:sub="foo"> + foo + </span> + <div f:sub="bar"> + blah + <a/> + </div> + <p f:sub="baz"/> + </body> +</html> +; : test-refs ( -- string ) [ H{ { "foo" { "foo" } } - { "bar" { "blah" T{ tag f T{ name f "" "a" "" } f f } } } + { "bar" { "blah" T{ tag f T{ name f "" "a" "" } T{ attrs } f } } } { "baz" f } } ref-table set - sample-doc string>xml dup template xml>string + sample-doc string>xml dup template pprint-xml>string ] with-scope ; -[ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><html xmlns:f=\"http://littledan.onigirihouse.com/namespaces/replace\"><body><span f:sub=\"foo\">foo</span><div f:sub=\"bar\">blah<a/></div><p f:sub=\"baz\"/></body></html>" ] [ test-refs ] unit-test +expected-result '[ _ ] [ test-refs ] unit-test diff --git a/basis/xml/tokenize/summary.txt b/basis/xml/tokenize/summary.txt new file mode 100644 index 0000000000..cc5361aaae --- /dev/null +++ b/basis/xml/tokenize/summary.txt @@ -0,0 +1 @@ +Basic tools for parsing XML diff --git a/basis/xml/tokenize/tokenize.factor b/basis/xml/tokenize/tokenize.factor index 7a26385332..943f4e7a15 100644 --- a/basis/xml/tokenize/tokenize.factor +++ b/basis/xml/tokenize/tokenize.factor @@ -6,10 +6,6 @@ circular xml.entities assocs make splitting math.parser locals combinators arrays ; IN: xml.tokenize -SYMBOL: prolog-data - -SYMBOL: depth - : version=1.0? ( -- ? ) prolog-data get [ version>> "1.0" = ] [ t ] if* ; diff --git a/basis/xml/utilities/summary.txt b/basis/xml/utilities/summary.txt new file mode 100644 index 0000000000..a671132945 --- /dev/null +++ b/basis/xml/utilities/summary.txt @@ -0,0 +1 @@ +Utilities for manipulating an XML DOM tree diff --git a/basis/xml/writer/summary.txt b/basis/xml/writer/summary.txt new file mode 100644 index 0000000000..04d0471969 --- /dev/null +++ b/basis/xml/writer/summary.txt @@ -0,0 +1 @@ +Tools for printing XML, including prettyprinting diff --git a/basis/xml/xml.factor b/basis/xml/xml.factor index 29b647eb78..4dd872156e 100644 --- a/basis/xml/xml.factor +++ b/basis/xml/xml.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays io io.encodings.binary io.files io.streams.string kernel namespaces sequences strings io.encodings.utf8 -xml.backend xml.data xml.errors xml.elements ascii xml.entities +xml.data xml.errors xml.elements ascii xml.entities xml.writer xml.state xml.autoencoding assocs xml.tokenize xml.name ; IN: xml