docbook: Variables in an SGML or XML document
Subject:
Re: Variables in an SGML or XML document
From:
"Martin A. Brown" ####@####.####
Date:
15 Nov 2003 22:26:09 -0000
Message-Id: <Pine.LNX.4.58.0311151616190.4453@copula.wonderfrog.net>
Rodolfo,
Hi again!
: Can I define a variable in an SGML or XML document, like $TITLE
: for instance?
:
: I would like to create a standardized block with which to start any HOWTO
: document (including intro, copyright, credits, disclaimers, etc.) and of
: course this would be easier if I could include something like
: TITLE="Nailbiting-HOWTO" and then refer to <title>$TITLE</title> later.
:
: Is this possible, and (if so) is there a difference between how it is done
: in SGML vis-à-vis XML?
I can't speak for SGML (although I gather it's quite similar). Here
goes for XML:
You are looking to use entities....general entities. I use them
frequently in my linux-ip guide (which, though underway, has seen
little work in a few months).
There may be better places to read about general entities, but you
can use the following as an example:
<?xml version='1.0'?>
<!DOCTYPE book PUBLIC
"-//OASIS//DTD DocBook V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
<!ENTITY % my-entities SYSTEM "file-full-of-entities.ent" >
%my-entities;
]>
And then the file "file-full-of-entities.ent" contains lines that
look like this:
<!ENTITY % versioninfo SYSTEM "versioninfo.ent" >
%versioninfo; <!-- all version stuff in file called
versioninfo.ent -->
<!ENTITY iproute2 "<command>iproute2</command>" >
Now, anytime I use the general entity "&iproute2;" in my document,
it is replaced with the string "<command>iproute2</command>". This
is convenient for exactly the reason you expressed.
See also all sorts of documents in TLDP CVS. I'll point you to mine
although others also use entities, I'm sure.
http://cvs.tldp.org/index.cgi/LDP/guide/docbook/linux-ip/
In particular you may find the file linux-ip.ent interesting.
Best of luck,
-Martin
--
Martin A. Brown --- Wonderfrog Enterprises --- ####@####.####