Applying variables to replace text
Questions about XML that are not covered by the other forums should go here.
Applying variables to replace text
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!
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!
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
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
Return to “General XML Questions”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service