Talk:XML/Output: Difference between revisions

Content added Content deleted
(→‎Modification of Task: Use plain text)
Line 18: Line 18:


----
----
Create a function that takes a list of character names and a list of corresponding remarks and returns an XML doccument of <code><Character></code> elements each with a name attributes and surrounding their remarks. All <code><Character></code> elements are to be enclosed in an outer <code><CharacterQuotes></code> element.
Create a function that takes a list of character names and a list of corresponding remarks and returns an XML doccument 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 names of: “<code>April</code>”, “<code>Tam O'Shanter</code>”, and “<code>Emily</code>” and remarks of:
As an example, calling the function with the three names of:
<pre>
<pre>“Bubbly: I\'m > Tam and <= Emily”
April
“Burns: "When chapman billies leave the street ..."
Tam O'Shanter
and “Short & shrift”</pre>
Emily</pre>
Should produce the XML (modulo line breaks):
And three remarks of:
<pre><CharacterQuotes>
<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):
<pre><CharacterRemarks>
<Character name="April">Bubbly: I'm &amp;gt; Tam and &amp;lt;= Emily</Character>
<Character name="April">Bubbly: I'm &amp;gt; Tam and &amp;lt;= Emily</Character>
<Character name="Tam O&amp;apos;Shanter"
<Character name="Tam O&amp;apos;Shanter"
>Burns: &amp;quot;When chapman billies leave the street ...&amp;quot;</Character>
>Burns: &amp;quot;When chapman billies leave the street ...&amp;quot;</Character>
<Character name="Emily">Short &amp;amp; shrift</Character>
<Character name="Emily">Short &amp;amp; shrift</Character>
</CharacterQuotes></pre>
</CharacterRemarks></pre>


Note: the example is chosen to also show correct escaping of XML strings
Note: the example is chosen to also 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/dicctionary of nammes to remarks is also acceptable

----



--[[User:Paddy3118|Paddy3118]] 07:14, 9 June 2009 (UTC)
--[[User:Paddy3118|Paddy3118]] 07:14, 9 June 2009 (UTC)
Line 41: Line 51:
:::That's the point when I use UNICODE quotes. Thankfully they're easy to type on this keyboard. —[[User:Dkf|Donal Fellows]] 12:26, 9 June 2009 (UTC)
:::That's the point when I use UNICODE quotes. Thankfully they're easy to type on this keyboard. —[[User:Dkf|Donal Fellows]] 12:26, 9 June 2009 (UTC)
::Why quoted strings? Why not just enter the example input as plain text? In real world applications, the data would came from user, or from file, or from stdin, etc. Normally, the text is just plain text, with no quotes or escape characters. (Of course the test code that calls the actual function could use string constants, but that is language and implementation specific.) On the other hand, using two input lists would be quite strange way to enter data in real world. It would be more logical to enter the name and remark together, as a pair. (But I don't quite understand what this "remark" is supposed to be.) --[[User:PauliKL|PauliKL]] 15:27, 9 June 2009 (UTC)
::Why quoted strings? Why not just enter the example input as plain text? In real world applications, the data would came from user, or from file, or from stdin, etc. Normally, the text is just plain text, with no quotes or escape characters. (Of course the test code that calls the actual function could use string constants, but that is language and implementation specific.) On the other hand, using two input lists would be quite strange way to enter data in real world. It would be more logical to enter the name and remark together, as a pair. (But I don't quite understand what this "remark" is supposed to be.) --[[User:PauliKL|PauliKL]] 15:27, 9 June 2009 (UTC)
:Hi Pauli, I've changed the example above to be without outer quotes for the input text descriptions and removed the backslash. I have chosen the simplest input format that I thought languages could cope with. The focus is to be the generation of correctly formatted XML. The remark is just a device to allow the example to include characters that should be quoted, as is the apostrophe in Tam O'Shanter. --[[User:Paddy3118|Paddy3118]] 18:08, 9 June 2009 (UTC)