Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > xincluding a file twice

Reply
Thread Tools

xincluding a file twice

 
 
McSwell
Guest
Posts: n/a
 
      11-30-2008
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)
>


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

</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 <PhhonemeSet> 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 <PhhonemeSet> gets embedded:
<xi:include href="fragUnicodePhonemes.xml"
xpointer="element(UrduPhonemeSet)" />
The problem is that the <PhhonemeSet 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
 
Reply With Quote
 
 
 
 
Magnus Henriksson
Guest
Posts: n/a
 
      12-03-2008
McSwell wrote:
> I want to xi:include (part of) a single XML file twice in the same XML
> document


--snip--

> The problem is that the <PhhonemeSet 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
 
Reply With Quote
 
 
 
 
McSwell
Guest
Posts: n/a
 
      12-05-2008
On Dec 3, 6:28*am, Magnus Henriksson
<(E-Mail Removed)> wrote:
> Since you are using xsltproc you can use the xpointer() scheme. See
> here:http://www.sagehill.net/docbookxsl/DuplicateIDs.html


Thanks, that was exactly what I needed! (It took me awhile to figure
out the syntax for the namespace
names, but I found an example here: http://www.w3.org/TR/xptr-xmlns/.
That's maybe the first time
I've been able to understand a W3C spec well enough to use it. I
guess there's hope for me yet .)

Mike Maxwell
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to read and write a file without open file twice? Thanks in advance. mike Perl Misc 3 09-26-2007 06:56 PM
twice(twice(x)) Kiuhnm C++ 2 04-01-2006 04:41 PM
Download file dialogue appears twice using Content-Disposition 'attachment' submitted from a form ben ASP .Net 0 07-07-2004 10:26 AM
c++ file i/o: cant use file twice Jeremy Bishop C++ 2 11-13-2003 01:02 PM
no csc.exe file even thought i installed .netSDK twice khawar ASP .Net 1 07-15-2003 07:16 PM



Advertisments