28 lines
1.8 KiB
Plaintext
28 lines
1.8 KiB
Plaintext
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:
|
|
<pre>
|
|
April
|
|
Tam O'Shanter
|
|
Emily</pre>
|
|
And three remarks of:
|
|
<pre>
|
|
Bubbly: I'm > Tam and <= Emily
|
|
Burns: "When chapman billies leave the street ..."
|
|
Short & shrift</pre>
|
|
Should produce the XML (but not necessarily with the indentation):
|
|
<lang xml><CharacterRemarks>
|
|
<Character name="April">Bubbly: I'm > Tam and <= Emily</Character>
|
|
<Character name="Tam O'Shanter">Burns: "When chapman billies leave the street ..."</Character>
|
|
<Character name="Emily">Short & shrift</Character>
|
|
</CharacterRemarks></lang>
|
|
|
|
The document may include an <tt><?xml?></tt> declaration and document type declaration, but these are optional. If attempting this task by direct string manipulation, the implementation ''must'' include code to perform entity substitution for the characters that have entities defined in the XML 1.0 specification.
|
|
|
|
Note: the example is chosen to show correct escaping of XML strings.
|
|
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.
|