"The " { $link "xml.syntax" } " vocabulary defines a number of new parsing words forXML processing."
{ $subsection { "xml.syntax""tags" } }
{ $subsection { "xml.syntax""literals" } }
{ $subsection POSTPONE:XML-NS: } ;
ARTICLE: { "xml.syntax""tags" } "Dispatch on XML tag names"
"There is a system, analogous to generic words, for processing XML. A word can dispatch off the name of the tag that is passed to it. To define such a word, use"
{ $subsection POSTPONE:TAGS: }
"and to define a new 'method' for this word, use"
{ $subsection POSTPONE:TAG: } ;
HELP:TAGS:
{ $syntax "TAGS: word" }
{ $values { "word""a new word to define" } }
{ $description "Creates a new word to which dispatches on XML tag names." }
{ $see-also POSTPONE:TAG: } ;
HELP:TAG:
{ $syntax "TAG: tag word definition... ;" }
{ $values { "tag""an XML tag name" } { "word""an XML process" } }
{ $description "Defines a 'method' on a word created with " { $link POSTPONE:TAGS: } ". It determines what such a word should do for an argument that is has the given name." }
{ $examples { $code "TAGS: x ( tag -- )\nTAG: a x drop \"hi\" write ;" } }
{ $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.syntax""interpolation" } } "." } ;
{ $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.syntax""interpolation" } } "." } ;
"XML interpolation has two forms for each of the words " { $link POSTPONE:<XML } " and " { $link POSTPONE:[XML } ": a fry-like form and a locals form. To splice locals in, use the syntax " { $snippet "<-variable->" } ". 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 <foo><-></foo> XML]" } " or where an attribute might go, as in " { $snippet "[XML <foo bar=<->/> 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:"
{ $description "Defines a new word of the given name which constructs XML names in the namespace of the given URL. The names constructed are memoized." } ;