Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
36
Task/XML-Output/Lasso/xml-output-1.lasso
Normal file
36
Task/XML-Output/Lasso/xml-output-1.lasso
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
define character2xml(names::array, remarks::array) => {
|
||||
|
||||
fail_if(#names -> size != #remarks -> size, -1, 'Input arrays not of same size')
|
||||
|
||||
local(
|
||||
domimpl = xml_domimplementation,
|
||||
doctype = #domimpl -> createdocumenttype(
|
||||
'svg:svg',
|
||||
'-//W3C//DTD SVG 1.1//EN',
|
||||
'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'
|
||||
),
|
||||
character_xml = #domimpl -> createdocument(
|
||||
'http://www.w3.org/2000/svg',
|
||||
'svg:svg',
|
||||
#docType
|
||||
),
|
||||
csnode = #character_xml -> createelement('CharacterRemarks'),
|
||||
charnode
|
||||
)
|
||||
|
||||
#character_xml -> appendChild(#csnode)
|
||||
|
||||
loop(#names -> size) => {
|
||||
#charnode = #character_xml -> createelement('Character')
|
||||
#charnode -> setAttribute('name', #names -> get(loop_count))
|
||||
#charnode -> nodeValue = encode_xml(#remarks -> get(loop_count))
|
||||
#csnode -> appendChild(#charnode)
|
||||
}
|
||||
return #character_xml
|
||||
|
||||
}
|
||||
|
||||
character2xml(
|
||||
array(`April`, `Tam O'Shanter`, `Emily`),
|
||||
array(`Bubbly: I'm > Tam and <= Emily`, `Burns: "When chapman billies leave the street ..."`, `Short & shrift`)
|
||||
)
|
||||
8
Task/XML-Output/Lasso/xml-output-2.lasso
Normal file
8
Task/XML-Output/Lasso/xml-output-2.lasso
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE svg:svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:svg="http://www.w3.org/2000/svg"/>
|
||||
<CharacterRemarks>
|
||||
<Character name="April">Bubbly: I'm > Tam and <= Emily</Character>
|
||||
<Character name="Tam O'Shanter">Burns: "When chapman billies leave the street ..."</Character>
|
||||
<Character name="Emily">Short & shrift</Character>
|
||||
</CharacterRemarks>
|
||||
|
After Width: | Height: | Size: 456 B |
11
Task/XML-Output/Nim/xml-output.nim
Normal file
11
Task/XML-Output/Nim/xml-output.nim
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import xmltree, strtabs, sequtils
|
||||
|
||||
proc charsToXML(names, remarks): XmlNode =
|
||||
result = <>CharacterRemarks()
|
||||
for name, remark in items zip(names, remarks):
|
||||
result.add(<>Character(name=name, remark.newText))
|
||||
|
||||
echo charsToXML(@["April", "Tam O'Shanter", "Emily"],
|
||||
@["Bubbly: I'm > Tam and <= Emily",
|
||||
"Burns: \"When chapman billies leave the street ...\"",
|
||||
"Short & shrift"])
|
||||
33
Task/XML-Output/Phix/xml-output.phix
Normal file
33
Task/XML-Output/Phix/xml-output.phix
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
constant {hchars,hsubs} = columnize({{"<","<"},
|
||||
{">",">"},
|
||||
{"&","&"},
|
||||
{"\"","""},
|
||||
{"\'","'"}})
|
||||
function xmlquote_all(sequence s)
|
||||
for i=1 to length(s) do
|
||||
s[i] = substitute_all(s[i],hchars,hsubs)
|
||||
end for
|
||||
return s
|
||||
end function
|
||||
|
||||
function xml_CharacterRemarks(sequence data)
|
||||
string res = "<CharacterRemarks>\n"
|
||||
for i=1 to length(data) do
|
||||
res &= sprintf(" <CharacterName=\"%s\">%s</Character>\n",xmlquote_all(data[i]))
|
||||
end for
|
||||
return res & "</CharacterRemarks>\n"
|
||||
end function
|
||||
|
||||
constant testset = {
|
||||
{"April", "Bubbly: I'm > Tam and <= Emily"},
|
||||
{"Tam O'Shanter", "Burns: \"When chapman billies leave the street ...\""},
|
||||
{"Emily", "Short & shrift"}
|
||||
}
|
||||
printf(1,xml_CharacterRemarks(testset))
|
||||
|
||||
-- Sample output:
|
||||
-- <CharacterRemarks>
|
||||
-- <CharacterName="April">Bubbly: I'm &gt; Tam and &lt;= Emily</Character>
|
||||
-- <CharacterName="Tam O'Shanter">Burns: "When chapman billies leave the street ..."</Character>
|
||||
-- <CharacterName="Emily">Short & shrift</Character>
|
||||
-- </CharacterRemarks>
|
||||
19
Task/XML-Output/Sidef/xml-output.sidef
Normal file
19
Task/XML-Output/Sidef/xml-output.sidef
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
require('XML::Mini::Document');
|
||||
|
||||
var students = [
|
||||
["April", "Bubbly: I'm > Tam and <= Emily"],
|
||||
["Tam O'Shanter", "Burns: \"When chapman billies leave the street ...\""],
|
||||
["Emily", "Short & shrift"]
|
||||
];
|
||||
|
||||
var doc = %s'XML::Mini::Document'.new;
|
||||
var root = doc.getRoot;
|
||||
var studs = root.createChild("CharacterRemarks");
|
||||
|
||||
students.each { |s|
|
||||
var stud = studs.createChild("Character");
|
||||
stud.attribute("name", s[0]);
|
||||
stud.text(s[1]);
|
||||
};
|
||||
|
||||
print doc.toString;
|
||||
Loading…
Add table
Add a link
Reference in a new issue