多层次的慕尼黑分组

Posted

技术标签:

【中文标题】多层次的慕尼黑分组【英文标题】:Multi-level Muenchian Grouping 【发布时间】:2013-08-03 06:24:28 【问题描述】:

我希望有人可以通过 Muenchian 分组为我指明正确的方向来帮助我。

我有以下形式的数据:

<?xml version="1.0" encoding="UTF-16"?>
<LandXML schemaLocation="http://www.landxml.org/schema/LandXML-1.2 http://www.landxml.org/schema/LandXML-1.2.xsd" version="1.2" date="2013-08-01" time="22:10:15.294-00:00" readOnly="false" language="english">
<Application name="ListechStyleSheet" version="1, 0, 0, 0" manufacturer="LISTech Pty Ltd" manufacturerURL="www.liscad.com">
<Author createdBy="Listech Development Team" />
</Application>
<Project name="LISCAD" desc="OLC ANGLES JULY 2013" />
<Units>
<Metric linearUnit="meter" areaUnit="squareMeter" volumeUnit="cubicMeter" temperatureUnit="celsius" pressureUnit="HPA" />
</Units>
<Survey> 
<ReducedObservation setupID="liscadGM04" azimuth="70.0112" horizDistance="254.696" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00251">
<TargetPoint pntRef="GM03" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="70.0114" horizDistance="254.696" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00251">
<TargetPoint pntRef="GM03" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="70.0113" horizDistance="254.698" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00251">
<TargetPoint pntRef="GM03" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="252.3441" horizDistance="107.081" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00221">
<TargetPoint pntRef="SAW53" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="252.3429" horizDistance="107.081" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00221">
<TargetPoint pntRef="SAW53" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="309.3846" horizDistance="275.373" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00255">
<TargetPoint pntRef="HB402" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="309.3854" horizDistance="275.374" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00255">
<TargetPoint pntRef="HB402" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="320.3917" horizDistance="287.557" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00258">
<TargetPoint pntRef="GM05" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="320.3913" horizDistance="287.557" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00258">
<TargetPoint pntRef="GM05" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="348.0615" horizDistance="108.041" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00222">
<TargetPoint pntRef="SAW144B" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="348.0627" horizDistance="108.041" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00222">
<TargetPoint pntRef="SAW144B" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="35.4956" horizDistance="174.694" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00235">
<TargetPoint pntRef="SAW144" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="35.4955" horizDistance="174.695" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00235">
<TargetPoint pntRef="SAW144" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="70.0114" horizDistance="254.696" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00251">
<TargetPoint pntRef="GM03" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="70.0112" horizDistance="254.697" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00251">
<TargetPoint pntRef="GM03" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="252.3442" horizDistance="107.081" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00221">
<TargetPoint pntRef="SAW53" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="252.3431" horizDistance="107.081" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00221">
<TargetPoint pntRef="SAW53" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="309.3848" horizDistance="275.374" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00255">
<TargetPoint pntRef="HB402" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="309.3855" horizDistance="275.374" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00255">
<TargetPoint pntRef="HB402" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="320.3917" horizDistance="287.556" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00258">
<TargetPoint pntRef="GM05" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="320.3914" horizDistance="287.557" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00258">
<TargetPoint pntRef="GM05" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="348.0613" horizDistance="108.040" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00222">
<TargetPoint pntRef="SAW144B" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="348.0626" horizDistance="108.040" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00222">
<TargetPoint pntRef="SAW144B" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="35.4955" horizDistance="174.695" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00235">
<TargetPoint pntRef="SAW144" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="35.4954" horizDistance="174.695" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00235">
<TargetPoint pntRef="SAW144" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="70.0111" horizDistance="254.697" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00251">
<TargetPoint pntRef="GM03" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="70.0116" horizDistance="254.698" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00251">
<TargetPoint pntRef="GM03" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="252.3441" horizDistance="107.081" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00221">
<TargetPoint pntRef="SAW53" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="252.3433" horizDistance="107.081" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00221">
<TargetPoint pntRef="SAW53" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="309.3848" horizDistance="275.374" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00255">
<TargetPoint pntRef="HB402" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="309.3857" horizDistance="275.374" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00255">
<TargetPoint pntRef="HB402" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="320.3917" horizDistance="287.557" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00258">
<TargetPoint pntRef="GM05" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="320.3911" horizDistance="287.557" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00258">
<TargetPoint pntRef="GM05" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="348.0614" horizDistance="108.041" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00222">
<TargetPoint pntRef="SAW144B" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="348.0627" horizDistance="108.040" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00222">
<TargetPoint pntRef="SAW144B" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="35.4957" horizDistance="174.695" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00235">
<TargetPoint pntRef="SAW144" />
</ReducedObservation>
<ReducedObservation setupID="liscadSAW160" azimuth="329.0304" horizDistance="138.077" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00228">
<TargetPoint pntRef="SAW61" />
</ReducedObservation>
<ReducedObservation setupID="liscadSAW160" azimuth="148.0017" horizDistance="133.943" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00227">
<TargetPoint pntRef="GM06" />
</ReducedObservation>
<ReducedObservation setupID="liscadSAW160" azimuth="148.0026" horizDistance="133.944" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00227">
<TargetPoint pntRef="GM06" />
</ReducedObservation>
<ReducedObservation setupID="liscadSAW160" azimuth="149.1505" horizDistance="249.106" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00250">
<TargetPoint pntRef="SAW59" />
</ReducedObservation>
<ReducedObservation setupID="liscadSAW160" azimuth="149.1451" horizDistance="249.106" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00250">
<TargetPoint pntRef="SAW59" />
</ReducedObservation>
<ReducedObservation setupID="liscadSAW160" azimuth="160.2644" horizDistance="260.353" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00252">
<TargetPoint pntRef="SAW159" />
</ReducedObservation>
<ReducedObservation setupID="liscadSAW160" azimuth="160.2659" horizDistance="260.353" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00252">
<TargetPoint pntRef="SAW159" />
</ReducedObservation>
<ReducedObservation setupID="liscadSAW160" azimuth="244.5944" horizDistance="52.087" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00210">
<TargetPoint pntRef="SAW60" />
</ReducedObservation>

