M
maxwell
I am trying to figure out how to include namespace declarations that
come from another file. As usual for me (I'm hoping readers of this
list get different mileage, else I'm in trouble ), while it seems
conceptually simple, doing it has proven difficult.
I have a bunch of files that look something like this:
-----------------------------------
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE book PUBLIC "-//Normal Walsh//DTD XWEB V1.0 in DocBook XML
V4.2//EN"
"http://docbook.sourceforge.net/release/litprog/
current/dtd/ldocbook.dtd">
<src:fragment id="fragNaturalClasses"
xmlns:src="http://docbook.sourceforge.net/release/
litprog/current/dtd/ldocbook.dtd"
xmlnsh= "Phonology.xsd"<Ph:NCSegment id="ncConsonantLetter">
[more XML here...]
-----------------------------------
All the files contain the same set of xmlns declarations--in fact,
there are five or six such declarations, although the example above
only contains two of them (I kept it short for illustration). The id
of the <src:fragment> element will be different in each file, of
course.
What I would like to do is to pull out the namespace declarations into
a separate place, and include them somehow in all the individual
files. I've tried several ways to do that, and none of them seem to
work; or at least xsltproc complains when it tries to process the
files (e.g. by including them in some other file). My goal is that
each of these files should be well-formed and valid XML on its own.
Here's what I've tried:
1) Creating an entity definition, and "calling" it with e.g.
'&NamespaceDeclarations;'. But it's not clear how I include the file
containing the entity definition *before* the root element where the
entity is first used. <xinclude...> won't work, or at least I can't
figure out a way to make it work.
2) Creating a file containing the namespace declarations, and
xincluding them. But again, you can't have an <xinclude.../> element
before the root element.
3) Using cpp (an old C-style preprocessor) to #include the namespace
declarations. This works, but it's just not the xml way.
4) xlink: I can't figure out how this would work.
Is it possible to do what I'm trying to do, namely to put the
namespace declarations somewhere else--like in a separate file--and
include them in each individual file's root element?
Of course it's possible that my whole design is wrong, and that all
the <src:fragment> elements should be in a single file, with a single
namespace declaration at the top. But I wanted to modularize it, for
any number of reasons.
Mike Maxwell
CASL/ U MD
come from another file. As usual for me (I'm hoping readers of this
list get different mileage, else I'm in trouble ), while it seems
conceptually simple, doing it has proven difficult.
I have a bunch of files that look something like this:
-----------------------------------
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE book PUBLIC "-//Normal Walsh//DTD XWEB V1.0 in DocBook XML
V4.2//EN"
"http://docbook.sourceforge.net/release/litprog/
current/dtd/ldocbook.dtd">
<src:fragment id="fragNaturalClasses"
xmlns:src="http://docbook.sourceforge.net/release/
litprog/current/dtd/ldocbook.dtd"
xmlnsh= "Phonology.xsd"<Ph:NCSegment id="ncConsonantLetter">
[more XML here...]
-----------------------------------
All the files contain the same set of xmlns declarations--in fact,
there are five or six such declarations, although the example above
only contains two of them (I kept it short for illustration). The id
of the <src:fragment> element will be different in each file, of
course.
What I would like to do is to pull out the namespace declarations into
a separate place, and include them somehow in all the individual
files. I've tried several ways to do that, and none of them seem to
work; or at least xsltproc complains when it tries to process the
files (e.g. by including them in some other file). My goal is that
each of these files should be well-formed and valid XML on its own.
Here's what I've tried:
1) Creating an entity definition, and "calling" it with e.g.
'&NamespaceDeclarations;'. But it's not clear how I include the file
containing the entity definition *before* the root element where the
entity is first used. <xinclude...> won't work, or at least I can't
figure out a way to make it work.
2) Creating a file containing the namespace declarations, and
xincluding them. But again, you can't have an <xinclude.../> element
before the root element.
3) Using cpp (an old C-style preprocessor) to #include the namespace
declarations. This works, but it's just not the xml way.
4) xlink: I can't figure out how this would work.
Is it possible to do what I'm trying to do, namely to put the
namespace declarations somewhere else--like in a separate file--and
include them in each individual file's root element?
Of course it's possible that my whole design is wrong, and that all
the <src:fragment> elements should be in a single file, with a single
namespace declaration at the top. But I wanted to modularize it, for
any number of reasons.
Mike Maxwell
CASL/ U MD