Automatically Creating Framesets using the NPSOBJ Frame Command

To create a frameset and the required frame content for an exported file you require a layout. In this layout, first the frameset and then every frame is defined using an NPSOBJ instruction in accordance with the following example:

<npsobj frame="frameName" defaulttarget="defaultTarget">
  frameContent
</npsobj>

During export and in the preview this type of NPSOBJ instruction has the effect of creating, besides the output file for the file, a further output file containing the evaluated content of the NPSOBJ-frame tag. The name of this frame content file is made up of the name of the file to be exported, a period, the frameName given in the NPSOBJ tag, and the file-name extension derived from the file name extension. Thus on exporting the document sample, besides the main file sample.html the file sample.frameName.html is generated.

In a layout for creating framesets and frames the main content of the file to be exported is inserted into the content of an NPSOBJ-frame tag, so that it exists as the frame content file. The generated main file, on the other hand, contains only the code enclosing the NPSOBJ-frame tag, thus primarily the code that defines the frameset.

The following example assumes that in the same folder the files sampledoc and the layout frametemplate are found. In frametemplate a two-part frameset and both of the frames associated with it are defined:

<html>
  <head>
  <title><npsobj insertvalue="var" name="title"/></title>
  </head>
  <frameset rows="100,*">
    <npsobj frame="banner">
      <html>
        <head>
        <title>Banner</title>
        </head>
        <body>
          <img src="/banners/sample.tif">
          <!-- Put navigation code here -->
        </body>
      </html>
    </npsobj>
    <npsobj frame="content">
      <html>
        <head>
        <title><npsobj insertvalue="var" name="title"/></title>
        </head>
        <body>    
          <npsobj insertvalue="var" name="body"/>
        </body>
      </html>
    </npsobj>
  </frameset>
</html>

The file sampledoc has the title Sampledoc-Title and contains the following code:

<h1>Sampledoc</h1>
<p>A sample document with an <a href="sample2.html">
internal link</a> and an <a href="http://www.example.com"
target="_blank">external link</a>.</p>

On exporting sampledoc using the layout frametemplate the three output files sampledoc.html, sampledoc.banner.html and sampledoc.content.html are created. If one follows a link to the document sampledoc, then the main file sampledoc.html is displayed.

Sampledoc.html essentially contains the frameset definition:

<html>
  <head>
  <title>Sampledoc Title</title>
  </head>
  <frameset rows="100,*">
    <frame name="banner" src="sampledoc.banner.html">
    <frame name="content" src="sampledoc.content.html">
  </frameset>
</html>

The file sampledoc.banner.html:

<html>
  <head>
  <title>Banner</title>
  </head>
  <body>
    <img src="/banners/sample.tif">
    <!-- Put navigation code here -->
  </body>
</html>

The file sampledoc.content.html:

<html>
  <head>
  <title>Sampledoc Title</title>
  </head>
  <body>    
    <h1>Sampledoc</h1>
    <p>A sample document with an <a href="sample2.html" target="_top">
    internal link</a> and an <a href="http://www.example.com"
    target="_blank">external link</a>.</p>
  </body>
</html>

Please note that you can use the tag attribute defaulttarget in an NPSOBJ-frame instruction to determine the frame in which a linked document is to be displayed. The predefined value for defaulttarget is _top, you thus do not need to use this tag attribute if the links in a frame reference documents that were also exported as framesets. Other tag attributes that you use in NPSOBJ-frame tags are accepted without change in the resulting frame tag.

NPSOBJ-frame tags must not be nested, meaning that they must not contain further NPSOBJ-frame tags.