等等……

我正在尝试获得如下分组的输出:

liscadGM04
                pntRef  GM03    Min azimuth=:”70.0109”
                pntRef  GM03    Max azimuth=:”70.0117”
liscadGM04
                pntRef  SAW53  Min azimuth=:”107.3429”
                pntRef  SAW53  Max azimuth=:”107.3442”
liscadGM04
                pntRef  HB402   Min azimuth=:”309.3845”
                pntRef  HB402   Max azimuth=:”309.3857”

                Etc…..
liscadSAW160
                pntRef  SAW61  Min azimuth=:”10.0112”
                pntRef  SAW61  Max azimuth=:”70.0112”

            Etc…

我正在努力获得这样的 XSL 代码嵌套,这是我迄今为止的微弱尝试的摘录:

 <!-- Define a key that uses our element or attribute for grouping -->
<xsl:key name="SetUp" match="LandXML/Survey/ReducedObservation" use="@setupID" />
<!--<xsl:key name="Target" match="LandXML/Survey/ReducedObservation/TargetPoint" use="@pntRef" />-->
<xsl:key name="Target" match="LandXML/Survey/ReducedObservation/TargetPoint" use="concat(@setupID, '|', @pntRef)" />




    <xsl:template match="/">
        <html>
        <!-- Create a node set for the current Row item (.) and the first 
         item in the Key of the Current item  Category. Then we check the count to see is it 1 or 2.. 
         If 1, So we've the same item in the node set; We have a new Category.-->
        <xsl:for-each select="LandXML/Survey/ReducedObservation[count(. | key('SetUp', @setupID)[1]) = 1]">
            <!--<xsl:for-each select="LandXML/Survey/ReducedObservation/TargetPoint[count(. | key('Target', @pntRef)[1]) = 1]">-->
                <!-- Sort by the Category -->
                <xsl:sort select="@setupID" />
                <xsl:sort select="TargetPoint/@pntRef" />
                <xsl:sort select="@azimuth"/>
                <xsl:value-of select='substring(@setupID,7)' />
                <br />

                <!-- Now loop on the items of this Category, We get them from the Key we defined -->
                <xsl:for-each select="key('SetUp', @setupID)">
                <!--<xsl:for-each select="key('Target', @pntRef)">-->
                <!-- Sort by the item Value -->
                    <xsl:if test="position() = 1">
                        Min
                        <xsl:value-of select="TargetPoint/@pntRef"/>:
                        <xsl:value-of select="@azimuth"/><br />
                    </xsl:if>

                    <xsl:if test="position() = last()">
                        Max
                        <xsl:value-of select="TargetPoint/@pntRef"/>:
                        <xsl:value-of select="@azimuth"/>
                    </xsl:if>

              <!--</xsl:for-each>-->
          </xsl:for-each>
          <hr />
          <br />
        </xsl:for-each>

