Previous: ISL Images and Movies Next: Changing Bundle Properties Table of contents Images Frames Unidata's Integrated Data Viewer > Miscellaneous > IDV Scripting

7.1.6 Writing Text Files

<output> Write output to file
<output
    file="the file to write to"
    template="inline text of 'file:filename' of the template file"
    fromfile="filename to read contents from"
    text="text to output" >

The output tag allows you to generate text files. For example, this could be used to generate html pages, xml files, etc.

The output tag is used in two modes. First it is used to define the output file name, and possibly some templates. Then, the output tag is used to write text output into that file.

You can write text a number of ways:

<isl>
    <output file="output.txt">
        <output text="Some text to write"/>
<!-- Read in the contents of the file. Apply properties to the name and the contents -->
        <output fromfile="${islpath}/file.txt"/>

        <output>Some more text</output>
        <output><![CDATA[
Some text in a CDATA Section. This allows you to have " and < without
escaping the in the xml
        >]]></output>
   </output>

</isl>
output.isl

To be even more complicated the output tag can specify templates to write into. For example, in output1.isl below, we are writing an output1.txt file. Its template has some text and a ${text} macro. The text macro corresponds to the text that gets written into the template:text template. The two following output tags use the template:text template, writing in the values of the thetext attribute.

<isl>
    <output 
        file="output1.txt" 
        template="Here is the text: ${text}"
        template:text="${thetext} ">

        <output template="text" thetext="The text I am writing"/>

        <output template="text" thetext="More text I am writing"/>

   </output>

</isl>
output1.isl
The result of running this is:
Here is the text: The text I am writing More text I am writing 
Here we have two different entry templates, place1 and place2.
<isl>
    <output 
        file="output2.txt" 
        template="Place 1 text: ${place1} Place 2 text: ${place2}"
        template:place1="${value1} -- ${value2} "
        template:place2="  ${someothervalue}  "
        >
        <output template="place1" value1="the value 1" value2="the value 2"/>
        <output template="place2" someothervalue="some value"/>
        <output template="place2" someothervalue="some other value"/>
   </output>

</isl>
output2.isl
The result of running this is:
Place 1 text: the value 1 -- the value 2  Place 2 text:   some value    some other value  
Here we are generating an html file showing the thumbnail images that are generated with links to the actual image and a caption for each thumbnail:
<isl>
    <bundle file="test.xidv"/>
    <pause/>

    <output 
        file="images.html" 
        template="file:template.html"
        template:header="${text}"
        template:imagehtml="file:imagetemplate.html">

        <output template="header" text="Here are the images"/>

        <image file="test1.png">
            <thumbnail file="test1thumb.png" width="25%"/>
        </image>
        <output template="imagehtml"  thumb="test1thumb.png" image="test1.png" caption="Test1"/>

        <image file="test2.png">
            <thumbnail file="test2thumb.png" width="25%"/>
        </image>
        <output template="imagehtml"  thumb="test2thumb.png" image="test2.png" caption="Test2"/>

        <image file="test3.png">
            <thumbnail file="test3thumb.png" width="25%"/>
        </image>
        <output template="imagehtml"  thumb="test3thumb.png" image="test3.png" caption="Test3"/>


     </output>

</isl>
output3.isl
In this example the templates are defined as files: template.html:
<html>
<body>
${header}
${imagehtml}
</body>
and imagetemplate.html.
<a href="${image}"><img border="0" src="${thumb}"></a>
${caption}
<p>

 


Previous: ISL Images and Movies Next: Changing Bundle Properties Table of contents Images Frames Unidata's Integrated Data Viewer > Miscellaneous > IDV Scripting