USING: help.markup help.syntax present multiline xml.data ; IN: xml.literals ABOUT: "xml.literals" ARTICLE: "xml.literals" "XML literals" "The " { $vocab-link "xml.literals" } " vocabulary provides a convenient syntax for generating XML documents and chunks. It defines the following parsing words:" { $subsection POSTPONE: ... XML>" } { $description "This gives syntax for literal XML documents. When evaluated, there is an XML document (" { $link xml } ") on the stack. It can be used for interpolation as well, if interpolation slots are used. For more information about XML interpolation, see " { $link { "xml.literals" "interpolation" } } "." } ; HELP: [XML { $syntax "[XML foo ... bar ... baz XML]" } { $description "This gives syntax for literal XML documents. When evaluated, there is an XML chunk (" { $link xml-chunk } ") on the stack. For more information about XML interpolation, see " { $link { "xml.literals" "interpolation" } } "." } ; ARTICLE: { "xml.literals" "interpolation" } "XML interpolation syntax" "XML interpolation has two forms for each of the words " { $link POSTPONE: " } ". To splice something in from the stack, in the style of " { $vocab-link "fry" } ", use the syntax " { $snippet "<->" } ". An XML interpolation form may only use one of these styles." $nl "These forms can be used where a tag might go, as in " { $snippet "[XML <-> XML]" } " or where an attribute might go, as in " { $snippet "[XML /> XML]" } ". When an attribute is spliced in, it is not included if the value is " { $snippet "f" } " and if the value is not a string, the value is put through " { $link present } ". Here is an example of the fry style of XML interpolation:" { $example {" USING: splitting sequences xml.writer xml.literals ; "one two three" " " split [ [XML <-> XML] ] map <-> XML> pprint-xml"} {" one two three "} } "Here is an example of the locals version:" { $example {" USING: locals urls xml.literals xml.writer ; [let | number [ 3 ] false [ f ] url [ URL" http://factorcode.org/" ] string [ "hello" ] word [ \ drop ] | false=<-false-> url=<-url-> string=<-string-> word=<-word-> /> XML> pprint-xml ] "} {" "} } ;