谁能指出我正确的方向?

谢谢

李莫尔斯

【问题讨论】:

【参考方案1】:

你必须使用 Muenchian 方法吗?我告诉我的学生,对于多级分组,我发现基于变量的分组方法更容易编写。

t:\ftemp>type land.xml 
<?xml version="1.0" encoding="UTF-16"?>
<LandXML version="1.2" date="2013-08-01" time="22:10:15.294-00:00" readOnly="false" language="english">
<Application name="ListechStyleSheet" version="1, 0, 0, 0" manufacturer="LISTech Pty Ltd" manufacturerURL="www.liscad.com">
<Author createdBy="Listech Development Team" />
</Application>
<Project name="LISCAD" desc="OLC ANGLES JULY 2013" />
<Units>
<Metric linearUnit="meter" areaUnit="squareMeter" volumeUnit="cubicMeter" temperatureUnit="celsius" pressureUnit="HPA" />
</Units>
<Survey> 
<ReducedObservation setupID="liscadGM04" azimuth="70.0112" horizDistance="254.696" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00251">
<TargetPoint pntRef="GM03" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="70.0114" horizDistance="254.696" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00251">
<TargetPoint pntRef="GM03" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="70.0113" horizDistance="254.698" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00251">
<TargetPoint pntRef="GM03" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="252.3441" horizDistance="107.081" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00221">
<TargetPoint pntRef="SAW53" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="252.3429" horizDistance="107.081" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00221">
<TargetPoint pntRef="SAW53" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="309.3846" horizDistance="275.373" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00255">
<TargetPoint pntRef="HB402" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="309.3854" horizDistance="275.374" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00255">
<TargetPoint pntRef="HB402" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="320.3917" horizDistance="287.557" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00258">
<TargetPoint pntRef="GM05" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="320.3913" horizDistance="287.557" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00258">
<TargetPoint pntRef="GM05" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="348.0615" horizDistance="108.041" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00222">
<TargetPoint pntRef="SAW144B" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="348.0627" horizDistance="108.041" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00222">
<TargetPoint pntRef="SAW144B" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="35.4956" horizDistance="174.694" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00235">
<TargetPoint pntRef="SAW144" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="35.4955" horizDistance="174.695" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00235">
<TargetPoint pntRef="SAW144" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="70.0114" horizDistance="254.696" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00251">
<TargetPoint pntRef="GM03" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="70.0112" horizDistance="254.697" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00251">
<TargetPoint pntRef="GM03" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="252.3442" horizDistance="107.081" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00221">
<TargetPoint pntRef="SAW53" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="252.3431" horizDistance="107.081" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00221">
<TargetPoint pntRef="SAW53" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="309.3848" horizDistance="275.374" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00255">
<TargetPoint pntRef="HB402" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="309.3855" horizDistance="275.374" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00255">
<TargetPoint pntRef="HB402" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="320.3917" horizDistance="287.556" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00258">
<TargetPoint pntRef="GM05" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="320.3914" horizDistance="287.557" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00258">
<TargetPoint pntRef="GM05" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="348.0613" horizDistance="108.040" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00222">
<TargetPoint pntRef="SAW144B" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="348.0626" horizDistance="108.040" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00222">
<TargetPoint pntRef="SAW144B" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="35.4955" horizDistance="174.695" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00235">
<TargetPoint pntRef="SAW144" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="35.4954" horizDistance="174.695" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00235">
<TargetPoint pntRef="SAW144" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="70.0111" horizDistance="254.697" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00251">
<TargetPoint pntRef="GM03" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="70.0116" horizDistance="254.698" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00251">
<TargetPoint pntRef="GM03" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="252.3441" horizDistance="107.081" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00221">
<TargetPoint pntRef="SAW53" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="252.3433" horizDistance="107.081" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00221">
<TargetPoint pntRef="SAW53" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="309.3848" horizDistance="275.374" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00255">
<TargetPoint pntRef="HB402" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="309.3857" horizDistance="275.374" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00255">
<TargetPoint pntRef="HB402" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="320.3917" horizDistance="287.557" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00258">
<TargetPoint pntRef="GM05" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="320.3911" horizDistance="287.557" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00258">
<TargetPoint pntRef="GM05" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="348.0614" horizDistance="108.041" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00222">
<TargetPoint pntRef="SAW144B" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="348.0627" horizDistance="108.040" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00222">
<TargetPoint pntRef="SAW144B" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="35.4957" horizDistance="174.695" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00235">
<TargetPoint pntRef="SAW144" />
</ReducedObservation>
<ReducedObservation setupID="liscadSAW160" azimuth="329.0304" horizDistance="138.077" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00228">
<TargetPoint pntRef="SAW61" />
</ReducedObservation>
<ReducedObservation setupID="liscadSAW160" azimuth="148.0017" horizDistance="133.943" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00227">
<TargetPoint pntRef="GM06" />
</ReducedObservation>
<ReducedObservation setupID="liscadSAW160" azimuth="148.0026" horizDistance="133.944" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00227">
<TargetPoint pntRef="GM06" />
</ReducedObservation>
<ReducedObservation setupID="liscadSAW160" azimuth="149.1505" horizDistance="249.106" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00250">
<TargetPoint pntRef="SAW59" />
</ReducedObservation>
<ReducedObservation setupID="liscadSAW160" azimuth="149.1451" horizDistance="249.106" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00250">
<TargetPoint pntRef="SAW59" />
</ReducedObservation>
<ReducedObservation setupID="liscadSAW160" azimuth="160.2644" horizDistance="260.353" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00252">
<TargetPoint pntRef="SAW159" />
</ReducedObservation>
<ReducedObservation setupID="liscadSAW160" azimuth="160.2659" horizDistance="260.353" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00252">
<TargetPoint pntRef="SAW159" />
</ReducedObservation>
<ReducedObservation setupID="liscadSAW160" azimuth="244.5944" horizDistance="52.087" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00210">
<TargetPoint pntRef="SAW60" />
</ReducedObservation>
</Survey>
</LandXML>
t:\ftemp>call xslt land.xml land.xsl 
liscadGM04
            pntRef  GM03   Min azimuth:70.0111
            pntRef  GM03   Max azimuth:70.0116
