
			 
			
			
			/**METADATA DATA TYPES - taken from Java SDK 1.4
			 * These are used as values in XML attribues ROOT/META/COLUMN/@TYPE.
			 * 
			 * NOTE: Not all of them can be used in XML of course, but
			 *       the full list is provided nevertheless.
			 */
			var TYPE_BIT = -7;
			var TYPE_TINYINT = -6;
			var TYPE_SMALLINT = 5;
			var TYPE_INTEGER = 4;
			var TYPE_BIGINT = -5;
			var TYPE_FLOAT = 6;
			var TYPE_REAL = 7;
			var TYPE_DOUBLE = 8;
			var TYPE_NUMERIC = 2;
			var TYPE_DECIMAL = 3;
			var TYPE_CHAR = 1;
			var TYPE_VARCHAR = 12;
			var TYPE_LONGVARCHAR = -1;
			var TYPE_DATE = 91;
			var TYPE_TIME = 92;
			var TYPE_TIMESTAMP = 93;
			var TYPE_BINARY = -2;
			var TYPE_VARBINARY = -3;
			var TYPE_LONGVARBINARY =  -4;
			var TYPE_NULL = 0;
			var TYPE_OTHER = 1111;
			var TYPE_JAVA_OBJECT = 2000;
			var TYPE_DISTINCT = 2001;
			var TYPE_STRUCT = 2002;
			var TYPE_ARRAY = 2003;
			var TYPE_BLOB = 2004;
			var TYPE_CLOB = 2005;
			var TYPE_REF = 2006;
			var TYPE_DATALINK = 70;
			var TYPE_BOOLEAN = 16;
			 
			 
			/**Processes XSLT stylesheet and sorts the data
			 * by the column name specified as a parameter.
			 *
			 * PARAMETERS:
			 *  [in] pTargetHtmlNode - contains reference to the HTML
			 *       page element which will receive the output of the
			 *       XML transformation (if successful).
			 *
			 *  [in] pXmlDataParam - contains reference to the XML data
			 *       island in the HTML page that is the data to be transformed. 
			 *       This can also be reference to a DOMDocument (refer to MSXML API).
			 *
			 *  [in] pXslDataParam - contains reference to XSL stylesheet document,
			 *       which is to be used to transform XML (as specified in pXmlDataParam)
			 *       into HTML.
			 *
			 *  [in,optional] pSortCol - name of the column to sort the resulted table.
			 *       If NULL is passed, data is not sorted. This value is passed to the
			 *       stylesheet and it's the responsibility of the XSL stylesheet to sort accordingly.
			 *
			 *  [in,optional] pSortOrder - the sort order. If specified, should contain 
			 *       one of the following string values:
			 *    [-] "ascending"
			 *    [-] "descending"
			 *
			 *  [in,optional] pSortDataType - The data-type of the sort column. Possible values are:
			 *    [-] "text"
			 *    [-] "number" 
			 *
			 *
			 * ASSUMPTIONS
			 *  In order for sort to work, the stylesheet MUST include the
			 *  following parameters at the <xsl:stylesheet> level:
			 *   [1] <xsl:param name="SORT_COL"/>
			 *   [2] <xsl:param name="SORT_ORDER"/>
			 *   [3] <xsl:param name="SORT_DATA_TYPE"/>
			 *
			 *  In order for anything to work, the following MUST be
			 *  in included in the stylesheet:
			 *   [4] <xsl:param name="XML_ELEMENT_ID"/>
			 *   [5] <xsl:param name="XSL_ELEMENT_ID"/>	
			 *   [6] <xsl:param name="HTML_TARGET_ID"/>
			 *
			 */
			function paintXSL(pTargetHtmlNode, pXmlDataParam, pXslDataParam, pSortCol, pSortOrder, pSortDataType)
			{	
			
				
				if (pXmlDataParam == null)
				{
					alert("Paint: XML Data Parameter was not specified.");
					return;
				}
			
				if (pXslDataParam == null)
				{
					alert("Paint: XSL Data Parameter was not specified.");
					return;
				}
			
				if (pXmlDataParam.parseError.errorCode > 0)
				{
					alert("XML Parse Error. Line: " + pXmlDataParam.parseError.line + "; Reason: " + pXmlDataParam.parseError.reason);
					return;
				}
				
				if (pXslDataParam.parseError.errorCode > 0)
				{
					alert("XSL Parse Error. Line: " + pXslDataParam.parseError.line + "; Reason: " + pXslDataParam.parseError.reason);
					return;
				}
				
				setXslParams(pTargetHtmlNode, pXmlDataParam, pXslDataParam, pSortCol, pSortOrder, pSortDataType);
				
				try
				{
					//alert("starting transform");
					pTargetHtmlNode.innerHTML = "";
					var tHtml = pXmlDataParam.transformNode(pXslDataParam);
					pTargetHtmlNode.innerHTML = tHtml;
					//alert("finished transform");
				}
				catch (e)
				{
					alert(e.message);
				}
			}
			
			function printXSL(pTargetHtmlNode, pXmlDataParam, pXslDataParam, pSortCol, pSortOrder, pSortDataType, pAppName)
			{
			
				if (pXmlDataParam == null)
				{
					alert("Paint: XML Data Parameter was not specified.");
					return;
				}
			
				if (pXslDataParam == null)
				{
					alert("Paint: XSL Data Parameter was not specified.");
					return;
				}
			
				if (pXmlDataParam.parseError.errorCode > 0)
				{
					alert("XML Parse Error. Line: " + pXmlDataParam.parseError.line + "; Reason: " + pXmlDataParam.parseError.reason);
					return;
				}
			
				if (pXslDataParam.parseError.errorCode > 0)
				{
					alert("XSL Parse Error. Line: " + pXslDataParam.parseError.line + "; Reason: " + pXslDataParam.parseError.reason);
					return;
				}
			
				setXslParams(pTargetHtmlNode, pXmlDataParam, pXslDataParam, pSortCol, pSortOrder, pSortDataType);
			
				try
				{
			
					//alert("starting transform");
					var tHtml = "<font face='verdana'>Results for '" + pAppName + "'</font><br>";
					tHtml = tHtml + pXmlDataParam.transformNode(pXslDataParam);
					tHtml = tHtml + "<p style='page-break-before:always'></p>";
					pTargetHtmlNode.innerHTML = pTargetHtmlNode.innerHTML + tHtml;
					//alert("finished transform");
				}
				catch (e)
				{
					alert(e.message);
				}
			}
			
			/**Sets the sort order parameters in the specified
			 * XSL stylesheet.
			 * 
			 * NOT FOR EXTERNAL USE!
			 */
			function setXslParams(pTargetHtmlNode, pXmlDataParam, pXslDataParam, pSortCol, pSortOrder, pSortDataType)
			{
			
				var sortColNode = null;
				var sortOrderNode = null;
				var xslElementNode = null;
				var xmlElementNode = null;
				var htmlTargetNode = null;
				var sortDataTypeNode = null;
				
				
				if (pXslDataParam == null)
				{
					return;
				}
				
				if (pXmlDataParam == null)
				{
					return;
				}
				
				if (pTargetHtmlNode == null)
				{
					return;
				}
					
			
				xmlElementNode = pXslDataParam.selectSingleNode("//xsl:param[@name='XML_ELEMENT_ID']");
				xslElementNode = pXslDataParam.selectSingleNode("//xsl:param[@name='XSL_ELEMENT_ID']");
				htmlTargetNode = pXslDataParam.selectSingleNode("//xsl:param[@name='HTML_TARGET_ID']");
				
				if (pSortCol != null && pSortCol.length > 0)
				{
					sortColNode = pXslDataParam.selectSingleNode("//xsl:param[@name='SORT_COL']");
				}
			
				if (pSortOrder == null)
				{
					pSortOrder = "ascending";
				}
				sortOrderNode = pXslDataParam.selectSingleNode("//xsl:param[@name='SORT_ORDER']");
				
				if (pSortDataType != null)
				{
					sortDataTypeNode = pXslDataParam.selectSingleNode("//xsl:param[@name='SORT_DATA_TYPE']");
				}
					
			
			
				if (sortColNode != null)
				{
					//alert("setting sort col: " + pSortCol);
					sortColNode.setAttribute("select", "'" + pSortCol + "'");
				}
				
				if (sortOrderNode != null)
				{
					//alert("setting sort order: " + pSortOrder);
					sortOrderNode.setAttribute("select", "'" + pSortOrder + "'");
				}
				
				if (sortDataTypeNode != null)
				{
					//alert("setting sort order datatype: " + pSortDataType);
					sortDataTypeNode.setAttribute("select", "'" + pSortDataType + "'");
				}
				
				if (xslElementNode != null)
				{
					//alert("setting XSL element: " + pXslDataParam.id);
					xslElementNode.setAttribute("select", "'" + pXslDataParam.id + "'");
				}
				
				if (htmlTargetNode != null)
				{
					//alert("setting XSL element: " + pXslDataParam.id);
					htmlTargetNode.setAttribute("select", "'" + pTargetHtmlNode.id + "'");
				}
				
				if (xmlElementNode != null)
				{
					//alert("setting XML element: " + pXmlDataParam.id);
					xmlElementNode.setAttribute("select", "'" + pXmlDataParam.id + "'");
				}
		}
