Xml 比较两个不同列表中的数字
我是XSL编程的新手,我有以下xmlXml 比较两个不同列表中的数字,xml,list,variables,compare,xslt-1.0,Xml,List,Variables,Compare,Xslt 1.0,我是XSL编程的新手,我有以下xml <InRoads productName="OpenRoads Designer CONNECT Edition - 2020 Release 3" productVersion="10.09.00.91" linearUnits="Metric" angularUnits="Degrees" isInternationalFoot="false" co
<InRoads productName="OpenRoads Designer CONNECT Edition - 2020 Release 3" productVersion="10.09.00.91" linearUnits="Metric" angularUnits="Degrees" isInternationalFoot="false" commandName="Geometry Report" >
<GeometryProject name="Default" file="C:\Users\Dennis.Chung\Desktop\GAP RD\280421 new kerb setout\RIA-AEC-MOD-130-310-00-3D-CTRL-ROAD_KERBS.dgn" lastRevisedDate="4/30/2021 21:31:11" >
<HorizontalAlignment name="Unnamed" lastRevisedDate="4/30/2021 06:58:57" area="0.000000000" perimeter="90.347392542" closingDistance="90.347392542" closingDirection="-3.059276459318" closingPrecision="1.000000000" northingClosingError="7.428657504" eastingClosingError="90.041470373" fromFeature="false" >
<HorizontalElements >
<HorizontalLine length="90.347392542" direction="0.082316194272" elementNumber="1" >
<Start northing="5838252.765890940" easting="299195.240389283" elevation="-0.160761453" pointType="POB" type="START" name="" >
<station internalStation="0.000000000" externalStation="0.000000000" externalStationName="" />
</Start>
<End northing="5838260.194548440" easting="299285.281859655" elevation="-0.502611998" pointType="POE" type="END" name="" >
<station internalStation="90.347392542" externalStation="90.347393000" externalStationName="" />
</End>
</HorizontalLine>
</HorizontalElements>
<HorizontalCurveSets >
<CurvesetPoint curveSetID="0" tangentDirectionStart="0.082316194272" pointType="POB" type="START" curveSetStartElement="1" >
<GeometryPoint northing="5838252.765890940" easting="299195.240389283" elevation="-0.160761453" pointType="POB" type="START" name="" >
<station internalStation="0.000000000" externalStation="0.000000000" externalStationName="" />
</GeometryPoint>
</CurvesetPoint>
<CurvesetPoint curveSetID="1" tangentDirectionEnd="0.082316194272" pointType="POE" type="END" curveSetStopElement="1" >
<GeometryPoint northing="5838260.194548440" easting="299285.281859655" elevation="-0.502611998" pointType="POE" type="END" name="" >
<station internalStation="90.347392542" externalStation="90.347393000" externalStationName="" />
</GeometryPoint>
</CurvesetPoint>
</HorizontalCurveSets>
<HorizontalEventPoints >
<HorizontalComputedEventPoints >
<HorizontalEventPoint eventType="stationEvent" radius="0.000000000" grade="0.04251083947571" tangentialDirection="0.082316194272" radialDirection="4.794705174656" >
<GeometryPoint northing="5838252.765890940" easting="299195.240389283" elevation="-0.160761453" pointType="POB" type="START" name="" >
<station internalStation="0.000000000" externalStation="0.000000000" externalStationName="" />
</GeometryPoint>
</HorizontalEventPoint>
<HorizontalEventPoint eventType="stationEvent" radius="0.000000000" grade="0.02781531466054" tangentialDirection="0.082316194272" radialDirection="4.794705174656" >
<GeometryPoint northing="5838254.410356220" easting="299215.172667977" elevation="0.638006868" pointType="POT" type="POT" name="" >
<station internalStation="20.000000000" externalStation="20.000000000" externalStationName="" />
</GeometryPoint>
</HorizontalEventPoint>
<HorizontalEventPoint eventType="stationEvent" radius="0.000000000" grade="-0.01416036580177" tangentialDirection="0.082316194272" radialDirection="4.794705174656" >
<GeometryPoint northing="5838256.054821500" easting="299235.104946671" elevation="0.774556356" pointType="POT" type="POT" name="" >
<station internalStation="40.000000000" externalStation="40.000000000" externalStationName="" />
</GeometryPoint>
</HorizontalEventPoint>
<HorizontalEventPoint eventType="stationEvent" radius="0.000000000" grade="-0.02603425086589" tangentialDirection="0.082316194272" radialDirection="4.794705174656" >
<GeometryPoint northing="5838257.699286780" easting="299255.037225365" elevation="0.287459632" pointType="POT" type="POT" name="" >
<station internalStation="60.000000000" externalStation="60.000000000" externalStationName="" />
</GeometryPoint> </HorizontalEventPoint>
<HorizontalEventPoint eventType="stationEvent" radius="0.000000000" grade="-0.02603425086589" tangentialDirection="0.082316194272" radialDirection="4.794705174656" >
<GeometryPoint northing="5838259.343752050" easting="299274.969504060" elevation="-0.233225385" pointType="POT" type="POT" name="" >
<station internalStation="80.000000000" externalStation="80.000000000" externalStationName="" />
</GeometryPoint>
</HorizontalEventPoint>
<HorizontalEventPoint eventType="stationEvent" radius="0.000000000" grade="-0.02603425086589" tangentialDirection="0.082316194272" radialDirection="4.794705174656" >
<GeometryPoint northing="5838260.194548440" easting="299285.281859655" elevation="-0.502611998" pointType="POE" type="END" name="" >
<station internalStation="90.347392542" externalStation="90.347393000" externalStationName="" />
</GeometryPoint>
</HorizontalEventPoint>
</HorizontalComputedEventPoints>
<HorizontalNormalEventPoints >
<EventPointLists >
<EventPointList name="rr" >
<HorizontalEventPoint eventType="stationEvent" radius="0.000000000" grade="-0.00820233459715" tangentialDirection="0.082316194272" radialDirection="4.794705174656" >
<GeometryPoint northing="5838255.821405970" easting="299232.275757552" elevation="0.806297990" pointType="POT" type="POT" name="" >
<station internalStation="37.161198514" externalStation="37.161199000" externalStationName="" />
</GeometryPoint>
</HorizontalEventPoint>
<HorizontalEventPoint eventType="stationEvent" radius="0.000000000" grade="-0.02603425086589" tangentialDirection="0.082316194272" radialDirection="4.794705174656" >
<GeometryPoint northing="5838258.192304850" easting="299261.013012043" elevation="0.131355925" pointType="POT" type="POT" name="" >
<station internalStation="65.996089830" externalStation="65.996090000" externalStationName="" />
</GeometryPoint> </HorizontalEventPoint>
<HorizontalEventPoint eventType="stationEvent" radius="0.000000000" grade="-0.02603425086589" tangentialDirection="0.082316194272" radialDirection="4.794705174656" >
<GeometryPoint northing="5838258.377685960" easting="299263.259984364" elevation="0.072658932" pointType="POT" type="POT" name="" >
<station internalStation="68.250696395" externalStation="68.250696000" externalStationName="" />
</GeometryPoint>
</HorizontalEventPoint>
</EventPointList>
</EventPointLists>
</HorizontalNormalEventPoints>
</HorizontalEventPoints>
</HorizontalAlignment>
</GeometryProject>
</InRoads>
我可以从HorizontalEventPoints列出电台,并制作类似的东西
0
20
40
60
80
90.347392542
但我不知道如何为这两个列表执行此操作
我所拥有的就是这样的东西
<?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:cif="cif">
<xsl:param name="xslShowHelp" select="cif:xslShowHelp"/>
<xsl:param name="xslRootDirectory" select="cif:xslRootDirectory"/>
<xsl:template match="/">
<xsl:variable name="gridOut"
select="cif:SetGridOut(number(InRoads/@outputGridScaleFactor))"/>
<html>
<head>
<link rel="stylesheet" type="text/css" href="
{$xslRootDirectory}/_Themes/engineer/theme.css"/>
</head>
<body>
<xsl:choose>
<xsl:when test="$xslShowHelp = 'true'">
<xsl:call-template name="StyleSheetHelp"/>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="InRoads">
<center>
<h2 lang="en">CL -  <xsl:value-of select="GeometryProject/HorizontalAlignment/@name"/></h2>
</center>
<xsl:for-each select="GeometryProject">
<table border="1" cellpadding="2" cellspacing="0" width="100%">
<thead style="display:table-header-group">
<tr>
<th lang="en" valign="bottom">Type</th>
<th lang="en" valign="bottom">Chainage</th>
<th lang="en" valign="bottom">Easting</th>
<th lang="en" valign="bottom">Northing</th>
<th lang="en" valign="bottom">Level</th>
<th lang="en" valign="bottom">Bearing</th>
<th lang="en" valign="bottom">Rad/Spiral</th>
<th lang="en" valign="bottom">A.Length</th>
<th lang="en" valign="bottom">D.Angle</th>
</tr>
</thead>
<tbody>
<xsl:for-each select="HorizontalAlignment">
<xsl:for-each select="HorizontalElements">
<xsl:apply-templates select="//HorizontalLine | //HorizontalCircle | //HorizontalSpiral"/>
</xsl:for-each>
</xsl:for-each>
</tbody>
</table>
</xsl:for-each>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</body>
</html>
</xsl:template>
<xsl:template match="HorizontalLine">
<xsl:variable name="startStation" select="Start/station/@internalStation"/>
<xsl:variable name="endStation" select="End/station/@internalStation"/>
<xsl:if test="Start">
<tr>
<xsl:choose>
<xsl:when test="Start/@pointType = 'POB'">
<td align="center" lang="en">IP</td>
</xsl:when>
<xsl:when test="Start/@pointType = 'PI'">
<td align="center" lang="en">IP</td>
</xsl:when>
<xsl:otherwise>
<td align="center"><xsl:value-of select="cif:pointType(string(Start/@pointType))"/></td>
</xsl:otherwise>
</xsl:choose>
<td align="center" style="white-space:nowrap">
<xsl:value-of select="cif:stationFormat(number(Start/station/@externalStation), string(Start/station/@externalStationName))"/>
</td>
<td align="center">
<xsl:value-of select="cif:ordinateFormat(number(Start/@easting))"/>
</td>
<td align="center">
<xsl:value-of select="cif:ordinateFormat(number(Start/@northing))"/>
</td>
<td align="center">
<xsl:value-of select="cif:ordinateFormat(number(Start/@elevation))"/>
</td>
<td align="center">
<xsl:value-of select="cif:directionFormat(number(@direction))"/>
</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</xsl:if>
<xsl:for-each select="../../HorizontalEventPoints">
<xsl:variable name="list1" select="*/HorizontalEventPoint[GeometryPoint/station/@internalStation > $startStation]"/>
<xsl:for-each select="$list1[GeometryPoint/station/@internalStation < $endStation]">
<tr>
<td> </td>
<td align="center" style="white-space:nowrap">
<xsl:value-of select="cif:stationFormat(number(GeometryPoint/station/@externalStation), string(GeometryPoint/station/@externalStationName))"/>
</td>
<td align="center">
<xsl:value-of select="cif:ordinateFormat(number(GeometryPoint/@easting))"/>
</td>
<td align="center">
<xsl:value-of select="cif:ordinateFormat(number(GeometryPoint/@northing))"/>
</td>
<td align="center">
<xsl:value-of select="cif:ordinateFormat(number(GeometryPoint/@elevation))"/>
</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</xsl:for-each>
</xsl:for-each>
<xsl:if test="End[@pointType = 'POE']">
<tr>
<td align="center" lang="en">IP</td>
<td align="right" style="white-space:nowrap">
<xsl:value-of select="cif:stationFormat(number(End/station/@externalStation), string(End/station/@externalStationName))"/>
</td>
<td align="center">
<xsl:value-of select="cif:ordinateFormat(number(End/@easting))"/>
</td>
<td align="center">
<xsl:value-of select="cif:ordinateFormat(number(End/@northing))"/>
</td>
<td align="center">
<xsl:value-of select="cif:ordinateFormat(number(End/@elevation))"/>
</td>
<td align="center">
<xsl:value-of select="cif:directionFormat(number(@direction))"/>
</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</xsl:if>
</xsl:template>
**strong text**</xsl:stylesheet>
CL-#xa0;
类型
链测
东距
北行
水平仪
关系
无线电/螺旋
A.长度
D.角度
知识产权
知识产权
;
;
;
;
;
;
;
;
知识产权
;
;
;
**强文本**
提前感谢您可以通过以下方式轻松生成所显示的输出: XSLT1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template match="/InRoads">
<xsl:for-each select="GeometryProject/HorizontalAlignment/HorizontalEventPoints/HorizontalComputedEventPoints/HorizontalEventPoint | GeometryProject/HorizontalAlignment/HorizontalEventPoints/HorizontalNormalEventPoints/EventPointLists/EventPointList/HorizontalEventPoint">
<xsl:sort select="GeometryPoint/station/@internalStation" data-type="number" order="ascending"/>
<xsl:value-of select="number(GeometryPoint/station/@internalStation)"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
尽管这会增加处理器在整个XML文档中查找所有
HorizontalEventPoint
元素的负担。请编辑您的问题,并将输入和预期输出添加为代码,而不是图片。还要准确地解释什么是“正确的顺序”——瞧,这里应该应用什么逻辑。嗨,迈克尔,我已经重新发布了代码和问题。谢谢,谢谢你的回复。我会把这个给你。regardshi Michael,代码工作完美!谢谢只是出于兴趣,有没有办法从两个列表中检测重复的值?例如,如果两个列表中都有链测长度20,我只想显示其中一个,而不是两个。如果这有帮助,谢谢:。如果没有,发布一个新问题。
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template match="/InRoads">
<xsl:for-each select="GeometryProject/HorizontalAlignment/HorizontalEventPoints/HorizontalComputedEventPoints/HorizontalEventPoint | GeometryProject/HorizontalAlignment/HorizontalEventPoints/HorizontalNormalEventPoints/EventPointLists/EventPointList/HorizontalEventPoint">
<xsl:sort select="GeometryPoint/station/@internalStation" data-type="number" order="ascending"/>
<xsl:value-of select="number(GeometryPoint/station/@internalStation)"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template match="/InRoads">
<xsl:for-each select="//HorizontalEventPoint">
<xsl:sort select="GeometryPoint/station/@internalStation" data-type="number" order="ascending"/>
<xsl:value-of select="number(GeometryPoint/station/@internalStation)"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>