FILE: C:\Program Files (x86)\Microsoft Office\Office16\AccessWeb\RPT2HTM4.XSL

--
html 4.0 yes //dataroot RTL <xsl:value-of select="RPTML/REPORT[1]/TITLE"/> VBScript fx Option Explicit ' ********************************************************************************** ' ** Functions dynamically generated to evaluate expressions used as a Control Source ' ********************************************************************************** gExpr_ ' ********************************************************************************** ' ** Functions dynamically generated to evaluate running sums ' ********************************************************************************** gRunningSum_ true Detail Detail Global Global ' ********************************************************************************** ' ** Functions dynamically generated to be used for sorting and grouping ' ********************************************************************************** ' This expression was ' There is no formatting on Sorting/Grouping fields Function GroupExpr_(nodelist) Set objCurrNodeT = objCurrNode Set objCurrNode = nodelist.item(0) GroupExpr_ = Set objCurrNode = objCurrNodeT End Function ' ********************************************************************************** ' ** Code staticly copied for expressions to use ' ********************************************************************************** 'variable declaration Dim objCurrNode Dim objCurrNodeT Dim cGroupCount Dim objGroupNodes Set objGroupNodes = Nothing Set objCurrNode = Nothing cGroupCount = 0 Function PrepExpressions(CurrentNode, GroupNodes) CacheCurrentNode CurrentNode CacheGroupNodes GroupNodes PrepExpressions = "" End Function Function CacheCurrentNode(objNodeList) Set objCurrNode = objNodeList.item(0) CacheCurrentNode = "" End Function Function CacheGroupNodes(objNodeList) Set objGroupNodes = objNodeList cGroupCount = objGroupNodes.length CacheGroupNodes = "" End Function Function GroupValue_quarter(strValue) GroupValue_quarter = Left(strValue, 4) & DatePart("q", BuildDateFromStr(strValue, False)) End Function Function GroupValue_week(strValue) GroupValue_week = Left(strValue, 4) & DatePart("ww", BuildDateFromStr(strValue, False)) End Function Function GroupValue_interval(nValue, nInterval) GroupValue_interval = Int(nValue / nInterval) End Function Function Page() Page = 1 End Function Function Pages() Pages = 1 End Function Function ToString(varValue) On Error Resume Next ToString = "" ToString = CStr(varValue) End Function Function ToNumber(varValue) On Error Resume Next ToNumber = 0 ToNumber = CDbl(varValue) End Function Function FormatFromXSL(strRef, strFormat, iNumDecimals, LCID, nType) FormatFromXSL = ToString(Format(GetValue(strRef, nType), strFormat, iNumDecimals, LCID, nType)) End Function Function Format(varValue, strFormat, iNumDecimals, LCID, nType) Dim FormatTemp Dim strTemp If IsDate(varValue) Then Select Case strFormat Case "General Date" FormatTemp = FormatDateTime(varValue, vbGeneralDate) Case "Long Date" FormatTemp = FormatDateTime(varValue, vbLongDate) Case "Medium Date" If GetLocale = 1054 Then ' Special case for thai year FormatTemp = Day(varValue) & "-" & MonthName(Month(varValue), True) & "-" & Right(FormatDateTime(varValue, vbShortDate), 2) Else FormatTemp = Day(varValue) & "-" & MonthName(Month(varValue), True) & "-" & Mid(Year(varValue), 3, 2) End If Case "Short Date" FormatTemp = FormatDateTime(varValue, vbShortDate) Case "Long Time" FormatTemp = FormatDateTime(varValue, vbLongTime) Case "Medium Time" strTemp = FormatDateTime(varValue, vbLongTime) If (IsNumeric(Mid(strTemp, 2, 1))) Then FormatTemp = Mid(strTemp,1,5) & Mid(strTemp, 9) Else FormatTemp = Mid(strTemp,1,4) & Mid(strTemp, 9) End If Case "Short Time" FormatTemp = FormatDateTime(varValue, vbShortTime) Case Else Select Case LCase(strFormat) Case "yyyy", "q", "m", "y", "d", "w", "ww", "h", "n", "s" FormatTemp = DatePart(LCase(strFormat), varValue) Case Else ' This does not currently support custom formats such as dd-mmm-yyyy FormatTemp = FormatDateTime(varValue, vbGeneralDate) End Select End Select ElseIf IsNumeric(varValue) Then Select Case strFormat Case "General Number" FormatTemp = varValue Case "Currency" FormatTemp = FormatCurrencyPerLocale(varValue, iNumDecimals, LCID) Case "Euro" ' This does not really support the Euro format. FormatTemp = FormatCurrencyPerLocale(varValue, iNumDecimals, LCID) Case "Fixed" If IsNumeric(iNumDecimals) Then FormatTemp = FormatNumber(varValue, iNumDecimals, vbTrue, vbUseDefault, vbFalse) Else FormatTemp = FormatNumber(varValue, 2, vbTrue, vbUseDefault, vbFalse) End If Case "Standard" If IsNumeric(iNumDecimals) Then FormatTemp = FormatNumber(varValue, iNumDecimals, vbUseDefault, vbUseDefault, vbTrue) Else FormatTemp = FormatNumber(varValue, 2, vbUseDefault, vbUseDefault, vbTrue) End If Case "Percent" If IsNumeric(iNumDecimals) Then FormatTemp = FormatPercent(varValue, iNumDecimals) Else FormatTemp = FormatPercent(varValue) End If Case "Scientific" Dim nExp Dim nValue If (varValue = 0) Then nExp = 0 Else nExp = Int(Log(Abs(varValue)) / Log(10)) End If nValue = Round(CDbl(varValue)/(10^CDbl(nExp)), 2) If (Sgn(nExp) < 0) Then FormatTemp = FormatNumber(nValue, 2, vbTrue, vbFalse, vbFalse) & "E" & nExp Else FormatTemp = FormatNumber(nValue, 2, vbTrue, vbFalse, vbFalse) & "E+" & nExp End If Case "True/False" If (CBool(varValue)) Then FormatTemp = "True" Else FormatTemp = "False" End If Case "Yes/No" If (CBool(varValue)) Then FormatTemp = "Yes" Else FormatTemp = "No" End If Case "On/Off" If (CBool(varValue)) Then FormatTemp = "On" Else FormatTemp = "Off" End If Case Else ' This is a custom format If nType = 6 Then ' This is a currency FormatTemp = FormatCurrencyPerLocale(varValue, iNumDecimals, LCID) End If End Select End If If IsEmpty(FormatTemp) Then FormatTemp = varValue End If If FHasNoContent(FormatTemp) Then Format = " " Else Format = FormatTemp End If End Function Function FormatCurrencyPerLocale(varValue, iNumDecimals, LCID) Dim CurrentLCID If LCID >< "" Then CurrentLCID = SetLocale(LCID) If IsNumeric(iNumDecimals) Then FormatCurrencyPerLocale = FormatCurrency(varValue, iNumDecimals) Else FormatCurrencyPerLocale = FormatCurrency(varValue) End If If Not IsEmpty(CurrentLCID) Then SetLocale CurrentLCID End Function Function FHasNoContent(objValue) FHasNoContent = True If IsNull(objValue) Then Exit Function If IsEmpty(objValue) Then Exit Function If Not IsObject(objValue) Then If objValue = "" Then Exit Function Else If objValue Is Nothing Then Exit Function End if FHasNoContent = False End Function Function IIf(fCond, varTrue, varFalse) If fCond Then IIf = varTrue Else IIf = varFalse End If End Function Function Nz(varValue, varReplace) If FHasNoContent(varValue) Then Nz = varReplace Else Nz = varValue End If End Function Function Sum(strExpr) Dim nSum, i nSum = 0 Set objCurrNodeT = objCurrNode For i = 0 To cGroupCount - 1 Set objCurrNode = objGroupNodes.item(i) nSum = nSum + ToNumber(Eval(strExpr)) Next Set objCurrNode = objCurrNodeT Sum = nSum End Function Function Count(strExpr) Dim nCount, i If strExpr = "*" Then Count = cGroupCount Exit Function End If Set objCurrNodeT = objCurrNode nCount = 0 For i = 0 To cGroupCount - 1 Set objCurrNode = objGroupNodes.item(i) If Not FHasNoContent(Eval(strExpr)) Then nCount = nCount + 1 End If Next Set objCurrNode = objCurrNodeT Count = nCount End Function Function Avg(strExpr) Dim nSum Dim nCount nSum = Sum(strExpr) nCount = Count(strExpr) If nCount > 0 Then Avg = nSum / nCount Else Avg = nSum End If End Function Function Min(strExpr) Dim varMin, i Dim varTemp Set objCurrNodeT = objCurrNode For i = 0 To cGroupCount - 1 Set objCurrNode = objGroupNodes.item(i) varTemp = Eval(strExpr) If IsEmpty(varMin) Or (varTemp < varMin) Then varMin = varTemp End If Next Set objCurrNode = objCurrNodeT Min = varMin End Function Function Max(strExpr) Dim varMax, i Dim varTemp varMax = Eval(strExpr) Set objCurrNodeT = objCurrNode For i = 0 To cGroupCount - 1 Set objCurrNode = objGroupNodes.item(i) varTemp = Eval(strExpr) If IsEmpty(varMax) Or (varTemp > varMax) Then varMax = varTemp End If Next Set objCurrNode = objCurrNodeT Max = varMax End Function Function GetValue(strRef, nType) ' Set Null as the default return value GetValue = Null ' Return Null if anything goes wrong On Error Resume Next Dim objNode Set objNode = objCurrNode.selectSingleNode(strRef) If (objNode Is Nothing) Or IsNull(objNode) Or IsEmpty(objNode) Or Not IsObject(objNode) Then Exit Function End If Dim CurrentLCID CurrentLCID = SetLocale(1033) Select Case nType Case 2 ' adSmallInt GetValue = CLng(objNode.text) Case 3 ' adInteger GetValue = CLng(objNode.text) Case 20 ' adBigInt GetValue = CLng(objNode.text) Case 17 ' adUnsignedTinyInt GetValue = CLng(objNode.text) Case 18 ' adUnsignedSmallInt GetValue = CLng(objNode.text) Case 19 ' adUnsignedInt GetValue = CLng(objNode.text) Case 21 ' adUnsignedBigInt GetValue = CLng(objNode.text) Case 4 ' adSingle GetValue = CDbl(objNode.text) Case 5 ' adDouble GetValue = CDbl(objNode.text) Case 6 ' adCurrency GetValue = CCur(objNode.text) Case 14 ' adDecimal GetValue = CDbl(objNode.text) Case 131 ' adNumeric GetValue = CDbl(objNode.text) Case 139 ' adVarNumeric GetValue = CDbl(objNode.text) Case 11 ' adBoolean GetValue = CBool(objNode.text) Case 7 ' adDate GetValue = BuildDateFromStr(objNode.text, True) Case 133 ' adDBDate GetValue = BuildDateFromStr(objNode.text, True) Case 134 ' adDBTime GetValue = BuildDateFromStr(objNode.text, True) Case 135 ' adDBTimeStamp GetValue = BuildDateFromStr(objNode.text, True) Case 8 ' adBSTR GetValue = objNode.text Case 120 ' adChar GetValue = objNode.text Case 200 ' adVarChar GetValue = objNode.text Case 201 ' adLongVarChar GetValue = objNode.text Case 130 ' adWChar: GetValue = objNode.text Case 202 ' adVarWChar GetValue = objNode.text Case 203 ' adLongVarWChar GetValue = objNode.text Case -7 ' Special value used to get just the date. GetValue = BuildDateFromStr(objNode.text, False) Case Else GetValue = objNode.text End Select SetLocale CurrentLCID End Function Dim gStaticDate Function StaticDate() If IsEmpty(gStaticDate) Then gStaticDate = GetValue("/*/@generated", -7) StaticDate = gStaticDate End Function Dim gStaticNow Function StaticNow() If IsEmpty(gStaticNow) Then gStaticNow = GetValue("/*/@generated", 7) StaticNow = gStaticNow End Function Function BuildDateFromStr(strDate, fIncludeTime) Dim CurrentLCID CurrentLCID = SetLocale(1033) ' This requires that the Locale be set to en-us (1033). BuildDateFromStr = CDate(Left(strDate,10)) If (fIncludeTime) Then BuildDateFromStr = BuildDateFromStr + CDate(Right(strDate,8)) End If SetLocale CurrentLCID End Function Function ArrayItem(arr, index) If index > UBound(arr) Then ArrayItem = "" Else ArrayItem = arr(index) End If End Function Function HyperlinkPartFromNodeList(nodelist, nPart) If nodelist.length = 0 Then HyperlinkPartFromNodeList = "" Else HyperlinkPartFromNodeList = HyperlinkPartFromString(nodelist.item(0).text, nPart) End If End Function Function HyperlinkPart(strRef, nPart) HyperlinkPart = HyperlinkPartFromString(GetValue(strRef, 200), nPart) End Function Function HyperlinkPartFromString(strHyperlink, nPart) Dim arrParts Dim strHyperlinkPart Dim strAddress, strSubAddress arrParts = Split(strHyperlink, "#") Select Case nPart Case 0 ' acDisplayedValue strHyperlinkPart = ArrayItem(arrParts, 0) If strHyperlinkPart = "" Then strAddress = ArrayItem(arrParts, 1) strSubAddress = ArrayItem(arrParts, 2) If strAddress = "" and strSubAddress = "" Then strHyperlinkPart = "" ElseIf strSubAddress = "" Then strHyperlinkPart = strAddress ElseIf strAddress = "" Then strHyperlinkPart = strSubAddress Else strHyperlinkPart = strAddress & " - " & strSubAddress End If End If Case 1 ' acDisplayText strHyperlinkPart = ArrayItem(arrParts, 0) Case 2 ' acAddress strHyperlinkPart = ArrayItem(arrParts, 1) Case 3 ' acSubAddress strHyperlinkPart = ArrayItem(arrParts, 2) Case 4 ' acScreenTip strHyperlinkPart = ArrayItem(arrParts, 3) Case 5 ' acFullAddress strAddress = ArrayItem(arrParts, 1) strSubAddress = ArrayItem(arrParts, 2) If strAddress = "" and strSubAddress = "" Then strHyperlinkPart = "#" ElseIf strSubAddress = "" Then strHyperlinkPart = strAddress Else strHyperlinkPart = strAddress & "#" & strSubAddress End If End Select HyperlinkPartFromString = strHyperlinkPart End Function ' [] = ' Format: "" ' Decimal Places: "" ' Running Sum: "" Dim Function ExprFromXSL_() ExprFromXSL_ = ToString() End Function ' This function will reset the sums for the section Function ResetRunningSums_() gRunningSum_ = Empty gRunningSum_ = Empty ResetRunningSums_ = "" End Function ' This function will calculate the running sums and expressions for the section Function CalculateExpressions_(CurrentNode, GroupNodes) PrepExpressions CurrentNode, GroupNodes ResetRunningSums_ On Error Resume Next ' [] = gRunningSum_ = gRunningSum_ + ' [] = gExpr_ = Empty gExpr_ = CalculateExpressions_ = "" End Function . { } Cache the current node incase the a field is formatted fx:CacheCurrentNode(.)
GlobalGroup Calculate expressions and running sums fx:CalculateExpressions_Global($GlobalGroup[1], $GlobalGroup) Calculate expressions and running sums fx:CalculateExpressions_(., ) Calculate expressions and running sums fx:CalculateExpressions_Detail(., $GlobalGroup) Prepare for any expressions in the group footer fx:PrepExpressions(., ) Prepare for any expressions in the report or page footer fx:PrepExpressions($GlobalGroup[1], $GlobalGroup)
; POSITION: relative
checkbox ; POSITION: absolute checked ; POSITION: absolute ; POSITION: absolute yes ' ' ; POSITION: absolute [...] ; OVERFLOW: hidden; POSITION: absolute string() string-length($) > 0 href fx:HyperlinkPartFromString($, 5) title fx:HyperlinkPartFromString($, 4) fx:HyperlinkPartFromString($, 0) yes ; OVERFLOW: hidden; POSITION: absolute WIDTH: \n"; return strSort; } function GetGroupKey(nodelist) { return GetGroupKeyFromNode(nodelist.item(0)); } function GetGroupKeyFromNode(objGroup) { var strGroupName = GetGroupNameFromNode(objGroup); var strControlSource = GetGroupUseFromNode(objGroup) return "key('" + strGroupName + "', " + strControlSource + ")"; } function GetGroupForEachStart(nodelist) { // e.g. var objGroup = nodelist.item(0); var prevGroup = GetPreviousGroup(objGroup); var strGroupName = GetGroupName(nodelist); var objGroup = nodelist.item(0); var strRecordSource = ""; if (prevGroup == null) strRecordSource = GetNodeText(objGroup , "../XML-RECORD-SOURCE", ""); else strRecordSource = GetGroupKeyFromNode(prevGroup); var strSelect = strRecordSource + "[count(. | " + GetGroupKeyFromNode(objGroup) + "[1]) = 1]"; var strSort = GetGroupSort(nodelist); return "\n\n" + strSort; } function GetGroupForEachEnd(nodelist) { return ""; } function FixExpression(nodelist, replaceWithExpr) { var objElem = nodelist.item(0); return FixExpressionFromNode(objElem, replaceWithExpr==1); } var rgTotal = new Array("Sum", "Count", "Avg", "Min", "Max"); function FixExpressionFromNode(objElem, fReplaceWithExpr) { var objNodes; var strExpr = objElem.text; // // Check for values that are not expressions such as running sums on controls that are not bound to expressions // var strType = GetNodeText(objElem, "@type", ""); if (strType != "expression") strExpr = "[" + strExpr + "]"; strExpr = FixInnerQuotes(strExpr); // Replace things like left$( with just left( strExpr = strExpr.replace(/\$\(/g, '('); // Replace Date() with StaticDate() strExpr = strExpr.replace(/date\(\)/gi, 'StaticDate()'); // Replace Now() with StaticNow() strExpr = strExpr.replace(/now\(\)/gi, 'StaticNow()'); strExpr = strExpr.replace(/\[page\]/gi, 'Page()'); strExpr = strExpr.replace(/\[pages\]/gi, 'Pages()'); strExpr = strExpr.replace(/is\s+null/gi, '= \"\"'); strExpr = strExpr.replace(/is\s+not\s+null/gi, '<> \"\"'); strExpr = FixNzFunction(strExpr); // // Replace references to other expressions with the dynamically generated expression gExpr_* // if (objElem.selectSingleNode("@id") != null) objNodes = objElem.selectNodes("/RPTML/REPORT[1]/SECTION/REPORT-ITEM[@id != '' and @id != '" + objElem.selectSingleNode("@id").text + "']"); else objNodes = objElem.selectNodes("/RPTML/REPORT[1]/SECTION/REPORT-ITEM[@id != '']"); for (var iNode = 0; iNode < objNodes.length; iNode++) { var objNode = objNodes.item(iNode); var strRunningSum = GetNodeText(objNode, "RUNNING-SUM", ""); strType = GetNodeText(objNode, "ENCODED-CONTROL-SOURCE/@type", ""); if (strType == "expression" || strRunningSum == "over group" || strRunningSum == "over all") { var strNodeID = objNode.selectSingleNode("@id").text; var strSource = ""; if (fReplaceWithExpr) strSource = ((strRunningSum == "over group" || strRunningSum == "over all") ? "gRunningSum_" : "gExpr_") + GenerateVBName(strNodeID); else if (strType == "expression") strSource = objNode.selectSingleNode("ENCODED-CONTROL-SOURCE").text; if (strSource != "") strExpr = strExpr.replace(new RegExp("\\[" + strNodeID + "\\]", "gi"), "(" + strSource + ")"); } } if (!FIsValidExpression(strExpr)) return "\"\""; // // Replace all references to fields with GetValue statement // strExpr = FixGetValue(strExpr); // // Fix up all instances of total functions (sum, count, avg, min, max) // for (var iTotal = 0; iTotal < rgTotal.length; iTotal++) { strExpr = FixAggregate(rgTotal[iTotal], strExpr); } strExpr = FixFormat(strExpr); return strExpr; } function FixFormat(strExpr) { var strFunctionName = "Format"; if (strExpr == null || strExpr.length == 0 || strExpr.match(new RegExp(strFunctionName + "\\(", "i")) == null) return strExpr; var strInFunction = ""; var strAfterFunction = ""; var strBeforeFunction = strExpr.replace(new RegExp("\^(.*)" + strFunctionName + ".*$", "i"), "$1" + strFunctionName + "\("); var strTemp = strExpr.replace(new RegExp("\^.*" + strFunctionName + "\\(", "i"), ""); // find matching parens var len = strTemp.length var count = 1; for(var i=0; i 0) //before the matching paren { if (strTemp.charAt(i) == '(') count++; else if (strTemp.charAt(i) == ')') count--; if (count > 0) strInFunction += strTemp.charAt(i); } else //after the matching paren { strAfterFunction += strTemp.charAt(i); } } var nType = GetDataType(strInFunction); return strBeforeFunction + strInFunction + ", \"\", \"\", " + nType + ")" + strAfterFunction; } function FixAggregate(strFunctionName, strExpr) { if (strExpr == null || strExpr.length == 0 || strExpr.match(new RegExp(strFunctionName + "\\(", "i")) == null) return strExpr; var strInFunction = ""; var strAfterFunction = ""; // var strBeforeFunction = strExpr.replace(new RegExp("\^(.*)" + strFunctionName + ".*$", "i"), "$1" + strFunctionName + "\("); var strBeforeFunction = strExpr.replace(new RegExp("\^(.*)" + strFunctionName + ".*$", "i"), "$1"); var strTemp = strExpr.replace(new RegExp("\^.*" + strFunctionName + "\\(", "i"), ""); // find matching parens var len = strTemp.length var count = 1; for(var i=0; i 0) //before the matching paren { if (strTemp.charAt(i) == '(') count++; else if (strTemp.charAt(i) == ')') count--; if (count > 0) strInFunction += strTemp.charAt(i); } else //after the matching paren { strAfterFunction += strTemp.charAt(i); } } // return strBeforeFunction + "\"" + DoubleQuotes(strInFunction) + "\")" + strAfterFunction; return FixAggregate(strFunctionName, strBeforeFunction) + strFunctionName + "(\"" + DoubleQuotes(strInFunction) + "\")" + FixAggregate(strFunctionName, strAfterFunction); } function FixGetValue(strExpr) { if (strExpr == null || strExpr.length == 0 || strExpr.match(/^[^\[]*\[[^\]]*\]/) == null) return strExpr; var strBeforeFunction = strExpr.replace(/^([^\[]*)\[.*$/, "$1"); var strInFunction = FixupFieldNames(strExpr.replace(/^[^\[]*\[([^\]]*)\].*$/, "$1"), false, false); var strAfterFunction = strExpr.replace(/^[^\[]*\[[^\]]*\](.*)$/, "$1"); var nDataType = GetDataType(strInFunction); strInFunction = FixupFieldNames(strInFunction, true, false); return strBeforeFunction + "GetValue(\"" + strInFunction + "\", " + nDataType + ")" + FixGetValue(strAfterFunction); } function FixNzFunction(strExpr) { if (strExpr == null || strExpr.length == 0 || strExpr.match(/nz\(/gi) == null) return strExpr; var strInFunction = ""; var strAfterFunction = ""; var strBeforeFunction = strExpr.replace(new RegExp("\^(.*)nz.*$", "i"), "$1Nz\("); var strTemp = strExpr.replace(new RegExp("\^.*nz\\(", "i"), ""); // find matching parens var len = strTemp.length var count = 1; for(var i=0; i 0) //before the matching paren { if (strTemp.charAt(i) == '(') count++; else if (strTemp.charAt(i) == ')') count--; if (count > 0) strInFunction += strTemp.charAt(i); } else //after the matching paren { strAfterFunction += strTemp.charAt(i); } } if (strInFunction.match(/,/) == null) return strBeforeFunction + strInFunction + ",\"\")" + strAfterFunction; else return strExpr; } var arrNames = new Array(); function GenerateVBName(strDesiredName) { for (var i=0; i 0) strStyle = strStyle + "; "; strStyle = strStyle + "WIDTH: " + strWidth; strStyle = strStyle + "; HEIGHT: " + strHeight; } return strStyle; } var rgRectAttr = new Array("COLOR", "BACKGROUND-COLOR", "BORDER-WIDTH", "BORDER-COLOR", "BORDER-STYLE", "VISIBILITY", "LEFT", "TOP", "WIDTH", "HEIGHT"); function GetRectangleStyle(nodelist) { return GetItemStyle(nodelist.item(0), rgRectAttr); } var rgImageAttr = new Array("BORDER-WIDTH", "BORDER-COLOR", "BORDER-STYLE", "VISIBILITY", "LEFT", "TOP", "WIDTH", "HEIGHT"); function GetImageStyle(nodelist) { var objElem = nodelist.item(0); var strStyle = GetItemStyle(objElem, rgImageAttr); if (strStyle.length > 0) strStyle = strStyle + "; "; strStyle = strStyle + "BACKGROUND-COLOR: silver"; return strStyle; } var rgBodyAttr = new Array("BACKGROUND-POSITION", "BACKGROUND-REPEAT"); function GetBodyStyle(nodelist) { var objElem = nodelist.item(0); var strStyle = ""; var objImage = objElem.selectSingleNode("/RPTML/REPORT[1]/BACKGROUND-IMAGE") if (objImage != null) { strStyle = "BACKGROUND-IMAGE:url('" + objImage.text + "'); "; strStyle += GetItemStyle(objElem.selectSingleNode("/RPTML/REPORT[1]"), rgBodyAttr); } return strStyle; } function GetItemStyle(objElem, rgAttr) { var cStyles = 0; var strStyle = ""; for (var iAttr in rgAttr) if (SelectSingleNodeNoThrow(objElem, rgAttr[iAttr]) != null) { if (cStyles > 0) strStyle = strStyle + "; "; strStyle = strStyle + rgAttr[iAttr] + ": " + objElem.selectSingleNode(rgAttr[iAttr]).text; cStyles++; } return strStyle; } function GetStyleNode(objElem, strName) { var objWidth = objElem.selectSingleNode(strName); if (objWidth == null) objWidth = objElem.selectSingleNode("/RPTML/REPORT[1]/STYLE[@id='"+objElem.selectSingleNode("CLASS").text+"']/" + strName); return objWidth; } // // Gets the Field name from a table.field name, also makes sure field is correct case // function FixupFieldNames(strField, fConvertSpaces, fRequireDataModel) { var strFieldName = strField.replace(/.*\./, ''); //strip out table in table.field var objFields = gRPTML.selectNodes("/RPTML/REPORT[1]/DATA-MODEL/ROW-SOURCE/FIELD[@id]"); var strTemp = ""; for (var i = 0; i < objFields.length; i++) { strTemp = GetNodeText(objFields.item(i), "@id", ""); if (CaseInsensitiveCompare(strTemp, strFieldName) || CaseInsensitiveCompare(strTemp, strField)) { return (fConvertSpaces ? GetNodeText(objFields.item(i), "@encoded-id", "") : strTemp); } } return (fRequireDataModel ? "" : (fConvertSpaces ? CleanUpFieldName(strFieldName) : strFieldName)); } function CaseInsensitiveCompare(str1, str2) { return str1.toUpperCase() == str2.toUpperCase(); } function CleanUpFieldName(strFieldName) { strTemp = strFieldName.replace(/ /g, '_x0020_'); // spaces in data xml are _x0020_ var lFirstChar = strTemp.charCodeAt(0) - 48; if (lFirstChar > -1 && lFirstChar < 10) { strTemp = "_x003" + lFirstChar + "_" + strTemp.substr(1); // replace initial # } return strTemp; } function DoubleQuotes(strExpr) { return strExpr.replace(/\"/g, "\"\""); } function DoubleSingleQuotes(strExpr) { return strExpr.replace(/\'/g, "''"); } function GetCheckboxCondition(nodelist) { var objElem = nodelist.item(0); var objSource = objElem.selectSingleNode("ENCODED-CONTROL-SOURCE"); if (objSource != null) { if (GetNodeText(objSource, "@type", "") == "expression") { return ConvertControlSourceFromNode(objSource, false); } else { var strSource = FixupFieldNames(objSource.text, true, false); // Always return a boolean return "fx:GetValue('" + strSource + "', 11)"; } } return '0'; } function GetNodeTextFromNodeList(nodelist, strPath, strDefault) { return GetNodeText(nodelist.item(0), strPath, strDefault); } function GetNodeText(objNode, strPath, strDefault) { var objResult; if (objNode != null) objResult = objNode.selectSingleNode(strPath); return (objResult != null ? objResult.text : strDefault); } function FixInnerQuotes(strExpr) { var fNeedMatchSingleQuote = false; var fNeedMatchDoubleQuote = false; var fIsSingleQuote = false; var fIsDoubleQuote = false; var len = strExpr.length; var strTemp = ""; for(var i=0; i\n"; } function StylesheetEnd() { return "\n
"; } function SelectSingleNodeNoThrow(objElm, strXPath) { var objRet; try { objRet = objElm.selectSingleNode(strXPath); } catch(e) { } return objRet; } ]]>
--