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