DSSSL Library Reference: Part of the Modular DocBook Stylesheet distribution
Prev |  | Next

# include-file

## Name

include-file -- Return the literal content of fileref

## Synopsis

    (include-file fileref)

## Description

Opens and loads fileref with (read-entity); returns the content of fileref as a (literal). Trims the last trailing newline off the file so that "the right thing" happens in asis environments.

## Author

Norman Walsh, <ndw@nwalsh.com>

## Source Code

    (define (include-file fileref)
      ;; Return the literal content of fileref
      (let* ((newline #\U-000D)
    	 (file-content  (read-entity fileref))
    	 (file-length   (string-length file-content))
    	 ;; If the last char is a newline, drop it, otherwise print it...
    	 (content       (if (equal? newline (string-ref file-content
    							(- file-length 1)))
    			    (substring file-content 0 (- file-length 1))
    			    file-content)))
        (literal content)))

Prev | Home | Next
node-list->string | Up | url-encode-char