Decorate XML

This simple program copies decorates one xml file with another. Two files are input. One is the decoration for the other. It looks for lines in the decoration that contain a string like [decorated body goes here]. When it finds one, that string is replaced by the body of the other file, the decorated file. Such a sting is called a directive. Below is the source.

#!cat $source | sed 's/&/&/g' | sed 's//\>/g'

Look at the Makefile in this directory to see one way it can be used. We export some shell variables that are used within decoratexml.html.uc. This way all the file names appear in the Makefile and none are hidden in decoratexml.html.uc. Ubercat.rb is then applied to create decoratexml.html. At last decore.xhtml is applied by decoratexml.rb to create decoratexml.xhtml.

Notice that all pages, those being decorated and those used as decoration as well as the result, should be readily readable and understandable when viewed in a browser.

Notice also that decoration can be nested. c.f. SiteMesh (2013-01-08: Not sure what I meant by this. Maybe that one could generate a template from another one since unreplaced directives should remain in the result. Hence, one could replace some directives with a first run and then others with a second run. One run being more widely usable and one more specialized. Nesting directives like [decorated [global ourTag goes here] goes here] does work, but not the system directive.)

The tag in the syntax [decorated tag goes here] is like a CSS selector. So I'm going to call it a "selector". There are only a few forms it can take:

Other Insertions


Helpful might be:

Maybe the terms should be changed:

The raw file that will be decorated.
The file that will be wrapped around the undecorated file.
The result

So the undecorated + the decore -> the decorated. This will allow us to refer in the decore to both the undecorated and the decorated. e.g. we might want the file name of the decorated in the footer. Hence there might be both "[undecorated body goes here]" and "[decorated filename goes here]".

Perhaps a syntax like [undecorated attr of selector goes here] would be useful? Or other CSS like selector syntax like .class, tag subtag, etc.?

We could add some other stuff to make it a bit like a poor man's XSLT. Note that we want to continue the idea that every page stands on it's own, and can be reasonably viewed and understood in a web browser.

Maybe strip any mock up division (<div class="mockup">). This would allow web designers to put in mock text to see how a decore might look.