Applying variables to replace text

Questions about XML that are not covered by the other forums should go here.
d_shevitz
Posts: 1
Joined: Tue Jan 10, 2006 1:11 am

Applying variables to replace text

Post by d_shevitz »

Hello!

I have an interesting challenge (well, both interesting and challenging to me, at any rate):

I have a several documents that reference a master file through the use of xinclude statements. What I would like to have the master file contain a variable that represents an element, and have the referencing document replace that variable with a more relevant term.

I've done something similar before, where I had:

<[!Entity objectName "widget"]>

And in the body of the file:

You need to use &objectName; to get the job done.

When I transform a document like this, any instance of &objectName; is replaced with "widget." Unfortunately, this doesn't seem to work when I have xincludes.

Anyone have any suggestions on the best way to acheive this? Thanks!
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi,

If you want the entity to contain some text then you can use someting like

<xi:include href="w.txt" xmlns:xi="http://www.w3.org/2001/XInclude" parse="text"/>

and place the text inside the included text file, for instance, if w.txt contains widget then you get that replacing the xi:include element.

--

Entities do not work across multiple files and XInclude implies multiple files so you cannot use entities defined in one file in the other files.

--

You can also use an element like <widget/> for instance and create a processing layer that replaces this element (or multiple such elements if you need) with the replacement text.

Best Regards,
George
Post Reply