Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/XML-Output/Jq/xml-output.jq
Normal file
26
Task/XML-Output/Jq/xml-output.jq
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
def escapes: [
|
||||
["&" , "&"], # must do this one first
|
||||
["\"", """],
|
||||
["'" , "'"],
|
||||
["<" , "<"],
|
||||
[">" , ">"]
|
||||
];
|
||||
|
||||
def xmlEscape:
|
||||
reduce escapes[] as $esc (.; gsub($esc[0]; $esc[1]));
|
||||
|
||||
def xmlDoc(names; remarks):
|
||||
reduce range(0;names|length) as $i ("<CharacterRemarks>\n";
|
||||
(names[$i]|xmlEscape) as $name
|
||||
| (remarks[$i]|xmlEscape) as $remark
|
||||
| . + " <Character name=\"\($name)\">\($remark)</Character>\n")
|
||||
+ "</CharacterRemarks>" ;
|
||||
|
||||
def names: ["April", "Tam O'Shanter", "Emily"];
|
||||
def remarks: [
|
||||
"Bubbly: I'm > Tam and <= Emily",
|
||||
"Burns: \"When chapman billies leave the street ...\"",
|
||||
"Short & shrift"
|
||||
];
|
||||
|
||||
xmlDoc(names; remarks)
|
||||
Loading…
Add table
Add a link
Reference in a new issue