Jump to content

XML/Output: Difference between revisions

m
→‎{{header|REXX}}: added whitespace, changed comments, removed CHANGESTR subroutine, removed OVERFLOW from the PRE html tag.
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 tocreates createan HTML a list of character names & and remarks. */
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 /*ampersands & have to be treated special.*/
b=pos(';',x)\==0 /*semicolons have; " " " " " to be treated special.*/
xml0=0
/*the DOS[↓] (DOSfind undera Windows)free character codepage.···*/
 
if a then do /* ··· translate freely·*/
if a\==0 then do
ado j=10 to 254; /*below, find a?=d2c(j); free characterif topos(?,x)==0 then translateleave; freely.*/end
x=translate(x,?,"&"); do j=0 to 254; ?xml0=d2c(j); if pos(?,x)==0 then leave; end+1
x=translate(x,?,"&");xml0=j+1end
/* [↓] 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
if b\==0 then do
bx=1 /*below, find a free character to translate freely.*/(x,??,";")
end
do j=xml0 to 254; ??=d2c(j); if pos(??,x)==0 then leave; end
/*Following are a few of the */
x=translate(x,??,";")
/*characters in the DOS (or DOS */
end
/*FollowingWindows) codepage are a few437 of the chars in */
/*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 wethere hadwas an ampersand, translate it now.*/
if b then x=xml_(??,"semi") /*if we" had a " " " semicolon, translate it now. " "*/
return x</lang>
Some older REXXes don't have a '''changestr''' bif, so one is included here ──► [[CHANGESTR.REX]].
<br><br>
'''output''' &nbsp; (unrendered):
<pre>
charname 1 = April
Cookies help us deliver our services. By using our services, you agree to our use of cookies.