The classic: “Hello, world!” Or: what does a simple document look like?
As already described, the input for the Publisher consists of two files: the data file and the layout file.
Both must be in XML format and must always be available.
The data file is saved under the name
data.xml and the layout file under
These two files are best created with an XML editor or with the free text editor Visual Studio Code which has very good XML support.
If you want to try the “Hello World” example yourself, you can simply call
The data file for the “Hello World” example is named
That is enough for the simple example. The layout file is a bit more extensive (save as
<Layout xmlns="urn:speedata.de:2009/publisher/en" xmlns:sd="urn:speedata:2009/publisher/functions/en"> <Record element="data"> <PlaceObject> <Textblock> <Paragraph> <Value select="."/> </Paragraph> </Textblock> </PlaceObject> </Record> </Layout>
These two files are stored in an otherwise empty directory. On the command line, change to this directory (with
cd <directory name>) and call the Publisher with the command
$ character is intended to represent the prompt and is not entered. If everything goes smoothly, the result is a PDF file named
publisher.pdf in the same directory.
|For Windows users: if the publisher cannot create the PDF, this is sometimes because the same file is still open in a window. This can be Adobe Reader, but also Windows Explorer.|
The “Hello World!” example explained
Here follows a short explanation of the two files. The data file can be structured as you wish, as long as the content is well-formed XML (see glossary).
The layout file is a bit more complicated, at least at first sight.
<Layout ① xmlns="urn:speedata.de:2009/publisher/en" xmlns:sd="urn:speedata:2009/publisher/functions/en"> <Record element="data"> ② <PlaceObject> ③ <Textblock> <Paragraph> <Value select="."/> ④ </Paragraph> </Textblock> </PlaceObject> </Record> </Layout>
The root element is called
Layout and has the namespace
urn:speedata.de:2009/publisher/en. The second namespace is necessary for the built-in functions, but is not used in the example. (Tip: nevertheless always specify it in the layout, so that there are no surprises later).
Here the data processing starts. The root element of the data file is specified in the attribute
<PlaceObject> is the command to output things (texts, images, boxes, …) into the PDF.
The dot at the select attribute means “the current element”, in this case the root element. The text value of the element is output here, i.e. the string
We will not discuss more at this point. Rather, there is a reference to the corresponding chapters in this manual: Under File organization is described how the data file and the layout file are to be structured, and under Outputting objects the command
<PlaceObject> is described.