XML/Output: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: removed OVERFLOW from PRE html tags.) |
m (→{{header|REXX}}: added whitespace, changed comments, removed CHANGESTR subroutine, removed OVERFLOW from the PRE html tag.) |
||
Line 1,768: | Line 1,768: | ||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
REXX doesn't have any functions to handle XML entities, an abbreviated version is included here. |
REXX doesn't have any functions to handle XML entities, an abbreviated version is included here. |
||
<lang rexx>/*REXX program |
<lang rexx>/*REXX program creates an HTML list of character names and remarks. */ |
||
charname.= |
charname. = |
||
charname.1="April" |
charname.1 = "April" |
||
charname.2="Tam O'Shanter" |
charname.2 = "Tam O'Shanter" |
||
charname.3="Emily" |
charname.3 = "Emily" |
||
do i=1 while charname.i\=='' |
do i=1 while charname.i\=='' |
||
say 'charname' i '=' charname.i |
say 'charname' i '=' charname.i |
||
end /*i*/; say |
end /*i*/; say |
||
remark.= |
remark. = |
||
remark.1="I'm > Tam and <= Emily" |
remark.1 = "I'm > Tam and <= Emily" |
||
remark.2="When chapman billies leave the street ..." |
remark.2 = "When chapman billies leave the street ..." |
||
remark.3="Short & shift" |
remark.3 = "Short & shift" |
||
do k=1 while remark.k\=='' |
do k=1 while remark.k\=='' |
||
say ' remark' k '=' remark.k |
say ' remark' k '=' remark.k |
||
end /*k*/; say |
end /*k*/; say |
||
items=0 |
items = 0 |
||
header='CharacterRemarks' |
header = 'CharacterRemarks' |
||
header=header'>' |
header = header'>' |
||
do j=1 while charname.j\=='' |
do j=1 while charname.j\=='' |
||
_=charname.j |
_=charname.j |
||
if j==1 then call create '<'header |
if j==1 then call create '<'header |
||
call create ' <Character name="' ||, |
call create ' <Character name="' ||, |
||
char2xml(_)'">"' ||, |
char2xml(_)'">"' ||, |
||
Line 1,795: | Line 1,795: | ||
end /*j*/ |
end /*j*/ |
||
if create.0\==0 then call create '</'header |
if create.0\==0 then call create '</'header |
||
do m=1 for create.0 |
do m=1 for create.0 |
||
say create.m |
say create.m /*display the Mth entry to term*/ |
||
end /*m*/ |
end /*m*/ |
||
exit /*stick a fork in it, we're done.*/ |
exit /*stick a fork in it, we're done.*/ |
||
Line 1,808: | Line 1,808: | ||
/*──────────────────────────────────XML_ subroutine─────────────────────*/ |
/*──────────────────────────────────XML_ subroutine─────────────────────*/ |
||
xml_: parse arg _ /*make an XML entity (&xxxx;) */ |
xml_: parse arg _ /*make an XML entity (&xxxx;) */ |
||
if pos(_,x)\==0 then return changestr(_,x,"&"arg(2)";") |
if pos(_,x)\==0 then return changestr(_,x,"&"arg(2)";") |
||
return x |
return x |
||
/*──────────────────────────────────CHAR2XML subroutine─────────────────*/ |
/*──────────────────────────────────CHAR2XML subroutine─────────────────*/ |
||
char2xml: procedure; parse arg x |
char2xml: procedure; parse arg x |
||
a=pos('&',x)\==0 /* |
a=pos('&',x)\==0 /* & have to be treated special.*/ |
||
b=pos(';',x)\==0 /* |
b=pos(';',x)\==0 /* ; " " " " " */ |
||
xml0=0 |
xml0=0 |
||
⚫ | |||
if a then do /* ··· translate freely·*/ |
|||
if a\==0 then do |
|||
do j=0 to 254; ?=d2c(j); if pos(?,x)==0 then leave; end |
|||
x=translate(x,?,"&"); xml0=j+1 |
|||
end |
|||
/* [↓] find a free character ···*/ |
|||
⚫ | |||
if b then do /* ··· translate freely·*/ |
|||
⚫ | |||
if b\==0 then do |
|||
x=translate(x,??,";") |
|||
⚫ | |||
⚫ | |||
/*Following are a few of the */ |
|||
x=translate(x,??,";") |
|||
/*characters in the DOS (or DOS */ |
|||
end |
|||
/* |
/*Windows) codepage 437 */ |
||
⚫ | |||
x=XML_('♥',"hearts") ; x=XML_('â',"ETH") ; x=XML_('ƒ',"fnof") ; x=XML_('═',"boxH") |
x=XML_('♥',"hearts") ; x=XML_('â',"ETH") ; x=XML_('ƒ',"fnof") ; x=XML_('═',"boxH") |
||
x=XML_('♦',"diams") ; x=XML_('â','#x00e2') ; x=XML_('á',"aacute"); x=XML_('╬',"boxVH") |
x=XML_('♦',"diams") ; x=XML_('â','#x00e2') ; x=XML_('á',"aacute"); x=XML_('╬',"boxVH") |
||
Line 1,883: | Line 1,881: | ||
x=XML_('â',"acirc") ; x=XML_('¥',"yen") ; x=XML_('╠',"boxVR") ; x=XML_('■',"squart ") |
x=XML_('â',"acirc") ; x=XML_('¥',"yen") ; x=XML_('╠',"boxVR") ; x=XML_('■',"squart ") |
||
if a then x=xml_(?,"amp") /*if |
if a then x=xml_(?,"amp") /*if there was an ampersand, translate it*/ |
||
if b then x=xml_(??,"semi") /* |
if b then x=xml_(??,"semi") /* " " " " semicolon, " "*/ |
||
return x</lang> |
return x</lang> |
||
Some older REXXes don't have a '''changestr''' bif, so one is included here ──► [[CHANGESTR.REX]]. |
Some older REXXes don't have a '''changestr''' bif, so one is included here ──► [[CHANGESTR.REX]]. |
||
<br><br> |
<br><br> |
||
'''output''' |
'''output''' (unrendered): |
||
<pre> |
<pre> |
||
charname 1 = April |
charname 1 = April |