[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [StrongED] Re: StrongED Instructions



On 2017-12-17 17:14, Richard Torrens (lists) wrote:
In article <mpro.p13slx01fqtqk025n.lists@xxxxxxxxxxxxxxxxxx>,
   Steve Fryatt <lists@xxxxxxxxxxxxxxxxxx> wrote:
If you can write simple HTML web pages, you can mark up a manual in XML.
HTML is just one subset of XML, and in this case you define tags for
things like sections of the document, images, the names of icons in
dialogue boxes, menu entry names, and so on.

Sounds like XML is so similar to html it's not worth the bother.

It IS worth the bother, because it allows you to 'tag' information that
is significant in particular ways.

For example, you might want (in the final documents) to format a keyboard shortcut in a particular way. If you were preparing the document in HTML
you'd enter it (perhaps using HTML entities) and surround it with the
HTML tags that tell a browser how to display it.

But in XML you'd simply surround it with, say:

  <SEshortcut>Ctrl-D</SEshortcut>

That allows later processing to dig out all the references to SE shortcuts throughout the documents, and completely defers the decisions about how, in any output format, such a shortcut should actually be represented. (I know it's probably more complicated as you might need to represent the separate keys, Ctrl, Shift etc by individual elements, eg saying that that shortcut is a combination of keys, and those were Ctrl and D. Then in a plain text output document you might represent that by "Ctrl" and "-" and "D", while in HTML or PDF you might embed tiny icons representing the "Ctrl" key, and
so on.)

It would eg make generation of a table of shortcuts and links to all the
places they are described, easier to produce.


If XML were to be used, someone who's familiar with XML concepts would need to work out what sorts of things should be tagged, and the syntax for doing
that.  It's pretty arbitrary, but whatever is chosen affects what can be
done with the tagged information later on.

It might be a good idea if you looked at some example XML documents to see
the point about how elements in a text can be tagged usefully.

For example, I have an audio recorder which saves its settings in an XML
file. An example starts:

 <?xml version="1.0"?>
 <Project>
 <ProjectSettings>
 <SampleRate>0</SampleRate>
 <Width>24</Width>
 <ChanType>3</ChanType>
 <FileBase>Take</FileBase>
 <FileCount>24</FileCount>
 <MarkBase>Mark</MarkBase>
 <MarkCount>4</MarkCount>
 <DropNameBase>TCDrop</DropNameBase>
 <DropNameCount>0</DropNameCount>
 <OverNameBase>Over</OverNameBase>
 <OverNameCount>0</OverNameCount>
 ...

and continues - it's just a long list of stagged values. This file has no hierarchy, ie no nested definitions. But storing the data like this means
that other computer programs can extract named/tagged values easily.


Another example is part of an old RSS feed file.  Each <item> describes
an element of news:

<item>
 <title>Paraguay holds key presidential poll</title>
<description>Paraguayans are voting in a presidential election.</description> <link>http://www.bbc.co.uk/news/world-latin-america-22236775#sa-ns_mchannel=rss&amp;ns_source=PublicRSS20-sa</link> <guid isPermaLink="false">http://www.bbc.co.uk/news/world-latin-america-22236775</guid>
 <pubDate>Sun, 21 Apr 2013 13:07:51 GMT</pubDate>
<media:thumbnail width="66" height="49" url="http://news.bbcimg.co.uk/media/images/67139000/jpg/_67139616_77we7rn0.jpg"/> <media:thumbnail width="144" height="81" url="http://news.bbcimg.co.uk/media/images/67139000/jpg/_67139617_77we7rn0.jpg"/>
</item>

<item>
 <title>US steps up aid to Syria opposition</title>
<description>Secretary of State John Kerry steps up US aid to Syria's rebels.</description> <link>http://www.bbc.co.uk/news/world-middle-east-22232313#sa-ns_mchannel=rss&amp;ns_source=PublicRSS20-sa</link> <guid isPermaLink="false">http://www.bbc.co.uk/news/world-middle-east-22232313</guid>
 <pubDate>Sun, 21 Apr 2013 03:51:48 GMT</pubDate>
<media:thumbnail width="66" height="49" url="http://news.bbcimg.co.uk/media/images/67137000/jpg/_67137873_67027587.jpg"/> <media:thumbnail width="144" height="81" url="http://news.bbcimg.co.uk/media/images/67137000/jpg/_67137874_67027587.jpg"/>
</item>

The point about this example is that a program can easily iterate through the file asking to be given details of every <item>, or eg ask for just the <description> element of
each item, or eg count how many <media> elements there are in each one.

If the file had been presented in HTML you wouldn't know which sentences were titles,
descriptions etc, or what sorts of things links were to.

Also, unlike HTML, the elements in these two examples are named approriately for the task in hand. The tags in the two examples are named differently and have different sorts of
contents.


Here's a third example, which defines the layout of information on a menu somewhere
inside LibreOffice:

<menu:menupopup xmlns:menu="http://openoffice.org/2001/menu";>
  <menu:menuitem menu:id=".uno:Cut"/>
  <menu:menuitem menu:id=".uno:Copy"/>
  <menu:menuitem menu:id=".uno:Paste"/>
  <menu:menuseparator/>
  <menu:menuitem menu:id=".uno:ShowPropBrowser"/>
</menu:menupopup>

In that one the format is very hard to understand, I think because the contents
of the XML tagged fields are part of a language for defining computer
interfaces, developed by Mozilla. Regardless of what's inside the tags, an XML processor can still parse information out of the file and do arbitrary
things with it.


and here's another from a different program:


<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
  <schema id='org.gtk.Settings.ColorChooser'>
    <key name='custom-colors' type='a(dddd)'>
      <default>[]</default>
    </key>
    <key name='selected-color' type='(bdddd)'>
      <default>(false,1.0,1.0,1.0,1.0)</default>
    </key>
  </schema>
</schemalist>

Again, XML is used ... and again the 'tags' eg <schema>, <key>
suit the purpose of the file.  Somewhere there will be a definition
that says that 'name', 'type' and 'default' are permitted
attributes of the 'key' tag.  It might go into more detail about
what sorts of values are valid in each case.


Do you see that XML offers a general framework for structuring
data and passing value on about what those parts are for?

--
Jeremy Nicoll - my opinions are my own

--
To unsubscribe send a mail to StrongED+unsubscribe@xxxxxxxxxxx
List archives at http://diy.Torrens.org/RO/StrongED/index.html