Topics

Include plain text from external file?


chris_camb <chris@...>
 

Hi,

Is it possible in dita to pull plain text from an external file into a topic.

I have some scripts that generate text reports from our product that I want to include in the doc, something along the following lines:

<p>Here is some sample report output:</p>

<codeblock>
<include href="reports/my_report.txt"/>
</codeblock>

<p>Now for something else...</p>

Is there anyway to do this?

Thanks for your help,

Chris


Deborah Pickett <debbiep-list-ditausers@...>
 

Hi Chris,

On 2010-01-29 04.51, chris_camb wrote:
Is it possible in dita to pull plain text from an external file into a
topic.
If I recall, this was discussed on the list more than a year ago in the context of pulling source code from a file into a <codeblock>. The idea could be adapted to your needs.

There isn't one official, or best, way to do it, as you'll see if you find the prior discussion.

You could arrange to have DITA-OT process the source files through XInclude, which is designed for this kind of thing. Or you could specialize, and add XSLT processing for <include> that brings in the href'd file using the XPath 2.0 unparsed-text() function.

I'd probably lean towards the latter if I had to do it. There's no public implementation of this that I know of; you'd have to code it yourself.


chris_camb <chris@...>
 

Is it possible in dita to pull plain text from an external file into a
topic.
You could arrange to have DITA-OT process the source files through
XInclude, which is designed for this kind of thing. Or you could
specialize, and add XSLT processing for <include> that brings in the
href'd file using the XPath 2.0 unparsed-text() function.
Brilliant! thanks very much for your help, unparsed-text() appears to be the sort of thing I was looking for!

Thanks,

Chris


chris_camb <chris@...>
 

Is it possible in dita to pull plain text from an external file into a topic. [like this]
<codeblock>
<include href="reports/my_report.txt"/>
</codeblock>

I was just about to start specializing to use unparsed-text() and I stumbled across an existing element that lets me do exactly this -- coderef. I used this and it works just perfectly for me:

<codeblock>
<coderef href="reports/my_report.txt"/>
</codeblock>

Thought that might someone who stumbles across this thread in the future!

Cheers,

Chris


Roy <contact@...>
 

Chris,
Where did you find this element? It's not in the DITA 1.1 spec. Is it new in DITA 1.2?

--- In dita-users@..., "chris_camb" <chris@...> wrote:
...

I was just about to start specializing to use unparsed-text() and I stumbled across an existing element that lets me do exactly this -- coderef. I used this and it works just perfectly for me:

<codeblock>
<coderef href="reports/my_report.txt"/>
</codeblock>

Thought that might someone who stumbles across this thread in the future!

Cheers,

Chris


chris_camb <chris@...>
 

Hi,

I found the coderef element in the Open Toolkit, in dtd/technicalContent/dtd/programmingDomain.mod.

I have no idea whether it is part of the 1.2 spec or not I'm afraid -- it works and that's pretty much all I care about :)

Cheers,

Chris

--- In dita-users@..., "Roy" <contact@...> wrote:

Chris,
Where did you find this element? It's not in the DITA 1.1 spec. Is it new in DITA 1.2?

--- In dita-users@..., "chris_camb" <chris@> wrote:
<coderef href="reports/my_report.txt"/>


Roy <contact@...>
 

Nope, not in the DITA 1.1 programmingDomain.mod, so I assume it has been introduced recently. Sounds useful.

What would be even better is if it could pull in sections of a source-code text file -- maybe using tags-as-comments. e.g.
/* <codeblock id="foobar"> */
public void Foobar() ...
/* </codeblock> */

--- In dita-users@..., "chris_camb" <chris@...> wrote:

Hi,

I found the coderef element in the Open Toolkit, in dtd/technicalContent/dtd/programmingDomain.mod.

I have no idea whether it is part of the 1.2 spec or not I'm afraid -- it works and that's pretty much all I care about :)

Cheers,

Chris

--- In dita-users@..., "Roy" <contact@> wrote:

Chris,
Where did you find this element? It's not in the DITA 1.1 spec. Is it new in DITA 1.2?

--- In dita-users@..., "chris_camb" <chris@> wrote:
<coderef href="reports/my_report.txt"/>


nodyad <dond@...>
 

The coderef element is new with DITA 1.2. Processing for the still-in-development 1.2 spec is supported in the latest DITA OT 1.5 tools (at least for HTML output). Here is a reference to a recent internal draft, where you can learn more about coderef and other new features for 1.2. If you commit to using 1.2 features, be aware that you create a dependency on content interchange with other sharers of your topics, and that things can change in the DTDs before 1.2 becomes fully approved.
http://www.oasis-open.org/committees/download.php/35556/dita1.2-complete-11-December-2009.chm

--
Don Day
Chair, OASIS DITA Technical Committee
IBM Architect, Lightweight DITA Publishing Solutions

--- In dita-users@..., "Roy" <contact@...> wrote:

Nope, not in the DITA 1.1 programmingDomain.mod, so I assume it has been introduced recently. Sounds useful.

What would be even better is if it could pull in sections of a source-code text file -- maybe using tags-as-comments. e.g.
/* <codeblock id="foobar"> */
public void Foobar() ...
/* </codeblock> */

--- In dita-users@..., "chris_camb" <chris@> wrote:

Hi,

I found the coderef element in the Open Toolkit, in dtd/technicalContent/dtd/programmingDomain.mod.

I have no idea whether it is part of the 1.2 spec or not I'm afraid -- it works and that's pretty much all I care about :)

Cheers,

Chris

--- In dita-users@..., "Roy" <contact@> wrote:

Chris,
Where did you find this element? It's not in the DITA 1.1 spec. Is it new in DITA 1.2?

--- In dita-users@..., "chris_camb" <chris@> wrote:
<coderef href="reports/my_report.txt"/>


Stan Doherty
 

Hi Chris --

The new DITA1.2 element indeed works in all recent versions of DITA-OT1.5. I use it extensively in my production topics.

Here's an example.


 


Good luck.
Stan


From: chris_camb
To: dita-users@...
Sent: Thu, January 28, 2010 12:51:49 PM
Subject: [dita-users] Include plain text from external file?

 

Hi,

Is it possible in dita to pull plain text from an external file into a topic.

I have some scripts that generate text reports from our product that I want to include in the doc, something along the following lines:

<p>Here is some sample report output:







Now for something else...



Is there anyway to do this?

Thanks for your help,

Chris



Kim Wickens
 

Thank you! Finding this thread solves some txt content migration that took over 8 hours and needs to be done once or twice a year. This solution is going to cut the time down to minutes.