XML/Output: Difference between revisions

Content added Content deleted
(→‎{{header|PicoLisp}}: Fix typo in lib-import line)
m ({{out}})
Line 1: Line 1:
{{task|XML}}
{{task|XML}}
Create a function that takes a list of character names and a list of corresponding remarks and returns an XML document of <code><Character></code> elements each with a name attributes and each enclosing its remarks. All <code><Character></code> elements are to be enclosed in turn, in an outer <code><CharacterRemarks></code> element.
Create a function that takes a list of character names and a list of corresponding remarks and returns an XML document of <code><Character></code> elements each with a name attributes and each enclosing its remarks.
All <code><Character></code> elements are to be enclosed in turn, in an outer <code><CharacterRemarks></code> element.


As an example, calling the function with the three names of:
As an example, calling the function with the three names of:
Line 24: Line 25:
Note too that although the task is written to take two lists of corresponding data, a single mapping/hash/dictionary of names to remarks is also acceptable.
Note too that although the task is written to take two lists of corresponding data, a single mapping/hash/dictionary of names to remarks is also acceptable.


'''Note to editors:''' Program output with escaped characters will be viewed as the character on the page so you need to 'escape-the-escapes' to make the RC entry display what would be shown in a plain text viewer (See [[Talk:XML_Creation#Escaping_Escapes|this]]). Alternately, output can be placed in <nowiki><lang xml></lang></nowiki> tags without any special treatment.
'''Note to editors:''' Program output with escaped characters will be viewed as the character on the page so you need to 'escape-the-escapes' to make the RC entry display what would be shown in a plain text viewer (See [[Talk:XML_Creation#Escaping_Escapes|this]]).
Alternately, output can be placed in <nowiki><lang xml></lang></nowiki> tags without any special treatment.

=={{header|Ada}}==
=={{header|Ada}}==
{{works with|GNAT}}
{{works with|GNAT}}
Line 368: Line 371:
)
)
)</lang>
)</lang>
{{out}}
Output:
<lang xml><?xml?>
<pre><?xml?>
<CharacterRemarks><Character name="April">Bubbly: I'm &gt; Tam and &lt;= Emily</Character>
<CharacterRemarks><Character name="April">Bubbly: I'm &gt; Tam and &lt;= Emily</Character>
<Character name="Tam O'Shanter">Burns: "When chapman billies leave the street ..."</Character>
<Character name="Tam O'Shanter">Burns: "When chapman billies leave the street ..."</Character>
<Character name="Emily">Short &amp; shrift</Character>
<Character name="Emily">Short &amp; shrift</Character>
</CharacterRemarks></lang>
</CharacterRemarks></pre>


=={{header|C}}==
=={{header|C}}==
Line 530: Line 533:
"Short & shrift"))</lang>
"Short & shrift"))</lang>


{{out}}
output:
<div style="width:full;overflow:scroll">
<div style="width:full;overflow:scroll">
<pre><?xml version="1.0" encoding="UTF-8"?>
<pre><?xml version="1.0" encoding="UTF-8"?>
Line 708: Line 711:
puts(1,"</CharacterRemarks>\n")</lang>
puts(1,"</CharacterRemarks>\n")</lang>


{{out}}
Output:
<lang xml><CharacterRemarks>
<pre><CharacterRemarks>
<CharacterName="April">Bubbly: I&apos;m &gt; Tam and &lt;= Emily</Character>
<CharacterName="April">Bubbly: I&apos;m &gt; Tam and &lt;= Emily</Character>
<CharacterName="Tam O&apos;Shanter">Burns: &quot;When chapman billies leave the street ...&quot;</Character>
<CharacterName="Tam O&apos;Shanter">Burns: &quot;When chapman billies leave the street ...&quot;</Character>
<CharacterName="Emily">Short &amp; shrift</Character>
<CharacterName="Emily">Short &amp; shrift</Character>
</CharacterRemarks>
</CharacterRemarks>
</lang>
</pre>


=={{header|F_Sharp|F#}}==
=={{header|F_Sharp|F#}}==
Line 788: Line 791:
</lang>
</lang>


Output (not exactly conforming):
{{out}} (not exactly conforming):
<pre>
<pre>
<?xml version='1.0' encoding='UTF-8'?>
<?xml version='1.0' encoding='UTF-8'?>