Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,46 @@
# returns a translation of str suitable for attribute values and content in an XML document #
OP TOXMLSTRING = ( STRING str )STRING:
BEGIN
STRING result := "";
FOR pos FROM LWB str TO UPB str DO
CHAR c = str[ pos ];
result +:= IF c = "<" THEN "&lt;"
ELIF c = ">" THEN "&gt;"
ELIF c = "&" THEN "&amp;"
ELIF c = "'" THEN "&apos;"
ELIF c = """" THEN "&quot;"
ELSE c
FI
OD;
result
END; # TOXMLSTRING #
# generate a CharacterRemarks XML document from the characters and remarks #
# the number of elements in characters and remrks must be equal - this is not checked #
# the <?xml?> element is not generated #
PROC generate character remarks document = ( []STRING characters, remarks )STRING:
BEGIN
STRING result := "<CharacterRemarks>";
INT remark pos := LWB remarks;
FOR char pos FROM LWB characters TO UPB characters DO
result +:= "<Character name=""" + TOXMLSTRING characters[ char pos ] + """>"
+ TOXMLSTRING remarks[ remark pos ]
+ "</Character>"
+ REPR 10
;
remark pos +:= 1
OD;
result +:= "</CharacterRemarks>";
result
END; # generate character remarks document #
# test the generation #
print( ( generate character remarks document( ( "April", "Tam O'Shanter", "Emily" )
, ( "Bubbly: I'm > Tam and <= Emily"
, "Burns: ""When chapman billies leave the street ..."
, "Short & shrift"
)
)
, newline
)
)

View file

@ -0,0 +1,4 @@
<CharacterRemarks><Character name="April">Bubbly: I&apos;m &gt; Tam and &lt;= Emily</Character>
<Character name="Tam O&apos;Shanter">Burns: &quot;When chapman billies leave the street ...</Character>
<Character name="Emily">Short &amp; shrift</Character>
</CharacterRemarks>