xincluding a file twice

M

McSwell

I want to xi:include (part of) a single XML file twice in the same XML
document, and while it seems like it should be easy... well, that's
always my experience with XML: the hard things it does easily, the
simple things are what trip me up.

The file to be included is named fragUnicodePhonemes.xml, and it looks
like this:
---------------------------------
<?xml version="1.0" encoding="utf-8"?>
<src:fragment xml:id = "fragUnicodePhonemes"
xmlns:src = "http://docbook.sourceforge.net/release/
litprog/current/dtd/ldocbook.dtd"
(other namespace declarations here)

<Ph:phonemeSet xml:id = "UrduPhonemeSet)">
(lots of messy stuff here)
</Ph:phonemeSet>

</src:fragment>
---------------------------------
As you may guess, I'm using an <src:fragment> Literate Programming
construct, shamelessly stolen and modified to work with DocBook 5.

I want to embed the above <Ph:phonemeSet> in two different places (one
happens to be an appendix, which maybe explains the redundancy). One
time the entire <src:fragment> gets embedded (so it can be extracted
using the Lit Prog style sheet):
<xi:include href="fragUnicodePhonemes.xml"
xpointer="element(fragUnicodePhonemes)" />
The other time only the <Ph:phonemeSet> gets embedded:
<xi:include href="fragUnicodePhonemes.xml"
xpointer="element(UrduPhonemeSet)" />
The problem is that the <Ph:phonemeSet xml:id = "UrduPhonemeSet)">
element gets embedded both times (once inside the <src:fragment>, and
once by itself)--and so its xml:id shows up twice, which means it
flunks validation (xsltproc complains).

If I could get it to omit the xml:id when it embeds the element, I
guess it would be fine (the only use of the id is to "find" the
element in the external file so it can be embedded, although I suppose
it could end up being used for something else). Or maybe I should
just ignore the warning, taking Mad Magazine's advice: What, me
worry? Or maybe I should change the '<' and '>' to '&lt;' and '&gt;'
before embedding them, although that feels like a kludge. Or maybe I
should just reference the first occurrence in the appendix, instead of
a including it a second time; but that would be more obscure than I
would like. Or maybe there's a way to define it as an entity...

Suggestions?

Mike Maxwell
CASL/ U MD
 
M

Magnus Henriksson

McSwell said:
I want to xi:include (part of) a single XML file twice in the same XML
document
--snip--

The problem is that the <Ph:phonemeSet xml:id = "UrduPhonemeSet)">
element gets embedded both times (once inside the <src:fragment>, and
once by itself)--and so its xml:id shows up twice, which means it
flunks validation (xsltproc complains).

Since you are using xsltproc you can use the xpointer() scheme. See
here: http://www.sagehill.net/docbookxsl/DuplicateIDs.html


// Magnus
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top