What the hell is XML? And, how on earth do we use it in publishing?

This post is not a 'pure' programming guide, but instead the first post in a series designed as a practical way of getting XML working in publishing. If you are looking for the former, I'd recommend something like the w3schools guide as a good starting point.

The focus here is to ask questions like (1) how can we integrate XML into a publishing workflow? and (2) why should we integrate XML into a production workflow?

What the hell is XML?

Put simply:

<root>
<tag>Some text.</tag>
</root>

Do we need to label elements root and tag?

No, you can use whichever words you like, as long as they are paired with open and closing tags, e.g. <root> and </root>

Now let's create an XML document that looks like something we'd face in publishing:

<story>
<h1>This is a top level heading</h1>
<p>This is a paragraph with some <i>italic text</i> in it.</p>
</story>

If you type or copy and paste this into a text editor (not a word processor), there is only one more step until we have our XML document, and that is to 'Save as ...' a text document changing the document type from .txt to .xml in the filename box. Note: if the program you are using does not allow you to do this, do it in Finder or Windows Explorer (click on the hyperlinks if you need help on how to do this).

I don't want to blast you here with text encoding requirements or doc types and so on, because chances are everything will work fine if you use a basic text editor, but if asked to choose a text-encoding when you save your XML document choose 'UTF-8' with 'no BOM' if possible.

Now open the file in Firefox if you can, and you should see this:



Congratulations you have your first XML document (no need to worry about the missing style information at present).

The next post in this series will look at how we import this document into InDesign and apply styles to it.

Comments

  1. While I don't necessarily agree with all of their anti-w3schools vehemence, http://w3fools.com/ has some good links to resources as well.

    ReplyDelete
  2. @Chris Thank you for pointing this site out, it looks like a valuable resource. I cited w3schools mainly because their examples are easy to read and incredibly clear.

    I had thought to mention O'Reilly's XML.com but people visiting this site may well not be that far advanced in understanding code, and I wanted a non-scary way in for them.

    ReplyDelete
  3. Thanks Anthony. Have you posted yet on "how we import this document into InDesign and apply styles to it"? That would be great info.:)

    ReplyDelete
  4. Anna, Thanks for your comment. I'm trying to clear a space to do this. Hopefully, I'll get this post up soon. Best, Anthony.

    ReplyDelete

Post a Comment