• Home
  • About
  • Connect
  • Books
  • Books with fiction blog

Books with Views

~ multidimensional e-reading

Books with Views

Tag Archives: Into Embedded

Making books with XML

12 Tuesday Jul 2016

Posted by Ola in e-book, Emacs, epub, Into Computers, Into Embedded, Into Programming, nxml, PSGML, RelaxNG, XML

≈ Leave a comment

Tags

e-book, Emacs, epub, Into Computers, Into Embedded, Into Programming, nxml, PSGML, RelaxNG, XML

When I did my first book, I decided to use XML for the book contents. Considering my background in academia , I might have chosen LaTeX instead.

But I wanted the possibility to generate different output formats. Specifically, I wanted to generate html and pdf.

And I wanted to learn XML.

I chose PSGML and Emacs as my editing tools. I found this combination to be really powerful, and eventually (after a lot of practice) I could write almost as fast as when writing in a Word processor, like MS Word.

In early 2015, I found that my PSGML and Emacs combination did not work as good as before.

I did some trouble-shooting, but without luck.

I realized that it was perhaps time for something newer. I searched for alternatives, and after a while I found nxml. This turned out to be an interesting alternative, but I had to do some porting work, in order to get started.

I translated my old DTD files to RelaxNG schemas.

I added code to my .emacs file, as

(require 'nxml-mode)
(add-to-list 'auto-mode-alist '("\\.xml$" . nxml-mode))

(eval-after-load 'rng-loc
  '(add-to-list 'rng-schema-locating-files "~/rng/schemas.xml"))

The file schemas.xml is a reference to the actual schemas. As an example, taken from my own schemas.xml file, there is a reference to a file called chapter.rnc, as

  <documentElement prefix="" localName="chapter" typeId="chapter"/>
  <typeId id="chapter" uri="chapter.rnc"/>

Inside chapter.rnc we find e.g.

    element chapter_intro {
       element para_list {
          element para { external "para_elements.rnc"}*}},

which defines an element called chapter_intro, with an element called para_list inside, which in turn is a list of para elements.

The para element itself is defined in the file para_elements.rnc. As an example of contents from this file, we have the element item_list, which is a list of item elements (which in turn can contain text). The element item_list is part of a mixed element, and its Relax NG definition is

     element item_list {
         element item { text }+ } |

Using Relax NG schemas in this way, I found the actual editing to be fairly straightforward. It turns out that Emacs highlights (in red) parts of the XML file that do not comply with the schema. This is very helpful when doing the editing, and it is a feature that was not there when I used the PSGML and Emacs combination.

In PSGML, I used quite a few editing commands (which had to be learned, and practiced, to get up to speed). When using Relax NG schemas, I use only the command for completion.

The command for completion is set to Alt-Tab as default. As we know, Alt-Tab has another standard meaning! It changes focus to another program. It turns out, however, that Alt-Tab can be used anyway.

On Mac, I could use Alt-Tab as is, since the key that corresponds to Alt in Alt-Tab is the command key on Mac!

On Linux, I could use Esc Tab (the Escape key followed by Tab, i.e. the two keys are pressed in sequence, and the Escape key must be released before pressing the Tab key). This is not so surprising, since this is the alternative (old) way to use Alt-commands in Emacs.

In Emacs, Alt is often referred to as the Meta key. A Meta key combination can be obtained by pressing Alt and another key while holding down Alt, or alternatively, by pressing and releasing the Escape key before pressing the next key (Tab in this case).

The net result was that I could continue writing books in XML.

You can see some examples of generated files, as

  • Into Computers, a book about creating your own computer, in html
  • Into Programming, a book about programming, in pdf (Python) and pdf (C)
  • Into Embedded, a book about embedded systems, in epub

Books with Software

14 Monday Oct 2013

Posted by Ola in ARM, assembly, bare metal, download, Intel, Into Embedded, software, views

≈ Leave a comment

Tags

ARM, assembly, bare metal, download, Intel, Into Embedded, software, views

Books about software are best enjoyed with software.

In a book with views, there may be different pieces of software associated with the different views.

However, a reader may still like to enjoy one software package, covering all the views, for a given book.

This approach has been taken for the books produced here. As a first example, a software package for the book Into Embedded has been created.

The software package can be downloaded as a zip-file from the Book Software page.

But wait, there’s more!

As you might have guessed, the actual content of the books is generated, automatically, from some kind of template. I use XML for the template and Python for the book generation program.

And since a computer program processes the XML, and generates html for the web and epub or mobi for the e-book variants, we can take advantage of this and let the computer program perform other tasks as well.

As an example, all figures showing program code are extracted from real programs. The source code of a program from which a figure shall be extracted is annotated, with markup showing where each figure starts and ends. The result of this can be seen, e.g. in Figure 2, which shows startup code for a processor.

The corresponding source file for this figure is found in the file startup.s.

While the book-generating program processes the XML, it can also make a list of all software files needed. Such a list is shown on the Book Software page. You might note that there are links, inside the list, to Figures within the book and also to the actual software files used.

The software can be tried out. It can be built and it can be executed. It requires some tools, like compilers and linkers, and also a simulator (QEMU) is used.

The software covers the Bare Metal chapter of the book, and it shows how to make a small program that can run entirely on its own, i.e. it can run without the help of an operating system.

Here is a direct download link.

And yes, there is a README-file inside (with a HOWTO for building the software, and with hints on how to download and install the necessary tools)

Have fun,

The bookmaker (a.k.a Ola)

Please enter email address below

Recent Posts

  • Layered Books
  • Making books with XML
  • Books with Software
  • Three (3) books about programming? – Nope, there’s only one!
  • Linking in and out of a book

Latest Tweets

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

Where to go from here?

  • Books with fiction
  • gapingvoid
  • Harpers
  • Seth's Blog
  • The Story of Telling

Archives

  • January 2018
  • July 2016
  • October 2013
  • September 2012
  • July 2012
  • June 2012
  • May 2012
  • April 2012
  • March 2012
  • February 2012
  • January 2012

Categories

  • ARM
  • assembly
  • bare metal
  • C
  • concepts
  • download
  • e-book
  • e-book reader
  • Emacs
  • epub
  • hello world
  • index
  • Intel
  • Into Computers
  • Into Embedded
  • Into Programming
  • Java
  • Layered Books
  • math
  • meta information
  • mobi
  • nxml
  • pandoc
  • pdf
  • programming
  • programming languages
  • PSGML
  • Python
  • references
  • RelaxNG
  • release note
  • software
  • views
  • XML

Meta

  • Register
  • Log in
  • Entries feed
  • Comments feed
  • WordPress.com

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy