Associate Tefigel processors (subroutines) with tag file contents and
process a tag file (typically, XML or HTML files).
Process a tag file
applying corresponding user-defined Tefigel scripts from
a given directory:
[call] tag_file_process(<tag-file>,<subroutine-dir>,<case-sensitive>)
The built-in subroutine tag_file_process parses the specified
<tag-file> and processes its contents through user-defined
Tefigel scripts contained in directory <subroutine-dir>.
Both <tag-file>
and <subroutine-dir> are specified as <file-reference>'s.
The optional <case-sensitive> flag, which
defaults to 1, can be set to 0 for case-insensitive tag identifiers,
such as HTML tags.
When processing <tag-file>, Tefigel calls subroutines from
<subroutine-dir> according to the scheme described below. Only available
subroutines are called: it is not required to supply all subroutines
described below. Missing subroutines will result in Tefigel silently
ignoring them.
- On entering and exiting the processing of the tag file, Tefigel calls subroutines tag_tree.in and tag_tree.out respectively;
- On entering and exiting the processing of each tag node, Tefigel calls subroutines tag_node.in and tag_node.out respectively;
- On entering and exiting the processing of a tag node (element) identified by tagId, Tefigel calls subroutines tagId.in and tagId.out respectively;
- Input text within one element tagId is processed through subroutines tag_node.tval and tagId.tval;
- XML CDATA sections are processed through subroutine tag_cdata;
- Comment tags are processed through subroutine tag_comment.
Calls to subroutines 2-4 above are issued only if the current tag
matches the tag path search criteria specified by means of variable
TARGET_TAG_PATH, which should be set to a regular expression
according to the tag nodes of interest.
The following variables are automatically set by Tefigel when executing
a tag_file_process request:
- TAG_MACRO_LIB_PATH is set to the path of <subroutine-dir>;
- TAG_PATH is set to the current tag nesting path;
- TAG_CONTENTS is set to the source contents of the current tag;
- TAG_ID is set to the identifier of the current tag;
- Value of each tag attribute tagAttr is assigned to a corresponding variable tp_tagAttr;
- Input text within one element is assigned to variable TAG_TEXT;
- CDATA text within XML CDATA sections is assigned to variable TAG_CDATA_TEXT;
- Each comment tag is assigned to variable TAG_COMMENT_TEXT.
Variables 2-6 in the above list change dynamically with each tag node
being processed. All punctuation marks in tag identifiers are converted
to underscore _.
[Previous chapter]
[Next chapter]
[Back to top]
|