Multi-level Muenchian Grouping

2019-08-13 01:52发布

问题:

I was hoping someone could assist me by pointing me in the right direction with Muenchian grouping.

I have data in the following form:

<?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>

Etc...

I am trying to get output that groups as follows:

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…

I am struggling to get the XSL code nesting like this, here is an extract of my feeble attempts to date:

 <!-- 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>

Can anyone point me in the right direction?

Thanks

Lee Morse

回答1:

Okay, try this key-based solution. It turns out since you aren't grouping by setupID, it is only a single level of grouping, not a multi-level grouping, and so only one key is needed. I hadn't noticed that when I started with the variable-based grouping based on your question title. It produces the identical result as my variable-based solution. It will occupy less memory, hopefully less enough to work in your environment.

Note also your min/max calculation is overkill and both of my solutions suggest a simpler approach.

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! 


回答2:

Do you have to use the Muenchian method? I tell my students that for multi-level grouping I find the variable-based grouping method to be easier to write.

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!