liscadGM04
            pntRef  SAW53   Min azimuth:252.3429
            pntRef  SAW53   Max azimuth:252.3442
liscadGM04
            pntRef  HB402   Min azimuth:309.3846
            pntRef  HB402   Max azimuth:309.3857
liscadGM04
            pntRef  GM05   Min azimuth:320.3911
            pntRef  GM05   Max azimuth:320.3917
liscadGM04
            pntRef  SAW144B   Min azimuth:348.0613
            pntRef  SAW144B   Max azimuth:348.0627
liscadGM04
            pntRef  SAW144   Min azimuth:35.4954
            pntRef  SAW144   Max azimuth:35.4957
liscadSAW160
            pntRef  SAW61   Min azimuth:329.0304
            pntRef  SAW61   Max azimuth:329.0304
liscadSAW160
            pntRef  GM06   Min azimuth:148.0017
            pntRef  GM06   Max azimuth:148.0026
liscadSAW160
            pntRef  SAW59   Min azimuth:149.1451
            pntRef  SAW59   Max azimuth:149.1505
liscadSAW160
            pntRef  SAW159   Min azimuth:160.2644
            pntRef  SAW159   Max azimuth:160.2659
liscadSAW160
            pntRef  SAW60   Min azimuth:244.5944
            pntRef  SAW60   Max azimuth:244.5944

t:\ftemp>type land.xsl 
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

<xsl:output method="text"/>

