db_qd_prepare_queryfile_content (public)

 db_qd_prepare_queryfile_content file_content

Defined in packages/acs-bootstrap-installer/tcl/40-db-query-dispatcher-procs.tcl

Prepare raw .xql-file content form xml-parsing via quoting. The result is parsable XML, where "partialquery" is replaced by "fullquery".

Parameters:
file_content (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_files__check_xql_files files__check_xql_files (test acs-tcl) db_qd_prepare_queryfile_content db_qd_prepare_queryfile_content test_files__check_xql_files->db_qd_prepare_queryfile_content apidoc::get_xql_snippet apidoc::get_xql_snippet (private) apidoc::get_xql_snippet->db_qd_prepare_queryfile_content db_qd_internal_load_queries db_qd_internal_load_queries (private) db_qd_internal_load_queries->db_qd_prepare_queryfile_content

Testcases:
files__check_xql_files
Source code:

    set new_file_content ""

    # The lazy way to do it.  partialquery was added for clarification of
    # the query files, but in fact a partialquery and a fullquery are parsed
    # exactly the same.  Doing this saves the bother of having to tweak the
    # rest of the parsing code to handle partialquery.  (OpenACS - DanW)

    regsub -all {(</?)partialquery([ >])} $file_content {\1fullquery\2} rest_of_file_content

    set querytext_open "<querytext>"
    set querytext_close "</querytext>"

    set querytext_open_len [string length $querytext_open]
    set querytext_close_len [string length $querytext_close]

    # We're going to ns_quotehtml the querytext,
    # because XML parsing might choke otherwise
    while {1} {
        set first_querytext_open [string first $querytext_open $rest_of_file_content]
        set first_querytext_close [string first $querytext_close $rest_of_file_content]

        # We have no more querytext to process
        if {$first_querytext_open == -1} {
            append new_file_content $rest_of_file_content
            break
        }

        # append first chunk before the querytext including "<querytext>"
        append new_file_content [string range $rest_of_file_content  0  [expr {$first_querytext_open + $querytext_open_len - 1}]]

        # append quoted querytext
        append new_file_content [ns_quotehtml [string range $rest_of_file_content  $first_querytext_open+$querytext_open_len  $first_querytext_close-1]]

        # append close querytext
        append new_file_content $querytext_close

        # Set up the rest
        set rest_of_file_content [string range $rest_of_file_content  $first_querytext_close+$querytext_close_len  end]
    }

    # db_qd_log QDDebug "new massaged file content: \n $new_file_content \n"

    return $new_file_content
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: