]> gitweb.factorcode.org Git - factor.git/blob - basis/xml/writer/writer-docs.factor
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / basis / xml / writer / writer-docs.factor
1 ! Copyright (C) 2005, 2009 Daniel Ehrenberg
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: help.syntax help.markup io strings xml.data multiline ;
4 IN: xml.writer
5
6 ABOUT: "xml.writer"
7
8 ARTICLE: "xml.writer" "Writing XML"
9     "These words are used to print XML preserving whitespace in text nodes"
10     { $subsection write-xml }
11     { $subsection xml>string }
12     "These words are used to prettyprint XML"
13     { $subsection pprint-xml>string }
14     { $subsection pprint-xml }
15     "Certain variables can be changed to mainpulate prettyprinting"
16     { $subsection sensitive-tags }
17     { $subsection indenter }
18     "All of these words operate on arbitrary pieces of XML: they can take, as in put, XML documents, comments, tags, strings (text nodes), XML chunks, etc." ;
19
20 HELP: xml>string
21 { $values { "xml" "an XML document" } { "string" "a string" } }
22 { $description "This converts an XML document " { $link xml } " into a string. It can also be used to convert any piece of XML to a string, eg an " { $link xml-chunk } " or " { $link comment } "." }
23 { $notes "This does not preserve what type of quotes were used or what data was omitted from version declaration, as that information isn't present in the XML data representation. The whitespace in the text nodes of the original document is preserved." } ;
24
25 HELP: pprint-xml>string
26 { $values { "xml" "an XML document" } { "string" "a string" } }
27 { $description "converts an XML document into a string in a prettyprinted form." }
28 { $notes "This does not preserve what type of quotes were used or what data was omitted from version declaration, as that information isn't present in the XML data representation. The whitespace in the text nodes of the original document is preserved." } ;
29
30 HELP: write-xml
31 { $values { "xml" "an XML document" } }
32 { $description "prints the contents of an XML document to " { $link output-stream } "." }
33 { $notes "This does not preserve what type of quotes were used or what data was omitted from version declaration, as that information isn't present in the XML data representation. The whitespace in the text nodes of the original document is preserved." } ;
34
35 HELP: pprint-xml
36 { $values { "xml" "an XML document" } }
37 { $description "prints the contents of an XML document to " { $link output-stream } " in a prettyprinted form." }
38 { $notes "This does not preserve what type of quotes were used or what data was omitted from version declaration, as that information isn't present in the XML data representation. Whitespace is also not preserved." } ;
39
40 { xml>string write-xml pprint-xml pprint-xml>string } related-words
41
42 HELP: indenter
43 { $var-description "Contains the string which is used for indenting in the XML prettyprinter. For example, to print an XML document using " { $snippet "%%%%" } " for indentation, you can use the following:" }
44 { $example """USING: xml.syntax xml.writer namespaces ;
45 [XML <foo>bar</foo> XML] "%%%%" indenter [ pprint-xml ] with-variable """ """
46 <foo>
47 %%%%bar
48 </foo>""" } ;
49
50 HELP: sensitive-tags
51 { $var-description "Contains a sequence of " { $link name } "s where whitespace should be considered significant for prettyprinting purposes. The sequence can contain " { $link string } "s in place of names. For example, to preserve whitespace inside a " { $snippet "pre" } " tag:" }
52 { $example """USING: xml.syntax xml.writer namespaces ;
53 [XML <html> <head>   <title> something</title></head><body><pre>bing
54 bang
55    bong</pre></body></html> XML] { "pre" } sensitive-tags [ pprint-xml ] with-variable "} {"
56 <html>
57   <head>
58     <title>
59       something
60     </title>
61   </head>
62   <body>
63     <pre>bing
64 bang
65    bong</pre>
66   </body>
67 </html>""" } ;