How to resolve the algorithm XML/Output step by step in the Bracmat programming language
How to resolve the algorithm XML/Output step by step in the Bracmat programming language
Table of Contents
Problem Statement
Create a function that takes a list of character names and a list of corresponding remarks and returns an XML document of
Let's start with the solution:
Step by Step solution about How to resolve the algorithm XML/Output step by step in the Bracmat programming language
Source code in the bracmat programming language
( ( 2XML
= PCDATAentities attributeValueEntities doAll doAttributes
, xml
. ( attributeValueEntities
= a c
. @( !arg
: ?a
(("<"|"&"|\"):?c)
?arg
)
& !a
"&"
( !c:"<"<
| !c:"&"&
| quot
)
";"
attributeValueEntities$!arg
| !arg
)
& ( PCDATAentities
= a c
. @( !arg
: ?a
(("<"|"&"|">"):?c)
?arg
)
& !a
"&"
( !c:"<"<
| !c:"&"&
| gt
)
";"
PCDATAentities$!arg
| !arg
)
& ( doAttributes
= a v
. !arg:(?a.?v) ?arg
& " "
PCDATAentities$!a
"=\""
attributeValueEntities$!v
\"
doAttributes$!arg
|
)
& ( doAll
= xml first A B C att XML
. !arg:?xml
& :?XML
& whl
' ( !xml:%?first ?xml
& ( !first:(?A.?B)
& ( !B:(?att,?C)
& !XML
( !C:
& "<" !A doAttributes$!att " />\n"
| "<"
!A
doAttributes$!att
">"
doAll$!C
""
!A
">\n"
)
: ?XML
| !A
: ( "!"&!XML "":?XML
| "!--"
& !XML "":?XML
| "?"&!XML "" !B "?>\n":?XML
| "![CDATA["
& !XML "":?XML
| "!DOCTYPE"
& !XML "":?XML
| ?
& !XML "<" !A doAttributes$!B ">":?XML
)
)
| !XML PCDATAentities$!first:?XML
)
)
& str$!XML
)
& doAll$!arg
)
& ( makeList
= characters name names remark remarks
. !arg:(?names.?remarks)
& :?characters
& whl
' ( (!names.!remarks)
: (%?name ?names.%?remark ?remarks)
& !characters (Character.(name.!name),!remark)
: ?characters
)
& ("?".xml) (CharacterRemarks.,!characters)
)
& put
$ ( 2XML
$ ( makeList
$ ( April "Tam O'Shanter" Emily
. "Bubbly: I'm > Tam and <= Emily"
"Burns: \"When chapman billies leave the street ...\""
"Short & shrift"
)
)
)
)
You may also check:How to resolve the algorithm Y combinator step by step in the Nim programming language
You may also check:How to resolve the algorithm Dynamic variable names step by step in the Smalltalk programming language
You may also check:How to resolve the algorithm Logical operations step by step in the MUMPS programming language
You may also check:How to resolve the algorithm String prepend step by step in the Tcl programming language
You may also check:How to resolve the algorithm Text processing/1 step by step in the C++ programming language