<xsl:template match="/">
  <xsl:variable name="obs" select="LandXML/Survey/ReducedObservation"/>
  <xsl:for-each select="$obs">
    <xsl:if test="generate-id(.)=
                  generate-id($obs[@setupID=current()/@setupID][1])">
      <xsl:variable name="setups" 
                    select="$obs[@setupID=current()/@setupID]"/>
      <xsl:variable name="thisSetup" select="@setupID"/>
      <xsl:for-each select="$setups">
        <xsl:if test="generate-id(.)=
                      generate-id($setups[TargetPoint/@pntRef=
                                          current()/TargetPoint/@pntRef][1])">
          <xsl:value-of select="$thisSetup"/>
          <xsl:text>&#xa;</xsl:text>
          <xsl:variable name="points" 
                        select="$setups[TargetPoint/@pntRef=
                                        current()/TargetPoint/@pntRef]"/>
          <xsl:variable name="azimuths"
                        select="$points/@azimuth"/>
          <xsl:text>            pntRef  </xsl:text>
          <xsl:value-of select="TargetPoint/@pntRef"/>
          <xsl:text>   Min azimuth:</xsl:text>
          <xsl:value-of select="$azimuths[not(.>$azimuths)][1]"/>
          <xsl:text>&#xa;            pntRef  </xsl:text>
          <xsl:value-of select="TargetPoint/@pntRef"/>
          <xsl:text>   Max azimuth:</xsl:text>
          <xsl:value-of select="$azimuths[not(.&lt;$azimuths)][1]"/>
          <xsl:text>&#xa;</xsl:text>
        </xsl:if>
      </xsl:for-each>
    </xsl:if>
  </xsl:for-each>
</xsl:template>

</xsl:stylesheet>
t:\ftemp>rem Done! 

【讨论】:

您好,感谢您的回复。不,我不必使用 Muenchian Grouping。从我一直在阅读的内容来看,这似乎是建议的方式。我试过你的代码。在 Altova XMLSpy 中单步执行它似乎正在工作并生成代码,但是如果我让它运行应用程序挂起,Dreamweaver 中的结果类似。不知道为什么。原始 XML 文件长约 50,000 行,我想知道循环是否效率低下?你能给我解释一下代码吗?我在执行操作时遇到了一些麻烦,谢谢 Lee 您是否创建了一个测试 XML 文件,例如 1,000 行并用它运行它?我怀疑你只是内存不足。当您这样做时,我将创建一个使用密钥的解决方案。基于变量的方法确实会消耗大量内存,而基于键的方法会消耗更少的内存。对于您的特定情况,这可能是最重要的因素。 基于变量的方法建立被分组在变量中的项目的总体,然后通过遍历变量并检查每个成员从变量中找到“文档顺序中的第一个”。将此与基于键的方法(Muenchian)进行对比,其中“文档顺序中的第一个”是通过查找键值来确定的。我告诉我的学生,多级分组可以使用基于键的方法来完成,但是键的确定可能是一个挑战。此外,当您的人口跨越多个输入文档时,不能使用键,但变量可以。 嗨,是的,我已经在一个小型设备上运行过它并且它确实有效,但完整的一个正在苦苦挣扎。感谢您的所有帮助,非常宝贵!【参考方案2】:

好的,试试这个基于密钥的解决方案。事实证明,由于您没有按 setupID 进行分组,因此它只是单级分组,而不是多级分组,因此只需要一个键。当我开始根据您的问题标题进行基于变量的分组时,我没有注意到这一点。它产生与我的基于变量的解决方案相同的结果。它将占用更少的内存,希望更少的内存足以在您的环境中工作。

还请注意,您的最小/最大计算是多余的,我的两个解决方案都建议使用更简单的方法。

