自定义 Bentley InRoads 报告 - 带有简单 JavaScript 数学函数的 xsl 文件产生 +/- 0.05 错误,我不知道为啥?
Posted
技术标签:
【中文标题】自定义 Bentley InRoads 报告 - 带有简单 JavaScript 数学函数的 xsl 文件产生 +/- 0.05 错误,我不知道为啥?【英文标题】:Custom Bentley InRoads Report - xsl file with simple JavaScript math function producing +/- 0.05 error and i don't know why?自定义 Bentley InRoads 报告 - 带有简单 JavaScript 数学函数的 xsl 文件产生 +/- 0.05 错误,我不知道为什么? 【发布时间】:2021-10-25 17:10:47 【问题描述】:我试图理解为什么我的自定义 InRoads XSL 报告与我通过手动计算得出的结果相比,没有使用 javascript 生成横向坡度值的结果。有人可以看看这个,看看我错过了什么……拜托?
我正在尝试创建一个报告,发布左侧车道边缘、中心线和右侧车道边缘的高程,我还希望它发布左侧车道和右侧的横向坡度travelway,这些值将按横截面间隔提供。
我已经能够通过添加 JavaScript 函数来自定义评估报告“横截面点”以返回“横向坡度”百分比,但是我创建的这个数学函数总是产生一个始终偏离的结果0.06%,JavaScript“toFixed”方法是否存在舍入问题?我不知道为什么我创建的这个函数会产生一个始终偏离这个数量的结果。有没有人有时间来看看这个?
Cross Section of a road with 12' Travelways
这是我的自定义 JavaScript 函数,(这是我自定义样式表的最后 13 行)
</xsl:template>
<msxsl:script implements-prefix="inr" language="JScript">
<![CDATA[
// This function derives the slope between the CL point
// and the edge of travelway point both of which are at
// existing ground elevation.
function DeterimeSlope(clelev, etwelev, offset)
var elevdiff = clelev - etwelev;
var slope = (Math.abs(elevdiff / offset) * 100).toFixed(2);
return slope + "%";
]]>
</msxsl:script>
</xsl:stylesheet>
包含横截面信息的 raw.xml 文件是“RPT1A0D.xml”,我的自定义样式表是“MDOT_CrossSectionPoints_WTR_working.xsl”。 这是我的自定义报告输出的样子:
我的自定义 InRoads 报告/XSL 样式表:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:inr="http://mycompany.com/mynamespace">
<xsl:include href="../format.xsl"/>
<xsl:param name="xslRootDirectory" select="inr:xslRootDirectory"/>
<!-- Unique cross section surfaces -->
<xsl:variable name="uniqueSurfaceName" select="//CrossSectionSurfaces/CrossSectionSurface[not (@name = preceding::CrossSectionSurface/@name)]/@name"/>
<!-- Variable to hold number of points reported per line. Change this value to suit requirements. -->
<!-- You must also change the table data cells in the showPointData template below to match if you -->
<!-- change this variable to be other than 5. -->
<xsl:variable name="pointsPerLine" select="5"/>
<!-- Cross Section Points Report -->
<xsl:template match="/">
<xsl:variable name="gridOut" select="inr:SetGridOut(number(InRoads/@outputGridScaleFactor))"/>
<html>
<head>
<link rel="stylesheet" type="text/css" href="$xslRootDirectory/_Themes/engineer/theme.css"/>
<!-- Title displayed in browser Title Bar -->
<title lang="en">Cross Section Evaluation Report</title>
</head>
<body>
<xsl:choose>
<xsl:when test="$xslShowHelp = 'true'">
<xsl:call-template name="StyleSheetHelp"/>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="InRoads">
<center>
<!-- Report Title -->
<h2 lang="en">Cross Section Evaluation Report</h2>
<p lang="en">
Report Created:  <xsl:value-of select="inr:date()"/><br />
Time:  <xsl:value-of select="inr:time()"/>
</p>
</center>
<!-- Cross Section Set Data -->
<xsl:for-each select="CrossSectionSet">
<table class="margin" cellpadding="2" >
<tbody>
<tr>
<th align="right" lang="en">Set Name:  </th>
<td align="left" colspan="2"><xsl:value-of select="@setName"/></td>
</tr>
<tr>
<th align="right" lang="en">Alignment Name:  </th>
<td align="left" colspan="2"><xsl:value-of select="@alignmentName"/></td>
</tr>
<tr>
<th align="right" lang="en" style="font-size: 80%">Input Grid Factor:  </th>
<td align="left" style="font-size: 80%"><xsl:value-of select="../@inputGridScaleFactor" /></td>
<td align="right" lang="en" style="font-size: 80%">
<strong>Note:  </strong>All units in this report are in
<xsl:if test="//@linearUnits = 'Imperial'">feet</xsl:if>
<xsl:if test="//@linearUnits = 'Metric'">meters</xsl:if>
unless specified otherwise.
</td>
</tr>
</tbody>
</table>
<hr/>
<!-- Cross Section Point Data -->
<table >
<xsl:for-each select="$uniqueSurfaceName">
<tr>
<th align="left" lang="en">Surface:  </th>
<td align="left" colspan="2"><xsl:value-of select="."/></td>
</tr>
<tr>
<th class="underline" lang="en">Station</th>
<xsl:call-template name="colHead">
<xsl:with-param name="count" select="$pointsPerLine"/>
</xsl:call-template>
</tr>
<xsl:for-each select="//CrossSectionSurface[@name = current()]">
<tr>
<td align="right" nowrap="nowrap">
<br/><xsl:value-of select="inr:stationFormat(number(../../Station/@externalStation), $xslStationFormat,$xslStationPrecision, string(../../Station/@externalStationName))"/>
</td>
<xsl:for-each select="CrossSectionPoints">
<xsl:call-template name="showPointData">
<xsl:with-param name="list" select="CrossSectionPoint"/>
</xsl:call-template>
</xsl:for-each>
</tr>
</xsl:for-each>
<tr><td colspan="3"> </td></tr>
</xsl:for-each>
</table>
</xsl:for-each>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</body>
</html>
</xsl:template>
<xsl:template name="colHead">
<xsl:param name="count"/>
<xsl:if test="$count != 0">
<th class="underline" lang="en">Elevation</th>
<th class="underline" lang="en">Distance</th>
<th class="underline" lang="en">Cross_Slope</th>
<xsl:call-template name="colHead">
<xsl:with-param name="count" select="$count - 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="showPointData">
<xsl:param name="list"/>
<xsl:param name="rest" select="$list[position() > $pointsPerLine]"/>
<xsl:if test="$list[1]">
<td align="right" valign="bottom">
<xsl:value-of select="inr:elevationFormat(number($list[1]/@elevation), $xslElevationPrecision)"/>
</td>
<td align="right" valign="bottom">
<xsl:value-of select="inr:distanceFormat(number($list[1]/@offset), $xslDistancePrecision)"/>
</td>
<td align="right" valign="bottom">
<xsl:value-of select="inr:DeterimeSlope(number($list[2]/@elevation), number($list[1]/@elevation), number($list[1]/@offset))"/>
</td>
</xsl:if>
<xsl:if test="$list[2]">
<td align="right" valign="bottom">
<xsl:value-of select="inr:elevationFormat(number($list[2]/@elevation), $xslElevationPrecision)"/>
</td>
<td align="right" valign="bottom">
<xsl:value-of select="inr:distanceFormat(number($list[2]/@offset), $xslDistancePrecision)"/>
</td>
<td align="right" valign="bottom">
CL no Slope
</td>
</xsl:if>
<xsl:if test="$list[3]">
<td align="right" valign="bottom">
<xsl:value-of select="inr:elevationFormat(number($list[3]/@elevation), $xslElevationPrecision)"/>
</td>
<td align="right" valign="bottom">
<xsl:value-of select="inr:distanceFormat(number($list[3]/@offset), $xslDistancePrecision)"/>
</td>
<td align="right" valign="bottom">
<xsl:value-of select="inr:DeterimeSlope(number($list[2]/@elevation), number($list[3]/@elevation), number($list[3]/@offset))"/>
</td>
</xsl:if>
<xsl:if test="$list[4]">
<td align="right" valign="bottom">
<xsl:value-of select="inr:elevationFormat(number($list[4]/@elevation), $xslElevationPrecision)"/>
</td>
<td align="right" valign="bottom">
<xsl:value-of select="inr:distanceFormat(number($list[4]/@offset), $xslDistancePrecision)"/>
</td>
</xsl:if>
<xsl:if test="$list[5]">
<td align="right" valign="bottom">
<xsl:value-of select="inr:elevationFormat(number($list[5]/@elevation), $xslElevationPrecision)"/>
</td>
<td align="right" valign="bottom">
<xsl:value-of select="inr:distanceFormat(number($list[5]/@offset), $xslDistancePrecision)"/>
</td>
</xsl:if>
<!-- Add or remove here if the number of points per line is different from 5. -->
<xsl:if test="$rest">
<tr>
<td> </td>
<xsl:call-template name="showPointData">
<xsl:with-param name="list" select="$rest"/>
</xsl:call-template>
</tr>
</xsl:if>
</xsl:template>
<xsl:template name="StyleSheetHelp">
<div class="section1">
<h4 lang="en">Notes</h4>
<p class="normal1" lang="en">
You must have created cross sections along your alignment and the cross section set must
have the surfaces and features upon which you wish to report displayed.
</p>
<p class="normal1" lang="en">
You can create the XML data file from the <em>Evaluation > Cross Section > Cross
Section Report</em> command or from the <em>End-Area Volumes</em> leaf of the <em>
Evaluation > Cross Section > Cross Sections</em> command by toggling on the <em>
Create XML Report</em> option on the <em>General</em> leaf.
</p>
<p class="normal1" lang="en">
This report displays five cross section points and their associated data per line before
wrapping to the next line.  You can change the number of points per line by changing
the value in the <code>pointsPerLine</code> variable near the top of the style sheet and by
adding or removing columns in the <code>showPointData</code> template.
</p>
<p class="small" lang="en">
<em>© 2006 Bentley Systems, Inc</em>
</p>
</div>
</xsl:template>
<msxsl:script implements-prefix="inr" language="JScript">
<![CDATA[
// This function derives the slope between the CL point
// and the edge of travelway point both of which are at
// existing ground elevation.
function DeterimeSlope(clelev, etwelev, offset)
var elevdiff = clelev - etwelev;
var slope = (Math.abs(elevdiff / offset) * 100).toFixed(2);
return slope + "%";
]]>
</msxsl:script>
</xsl:stylesheet>
例如,如果您查看报告的最后一列,这是由 12 英尺距离上的前两个高程差得出的坡度。此列中的第一个值为 5.44%,但如果您手动计算 [(616.00 - 615.34) 除以 12] = 0.055 或 5.5%,但我的 StyleSheet 中的 JavaScript 得出 5.44%,我不明白?我做错了什么?
这不仅仅是一个实例,它似乎是所有使用我的 JavaScript 函数的实例,除了第一个实例(第一行第四列),它是 8.91%,但在第一个实例之后其余的都是大约 +/- 0.05% 的折扣。
车站标高距离Cross_Slope标高距离Cross_Slope标高距离Cross_Slope
0+00.00 614.93 -12.00 8.91% 616.00 0.00 CL no Slope 615.34 12.00 5.44% 不正确应该是 5.50%
0+10.00 614.80 -12.00 9.53% 615.95 0.00 CL no Slope 615.30 12.00 5.36% 不正确应该是 5.42%
0+20.00 614.72 -12.00 10.05% 615.92 0.00 CL no Slope 615.24 12.00 5.72% 不正确应该是 5.67%
0+30.00 614.72 -12.00 9.62% 615.88 0.00 CL no Slope 615.21 12.00 5.54% 不正确应该是 5.58%
0+40.00 614.77 -12.00 9.04% 615.85 0.00 CL no Slope 615.19 12.00 5.51% 不正确应该是 5.50%
0+50.00 614.83 -12.00 7.92% 615.78 0.00 CL no Slope 615.13 12.00 5.40% 不正确应该是 5.42%
源 XML 文件:
<?xml version="1.0" encoding="iso-8859-1"?>
<InRoads productName="Bentley InRoads Suite V8i (SELECTseries 2)" productVersion="08.11.07.630" outputGridScaleFactor="1.000000" inputGridScaleFactor="1.000000" linearUnits="Imperial" angularUnits="Degrees" commandName="Cross Section Report">
<CrossSectionSet setID="3" setName="Ex-XSlope-Test" alignmentOID="D97B6FD8-920B-40F1-8F03-6019AEFF8978" alignmentName="Ex-XSlope-Test">
<CrossSectionStations>
<CrossSectionStation leftOffset="-15.000000" rightOffset="15.000000" tangentialDirection="0.848102" radialDirection="2.418899" northing="735891.301345" easting="1692710.841221" elevation="615.997065" longitudinalGrade="-0.003648">
<Station internalStation="0.000050" externalStationName="" externalStation="0.000050"/>
<CrossSectionSurfaces>
<CrossSectionSurface name="LIDAR existing conditions x-sections only" type="0">
<CrossSectionPoints>
<CrossSectionPoint type="CrossSectionPoint" northing="735900.301651" easting="1692702.904343" offset="-11.999981" elevation="614.927381" flag="Begin"/>
<CrossSectionPoint type="ExistingCenterline" northing="735891.301331" easting="1692710.841234" offset="0.000019" elevation="615.997065"/>
<CrossSectionPoint type="CrossSectionPoint" northing="735882.301012" easting="1692718.778125" offset="12.000019" elevation="615.343766" flag="End"/>
</CrossSectionPoints>
</CrossSectionSurface>
</CrossSectionSurfaces>
</CrossSectionStation>
<CrossSectionStation leftOffset="-15.000000" rightOffset="15.000000" tangentialDirection="0.848102" radialDirection="2.418899" northing="735897.915389" easting="1692718.341450" elevation="615.947748" longitudinalGrade="-0.006215">
<Station internalStation="10.000000" externalStationName="" externalStation="10.000000"/>
<CrossSectionSurfaces>
<CrossSectionSurface name="LIDAR existing conditions x-sections only" type="0">
<CrossSectionPoints>
<CrossSectionPoint type="CrossSectionPoint" northing="735906.915708" easting="1692710.404559" offset="-12.000000" elevation="614.804465" flag="Begin"/>
<CrossSectionPoint type="ExistingCenterline" northing="735897.915389" easting="1692718.341450" offset="-0.000000" elevation="615.947748"/>
<CrossSectionPoint type="CrossSectionPoint" northing="735888.915069" easting="1692726.278342" offset="12.000000" elevation="615.303967" flag="End"/>
</CrossSectionPoints>
</CrossSectionSurface>
</CrossSectionSurfaces>
</CrossSectionStation>
<CrossSectionStation leftOffset="-15.000000" rightOffset="15.000000" tangentialDirection="0.848102" radialDirection="2.418899" northing="735904.529465" easting="1692725.841717" elevation="615.924367" longitudinalGrade="-0.003074">
<Station internalStation="20.000000" externalStationName="" externalStation="20.000000"/>
<CrossSectionSurfaces>
<CrossSectionSurface name="LIDAR existing conditions x-sections only" type="0">
<CrossSectionPoints>
<CrossSectionPoint type="CrossSectionPoint" northing="735913.529784" easting="1692717.904825" offset="-12.000000" elevation="614.718334" flag="Begin"/>
<CrossSectionPoint type="ExistingCenterline" northing="735904.529465" easting="1692725.841717" offset="-0.000000" elevation="615.924367"/>
<CrossSectionPoint type="CrossSectionPoint" northing="735895.529145" easting="1692733.778608" offset="12.000000" elevation="615.238414" flag="End"/>
</CrossSectionPoints>
</CrossSectionSurface>
</CrossSectionSurfaces>
</CrossSectionStation>
<CrossSectionStation leftOffset="-15.000000" rightOffset="15.000000" tangentialDirection="0.848102" radialDirection="2.418899" northing="735911.143541" easting="1692733.341983" elevation="615.876978" longitudinalGrade="-0.004556">
<Station internalStation="30.000000" externalStationName="" externalStation="30.000000"/>
<CrossSectionSurfaces>
<CrossSectionSurface name="LIDAR existing conditions x-sections only" type="0">
<CrossSectionPoints>
<CrossSectionPoint type="CrossSectionPoint" northing="735920.143861" easting="1692725.405092" offset="-12.000000" elevation="614.723170" flag="Begin"/>
<CrossSectionPoint type="ExistingCenterline" northing="735911.143541" easting="1692733.341983" offset="-0.000000" elevation="615.876978"/>
<CrossSectionPoint type="CrossSectionPoint" northing="735902.143221" easting="1692741.278875" offset="12.000000" elevation="615.211808" flag="End"/>
</CrossSectionPoints>
</CrossSectionSurface>
</CrossSectionSurfaces>
</CrossSectionStation>
<CrossSectionStation leftOffset="-15.000000" rightOffset="15.000000" tangentialDirection="0.848102" radialDirection="2.418899" northing="735917.757617" easting="1692740.842250" elevation="615.852620" longitudinalGrade="-0.002954">
<Station internalStation="40.000000" externalStationName="" externalStation="40.000000"/>
<CrossSectionSurfaces>
<CrossSectionSurface name="LIDAR existing conditions x-sections only" type="0">
<CrossSectionPoints>
<CrossSectionPoint type="CrossSectionPoint" northing="735926.757937" easting="1692732.905358" offset="-12.000000" elevation="614.767253" flag="Begin"/>
<CrossSectionPoint type="ExistingCenterline" northing="735917.757617" easting="1692740.842250" offset="0.000000" elevation="615.852620"/>
<CrossSectionPoint type="CrossSectionPoint" northing="735908.757297" easting="1692748.779141" offset="12.000000" elevation="615.191458" flag="End"/>
</CrossSectionPoints>
</CrossSectionSurface>
</CrossSectionSurfaces>
</CrossSectionStation>
<CrossSectionStation leftOffset="-15.000000" rightOffset="15.000000" tangentialDirection="0.848102" radialDirection="2.418899" northing="735924.371693" easting="1692748.342516" elevation="615.782411" longitudinalGrade="-0.007228">
<Station internalStation="50.000000" externalStationName="" externalStation="50.000000"/>
<CrossSectionSurfaces>
<CrossSectionSurface name="LIDAR existing conditions x-sections only" type="0">
<CrossSectionPoints>
<CrossSectionPoint type="CrossSectionPoint" northing="735933.372013" easting="1692740.405625" offset="-12.000000" elevation="614.832509" flag="Begin"/>
<CrossSectionPoint type="ExistingCenterline" northing="735924.371693" easting="1692748.342516" offset="0.000000" elevation="615.782411"/>
<CrossSectionPoint type="CrossSectionPoint" northing="735915.371373" easting="1692756.279408" offset="12.000000" elevation="615.134286" flag="End"/>
</CrossSectionPoints>
</CrossSectionSurface>
</CrossSectionSurfaces>
</CrossSectionStation>
<CrossSectionStation leftOffset="-15.000000" rightOffset="15.000000" tangentialDirection="0.848102" radialDirection="2.418899" northing="735930.985769" easting="1692755.842783" elevation="615.764136" longitudinalGrade="-0.002428">
<Station internalStation="60.000000" externalStationName="" externalStation="60.000000"/>
<CrossSectionSurfaces>
<CrossSectionSurface name="LIDAR existing conditions x-sections only" type="0">
<CrossSectionPoints>
<CrossSectionPoint type="CrossSectionPoint" northing="735939.986089" easting="1692747.905891" offset="-12.000000" elevation="614.887480" flag="Begin"/>
<CrossSectionPoint type="ExistingCenterline" northing="735930.985769" easting="1692755.842783" offset="0.000000" elevation="615.764136"/>
<CrossSectionPoint type="CrossSectionPoint" northing="735921.985449" easting="1692763.779674" offset="12.000000" elevation="615.090532" flag="End"/>
</CrossSectionPoints>
</CrossSectionSurface>
</CrossSectionSurfaces>
</CrossSectionStation>
<CrossSectionStation leftOffset="-15.000000" rightOffset="15.000000" tangentialDirection="0.848102" radialDirection="2.418899" northing="735937.599845" easting="1692763.343049" elevation="615.721052" longitudinalGrade="-0.005054">
<Station internalStation="70.000000" externalStationName="" externalStation="70.000000"/>
<CrossSectionSurfaces>
<CrossSectionSurface name="LIDAR existing conditions x-sections only" type="0">
<CrossSectionPoints>
<CrossSectionPoint type="CrossSectionPoint" northing="735946.600165" easting="1692755.406158" offset="-12.000000" elevation="614.867040" flag="Begin"/>
<CrossSectionPoint type="ExistingCenterline" northing="735937.599845" easting="1692763.343049" offset="0.000000" elevation="615.721052"/>
<CrossSectionPoint type="CrossSectionPoint" northing="735928.599525" easting="1692771.279941" offset="12.000000" elevation="615.035679" flag="End"/>
</CrossSectionPoints>
</CrossSectionSurface>
</CrossSectionSurfaces>
</CrossSectionStation>
<CrossSectionStation leftOffset="-15.000000" rightOffset="15.000000" tangentialDirection="0.848102" radialDirection="2.418899" northing="735944.213921" easting="1692770.843316" elevation="615.711238" longitudinalGrade="0.000373">
<Station internalStation="80.000000" externalStationName="" externalStation="80.000000"/>
<CrossSectionSurfaces>
<CrossSectionSurface name="LIDAR existing conditions x-sections only" type="0">
<CrossSectionPoints>
<CrossSectionPoint type="CrossSectionPoint" northing="735953.214241" easting="1692762.906424" offset="-12.000000" elevation="614.853820" flag="Begin"/>
<CrossSectionPoint type="ExistingCenterline" northing="735944.213921" easting="1692770.843316" offset="0.000000" elevation="615.711238"/>
<CrossSectionPoint type="CrossSectionPoint" northing="735935.213602" easting="1692778.780207" offset="12.000000" elevation="615.116099" flag="End"/>
</CrossSectionPoints>
</CrossSectionSurface>
</CrossSectionSurfaces>
</CrossSectionStation>
<CrossSectionStation leftOffset="-15.000000" rightOffset="15.000000" tangentialDirection="0.848102" radialDirection="2.418899" northing="735950.827997" easting="1692778.343582" elevation="615.684421" longitudinalGrade="-0.002888">
<Station internalStation="90.000000" externalStationName="" externalStation="90.000000"/>
<CrossSectionSurfaces>
<CrossSectionSurface name="LIDAR existing conditions x-sections only" type="0">
<CrossSectionPoints>
<CrossSectionPoint type="CrossSectionPoint" northing="735959.828317" easting="1692770.406691" offset="-12.000000" elevation="614.915867" flag="Begin"/>
<CrossSectionPoint type="ExistingCenterline" northing="735950.827997" easting="1692778.343582" offset="0.000000" elevation="615.684421"/>
<CrossSectionPoint type="CrossSectionPoint" northing="735941.827678" easting="1692786.280473" offset="12.000000" elevation="615.071944" flag="End"/>
</CrossSectionPoints>
</CrossSectionSurface>
</CrossSectionSurfaces>
</CrossSectionStation>
<CrossSectionStation leftOffset="-15.000000" rightOffset="15.000000" tangentialDirection="0.848102" radialDirection="2.418899" northing="735957.442041" easting="1692785.843811" elevation="615.632357" longitudinalGrade="-0.006180">
<Station internalStation="99.999950" externalStationName="" externalStation="99.999950"/>
<CrossSectionSurfaces>
<CrossSectionSurface name="LIDAR existing conditions x-sections only" type="0">
<CrossSectionPoints>
<CrossSectionPoint type="CrossSectionPoint" northing="735966.442343" easting="1692777.906935" offset="-11.999977" elevation="614.938506" flag="Begin"/>
<CrossSectionPoint type="ExistingCenterline" northing="735957.442024" easting="1692785.843826" offset="0.000023" elevation="615.632356"/>
<CrossSectionPoint type="CrossSectionPoint" northing="735948.441704" easting="1692793.780717" offset="12.000023" elevation="614.966179" flag="End"/>
</CrossSectionPoints>
</CrossSectionSurface>
</CrossSectionSurfaces>
</CrossSectionStation>
</CrossSectionStations>
</CrossSectionSet>
</InRoads>
【问题讨论】:
如何运行 XSLT,您使用哪种 XSLT 处理器? 并不是说这回答了你的问题,但为什么你甚至需要进入 Javascript 来完成如此琐碎的任务? xsltfiddle.liberty-development.net/gVAkJ4M 如果您在 XSLT 中使用的 JScript 代码未能给出所需结果的系统上从命令行提示符运行cscript -?
,则“Microsoft (R) Windows Script Host”的版本可以它显示?当 JScript 开始支持 toFixed
时,我认为它对于许多版本来说都是错误的。但这已经是很久以前的事了,comp.lang.javascript FAQ 的旧档案曾经说“但是,在 JScript 5.8 及更低版本中存在具有某些值的错误;例如,0.007.toFixed(2)
错误地返回“0.00””。
早上好 Martin,这只是可以针对从 dgn CADD 文件(弧、线等)中的所有元素派生的 XML 文件运行的众多报告(XSL 文件)之一。 )。所有 CADD 元素的创建、元素信息到 XML 的导出和运行 XSL(报告)都是在使用 MSXML 6SP 1 解析器的 CADD 程序中完成的。很抱歉我的回复延迟,但 *** 对我来说是新的。
早上 michael.hor257k,这是个好问题。其他报告(XSL 文件)在运行数值运算时总是使用 JavaScript,所以我也照做了。我不声称自己是一名程序员,所以总是认为最好尝试并遵循而不是冒险离开。我将考虑调整我的样式表以在 XSLT 中完成所有工作。
【参考方案1】:
Michael.hor257k 是对的,我的 XML 和 XSLT 使用第 6 位的输入值产生了正确的结果。正是我手工完成的检查使用了第二位的值,这是我痛苦的全部根源所在。
【讨论】:
以上是关于自定义 Bentley InRoads 报告 - 带有简单 JavaScript 数学函数的 xsl 文件产生 +/- 0.05 错误,我不知道为啥?的主要内容,如果未能解决你的问题,请参考以下文章
Bentley 软件公司宣布创始人 Keith Bentley 即将退休,晋升 Julien Moutte 为首席技术官
Bentley.CivilStorm.V8i.SS5.08.11.05.113+Bentley.HAMMER.V8i.SS6.08.11.06.113
使用 STL 迭代器实现 Bentley-McIlroy 三向分区?