XML/Output: Difference between revisions

m
→‎{{header|REXX}}: removed superflous blanks. -- ~~~~
m (→‎{{header|REXX}}: removed superflous blanks. -- ~~~~)
Line 1,433:
=={{header|REXX}}==
REXX doesn't have any functions to handle XML entities, an abbreviated version is included here.
<lang rexx>/*REXX program to create a list of character names & remarks. */
<lang rexx>
charname.=''
/*REXX program to create a list of character names & remarks. */
 
charname.=''
charname.1="April"
charname.2="Tam O'Shanter"
charname.3="Emily"
 
do j=1 while charname.j\==''
say 'charname' j '=' charname.j
end
 
say
remark.=''
 
remark.=''
remark.1="I'm > Tam and <= Emily"
remark.2="When chapman billies leave the street ..."
remark.3="Short & shift"
 
do j=1 while remark.j\==''
say ' remark' j '=' remark.j
end
 
say
 
items=0
header='CharacterRemarks'
Line 1,473 ⟶ 1,467:
if create.0\==0 then call create '</'header
 
do k=1 for create.0
say create.k
end
 
exit
 
/*─────────────────────────────────────CREATE subroutine────────────────*/
create: items=items+1 /*bump the count of items in list*/
Line 1,484 ⟶ 1,476:
create.0=items /*indicate how many items in list*/
return
 
/*─────────────────────────────────────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
Line 1,507 ⟶ 1,497:
x=translate(x,??,";")
end
 
/*Following are a few of the chars in */
/*the DOS (DOS under Windows) codepage.*/
 
x=xml_('♥',"hearts")
x=xml_('♦',"diams")
Line 1,658 ⟶ 1,646:
if a then x=xml_(?,"amp") /*if we had an ampersand, translate it now.*/
if b then x=xml_(??,"semi") /*if we had a semicolon, translate it now.*/
return x</lang>
'''output'''
</lang>
Output:
<pre style="height:33ex;overflow:scroll">
charname 1 = April