t:\ftemp>type land.xml 
<?xml version="1.0" encoding="UTF-16"?>
<LandXML version="1.2" date="2013-08-01" time="22:10:15.294-00:00" readOnly="false" language="english">
<Application name="ListechStyleSheet" version="1, 0, 0, 0" manufacturer="LISTech Pty Ltd" manufacturerURL="www.liscad.com">
<Author createdBy="Listech Development Team" />
</Application>
<Project name="LISCAD" desc="OLC ANGLES JULY 2013" />
<Units>
<Metric linearUnit="meter" areaUnit="squareMeter" volumeUnit="cubicMeter" temperatureUnit="celsius" pressureUnit="HPA" />
</Units>
<Survey> 
<ReducedObservation setupID="liscadGM04" azimuth="70.0112" horizDistance="254.696" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00251">
<TargetPoint pntRef="GM03" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="70.0114" horizDistance="254.696" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00251">
<TargetPoint pntRef="GM03" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="70.0113" horizDistance="254.698" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00251">
<TargetPoint pntRef="GM03" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="252.3441" horizDistance="107.081" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00221">
<TargetPoint pntRef="SAW53" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="252.3429" horizDistance="107.081" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00221">
<TargetPoint pntRef="SAW53" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="309.3846" horizDistance="275.373" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00255">
<TargetPoint pntRef="HB402" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="309.3854" horizDistance="275.374" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00255">
<TargetPoint pntRef="HB402" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="320.3917" horizDistance="287.557" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00258">
<TargetPoint pntRef="GM05" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="320.3913" horizDistance="287.557" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00258">
<TargetPoint pntRef="GM05" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="348.0615" horizDistance="108.041" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00222">
<TargetPoint pntRef="SAW144B" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="348.0627" horizDistance="108.041" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00222">
<TargetPoint pntRef="SAW144B" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="35.4956" horizDistance="174.694" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00235">
<TargetPoint pntRef="SAW144" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="35.4955" horizDistance="174.695" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00235">
<TargetPoint pntRef="SAW144" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="70.0114" horizDistance="254.696" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00251">
<TargetPoint pntRef="GM03" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="70.0112" horizDistance="254.697" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00251">
<TargetPoint pntRef="GM03" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="252.3442" horizDistance="107.081" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00221">
<TargetPoint pntRef="SAW53" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="252.3431" horizDistance="107.081" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00221">
<TargetPoint pntRef="SAW53" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="309.3848" horizDistance="275.374" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00255">
<TargetPoint pntRef="HB402" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="309.3855" horizDistance="275.374" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00255">
<TargetPoint pntRef="HB402" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="320.3917" horizDistance="287.556" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00258">
<TargetPoint pntRef="GM05" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="320.3914" horizDistance="287.557" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00258">
<TargetPoint pntRef="GM05" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="348.0613" horizDistance="108.040" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00222">
<TargetPoint pntRef="SAW144B" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="348.0626" horizDistance="108.040" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00222">
<TargetPoint pntRef="SAW144B" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="35.4955" horizDistance="174.695" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00235">
<TargetPoint pntRef="SAW144" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="35.4954" horizDistance="174.695" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00235">
<TargetPoint pntRef="SAW144" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="70.0111" horizDistance="254.697" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00251">
<TargetPoint pntRef="GM03" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="70.0116" horizDistance="254.698" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00251">
<TargetPoint pntRef="GM03" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="252.3441" horizDistance="107.081" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00221">
<TargetPoint pntRef="SAW53" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="252.3433" horizDistance="107.081" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00221">
<TargetPoint pntRef="SAW53" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="309.3848" horizDistance="275.374" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00255">
<TargetPoint pntRef="HB402" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="309.3857" horizDistance="275.374" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00255">
<TargetPoint pntRef="HB402" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="320.3917" horizDistance="287.557" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00258">
<TargetPoint pntRef="GM05" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="320.3911" horizDistance="287.557" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00258">
<TargetPoint pntRef="GM05" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="348.0614" horizDistance="108.041" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00222">
<TargetPoint pntRef="SAW144B" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="348.0627" horizDistance="108.040" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00222">
<TargetPoint pntRef="SAW144B" />
</ReducedObservation>
<ReducedObservation setupID="liscadGM04" azimuth="35.4957" horizDistance="174.695" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00235">
<TargetPoint pntRef="SAW144" />
</ReducedObservation>
<ReducedObservation setupID="liscadSAW160" azimuth="329.0304" horizDistance="138.077" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00228">
<TargetPoint pntRef="SAW61" />
</ReducedObservation>
<ReducedObservation setupID="liscadSAW160" azimuth="148.0017" horizDistance="133.943" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00227">
<TargetPoint pntRef="GM06" />
</ReducedObservation>
<ReducedObservation setupID="liscadSAW160" azimuth="148.0026" horizDistance="133.944" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00227">
<TargetPoint pntRef="GM06" />
</ReducedObservation>
<ReducedObservation setupID="liscadSAW160" azimuth="149.1505" horizDistance="249.106" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00250">
<TargetPoint pntRef="SAW59" />
</ReducedObservation>
<ReducedObservation setupID="liscadSAW160" azimuth="149.1451" horizDistance="249.106" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00250">
<TargetPoint pntRef="SAW59" />
</ReducedObservation>
<ReducedObservation setupID="liscadSAW160" azimuth="160.2644" horizDistance="260.353" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00252">
<TargetPoint pntRef="SAW159" />
</ReducedObservation>
<ReducedObservation setupID="liscadSAW160" azimuth="160.2659" horizDistance="260.353" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00252">
<TargetPoint pntRef="SAW159" />
</ReducedObservation>
<ReducedObservation setupID="liscadSAW160" azimuth="244.5944" horizDistance="52.087" azimuthType="measured" azimuthAccuracy="0.000300" distanceAccuracy="0.00210">
<TargetPoint pntRef="SAW60" />
</ReducedObservation>
</Survey>
</LandXML>
t:\ftemp>call xslt land.xml land.xsl 
liscadGM04
            pntRef  GM03   Min azimuth:70.0111
            pntRef  GM03   Max azimuth:70.0116
