XML equivalent to an #ifdef?

A

a5ehren

For my job, we need to be able to dynamically compile a document based
on flags we send to the compiler; for example, the non-US version of
our program has features removed that foreign users are not allowed to
know about, so we need to remove any mention of them from the user's
manual. We're trying to save a lot of time by not having to maintain
two versions of the manual - is there any XML markup that will allow a
parser to selectively remove parts of the document?
 
B

Bjoern Hoehrmann

* (e-mail address removed) wrote in comp.text.xml:
For my job, we need to be able to dynamically compile a document based
on flags we send to the compiler; for example, the non-US version of
our program has features removed that foreign users are not allowed to
know about, so we need to remove any mention of them from the user's
manual. We're trying to save a lot of time by not having to maintain
two versions of the manual - is there any XML markup that will allow a
parser to selectively remove parts of the document?

The format you use to make the manual might have such means, other than
that you'll have to build that yourself, e.g. a processing instruction
could be added to signal this, like <?ifdef ...?>...<?endif?>.
 
A

Andy Dingley

- is there any XML markup that will allow a
parser to selectively remove parts of the document?

No, but this isn't a task that's appropriate for the _parser_ to be
doing anyway. XML parsers turn serialised documents into in-memory
DOMs, they don't make processing choices about things.

Such a task would be trivial to process in XSLT. Define some flag or
other in whatever schema you use to represent your documents (DocBook ?)
and process on its value.
 
R

Richard Tobin

- is there any XML markup that will allow a
parser to selectively remove parts of the document?
[/QUOTE]
No, but this isn't a task that's appropriate for the _parser_ to be
doing anyway. XML parsers turn serialised documents into in-memory
DOMs, they don't make processing choices about things.

That's not *quite* true. Conditional sections in the DTD allow you
some control, but not necessarily a convenient way to switch things
without changing a file.
Such a task would be trivial to process in XSLT.

Yes, and XSLT processors let you pass in parameters on the command
line.

-- Richard
 
P

Peter Flynn

For my job, we need to be able to dynamically compile a document based
on flags we send to the compiler; for example, the non-US version of
our program has features removed that foreign users are not allowed to
know about, so we need to remove any mention of them from the user's
manual. We're trying to save a lot of time by not having to maintain
two versions of the manual - is there any XML markup that will allow a
parser to selectively remove parts of the document?

Not quite, but the Entity Switch mechanism is heavily used in many
industrial DTDs to control which content models become allowed for
different classes of document. DocBook has this kind of modularity
enabled. What you describe are known as "effectivities", which are
classifications of certain element types (using sttribute values; see
DocBook again for an example) that your processor can recognise so
that only the appropriate parts of the document are output. This does
indeed allow you to maintain a single master document and output
targeted versions.

///Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,001
Messages
2,570,254
Members
46,851
Latest member
CliftonCor

Latest Threads

Top