00001 /* cgi2dom.tcl --*/ 00002 /* */ 00003 /* Turns CGI parameters into a DOM document*/ 00004 /* */ 00005 /* Copyright (c) 2000-2002 Zveno Pty Ltd*/ 00006 /* */ 00007 /* See the file "LICENSE" in this distribution for information on usage and*/ 00008 /* redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.*/ 00009 /* */ 00010 /* $Id: cgi2dom.tcl,v 1.4 2003/12/09 04:56:40 balls Exp $*/ 00011 00012 package require dom 2.5 00013 package require xpath 00014 00015 package provide cgi2dom 1.1 00016 00017 namespace cgi2dom { 00018 namespace export createdocument 00019 } 00020 00021 /* cgi2dom::createdocument --*/ 00022 /* */ 00023 /* Construct a DOM document from XPath locations paths.*/ 00024 /* */ 00025 /* Arguments:*/ 00026 /* specs List of XPath location path specifications*/ 00027 /* given as location-path/cdata pairs*/ 00028 /* */ 00029 /* Results:*/ 00030 /* Returns token for new DOM document*/ 00031 00032 ret cgi2dom::createdocument specs ( 00033 type set , type doc [, type dom::, type DOMImplementation , type create] 00034 00035 , type foreach , optional path =value $, type specs , optional 00036 if ={![string match =/* $path] , type continue 00037 00038 , type set , type node [, type dom::, type DOMImplementation , type createNode $, type doc $, type path] 00039 , type if , optional [string =length $value] , optional 00040 switch =[dom::node cget =$node -nodeType] ={ 00041 element ={ 00042 dom::document =createTextNode $node =$value 00043 00044 , type textNode , optional 00045 dom::node =configure $node =-nodeValue $value 00046 00047 , type default , optional 00048 ) 00049 } 00050 } 00051 00052 return $doc 00053 } 00054 00055 00056 00057