liscadGM04
            pntRef  SAW53   Min azimuth:252.3429
            pntRef  SAW53   Max azimuth:252.3442
liscadGM04
            pntRef  HB402   Min azimuth:309.3846
            pntRef  HB402   Max azimuth:309.3857
liscadGM04
            pntRef  GM05   Min azimuth:320.3911
            pntRef  GM05   Max azimuth:320.3917
liscadGM04
            pntRef  SAW144B   Min azimuth:348.0613
            pntRef  SAW144B   Max azimuth:348.0627
liscadGM04
            pntRef  SAW144   Min azimuth:35.4954
            pntRef  SAW144   Max azimuth:35.4957
liscadSAW160
            pntRef  SAW61   Min azimuth:329.0304
            pntRef  SAW61   Max azimuth:329.0304
liscadSAW160
            pntRef  GM06   Min azimuth:148.0017
            pntRef  GM06   Max azimuth:148.0026
liscadSAW160
            pntRef  SAW59   Min azimuth:149.1451
            pntRef  SAW59   Max azimuth:149.1505
liscadSAW160
            pntRef  SAW159   Min azimuth:160.2644
            pntRef  SAW159   Max azimuth:160.2659
liscadSAW160
            pntRef  SAW60   Min azimuth:244.5944
            pntRef  SAW60   Max azimuth:244.5944

t:\ftemp>type land.xsl 
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

<xsl:output method="text"/>

<xsl:key name="setup-refs" match="ReducedObservation"
         use="concat(@setupID,' ',TargetPoint/@pntRef)"/>

<xsl:template match="/">
  <xsl:for-each select="LandXML/Survey/ReducedObservation
          [generate-id(.)=
           generate-id(key('setup-refs',
                           concat(@setupID,' ',TargetPoint/@pntRef))[1])]">
    <xsl:value-of select="@setupID"/>
    <xsl:text>&#xa;</xsl:text>
    <xsl:variable name="azimuths"
                  select="key('setup-refs',
                              concat(@setupID,' ',TargetPoint/@pntRef))/
                          @azimuth"/>
    <xsl:text>            pntRef  </xsl:text>
    <xsl:value-of select="TargetPoint/@pntRef"/>
    <xsl:text>   Min azimuth:</xsl:text>
    <xsl:value-of select="$azimuths[not(.>$azimuths)][1]"/>
    <xsl:text>&#xa;            pntRef  </xsl:text>
    <xsl:value-of select="TargetPoint/@pntRef"/>
    <xsl:text>   Max azimuth:</xsl:text>
    <xsl:value-of select="$azimuths[not(.&lt;$azimuths)][1]"/>
    <xsl:text>&#xa;</xsl:text>
  </xsl:for-each>
</xsl:template>

</xsl:stylesheet>
t:\ftemp>rem Done! 

【讨论】:

效果很好!谢谢。

以上是关于多层次的慕尼黑分组的主要内容,如果未能解决你的问题,请参考以下文章

如何将枚举与分组和子分组层次结构/嵌套一起使用

XSL muenchian-多层次分组和嵌套

sqlserver 分组查询

json配置文件,如何在打开json文件时,缩进和分组,显示标签的分组层次结构(注意,各分组可折叠或伸展)

多层分组排序问题

如何快速的制作多层分组-数据汇总