При публикации вопроса я пытался очистить код, но закончил слишком много.Элементы point3d не являются родительскими и double дочерними.Они находятся на одном и том же «уровне».
Правильный xml.
<object id="4" class="Polyline7D">
<int name="type">0</int>
<int name="npts">7</int>
<int name="n_passes">1</int>
<double name="power">0.000000</double>
<double name="width">0.000000</double>
<int name="polside">0</int>
<point3d name="pts_p" index="0" x="-119.880476" y="2.012081" z="186.208920"/>
<double name="pts_e_roll" index="0">-179.999761</double>
<double name="pts_e_pitch" index="0">-87.567468</double>
<double name="pts_e_yaw" index="0">9.954604</double>
<double name="pts_tool" index="0">100.000000</double>
<double name="pts_velocity" index="0">100.000000</double>
<point3d name="pts_p" index="1" x="-119.359576" y="-4.849939" z="186.220865"/>
<double name="pts_e_roll" index="1">-179.998973</double>
<double name="pts_e_pitch" index="1">-87.416108</double>
<double name="pts_e_yaw" index="1">14.283145</double>
<double name="pts_tool" index="1">100.000000</double>
<double name="pts_velocity" index="1">30.000000</double>
<point3d name="pts_p" index="2" x="-117.434589" y="-11.072205" z="186.219202"/>
<double name="pts_e_roll" index="2">-179.998973</double>
<double name="pts_e_pitch" index="2">-85.716906</double>
<double name="pts_e_yaw" index="2">22.475456</double>
<double name="pts_tool" index="2">100.000000</double>
<double name="pts_velocity" index="2">40.000000</double>
<point3d name="pts_p" index="3" x="-113.846437" y="-17.133645" z="185.787516"/>
<double name="pts_e_roll" index="3">179.999352</double>
<double name="pts_e_pitch" index="3">-82.368383</double>
<double name="pts_e_yaw" index="3">35.771100</double>
<double name="pts_tool" index="3">0.000000</double>
<double name="pts_velocity" index="3">50.000000</double>
<point3d name="pts_p" index="4" x="-107.697823" y="-22.645023" z="185.765083"/>
<double name="pts_e_roll" index="4">-179.999933</double>
<double name="pts_e_pitch" index="4">-77.401336</double>
<double name="pts_e_yaw" index="4">48.719782</double>
<double name="pts_tool" index="4">0.000000</double>
<double name="pts_velocity" index="4">60.000000</double>
<point3d name="pts_p" index="5" x="-102.213016" y="-25.649298" z="185.527503"/>
<double name="pts_e_roll" index="5">-179.999933</double>
<double name="pts_e_pitch" index="5">-70.869095</double>
<double name="pts_e_yaw" index="5">60.187768</double>
<double name="pts_tool" index="5">0.000000</double>
<double name="pts_velocity" index="5">70.000000</double>
<point3d name="pts_p" index="6" x="-95.371503" y="-27.801876" z="185.264439"/>
<double name="pts_e_roll" index="6">-179.999933</double>
<double name="pts_e_pitch" index="6">-58.863558</double>
<double name="pts_e_yaw" index="6">70.870345</double>
<double name="pts_tool" index="6">100.000000</double>
<double name="pts_velocity" index="6">80.000000</double>
</object>
То, что идентифицирует точки, это индекс = #.Таким образом, я подтолкнул вас к ошибке (извините, возможно, ошибка) Но мне удалось найти решение на основе индекса
шаблон на xsl:
<xsl:template match="object[@class='Polyline7D']">
<xsl:variable name="type" select="int[@name='type']"/>
<xsl:variable name="power" select="double[@name='power']"/>
<xsl:variable name="npasses" select="int[@name='n_passes']"/>
<xsl:variable name="width" select="double[@name='width']"/>
<xsl:variable name="velocity" select="double[@name='pts_velocity']"/>
<xsl:variable name="toolpoint" select="double[@name='pts_tool']"/>
<xsl:for-each select="point3d[@name='pts_p']">
<xsl:variable name="i" select="@index"/>
<xsl:variable name="a" select="@index - 1"/>
<xsl:if test="$i = 0">
<xsl:if test="$toolpoint[@index = $i] = 0">
<xsl:text> SetDo RoughMotorOn, 0;
</xsl:text>
</xsl:if>
<xsl:if test="$toolpoint[@index = $i] = 100">
<xsl:text> SetDo RoughMotorOn, 1;
</xsl:text>
</xsl:if>
</xsl:if>
<xsl:if test="$i != 0">
<xsl:if test="$toolpoint[@index = $i] != $toolpoint[@index = $a]">
<xsl:if test="$toolpoint[@index = $i] = 0">
<xsl:text> SetDo RoughMotorOn, 0;
</xsl:text>
</xsl:if>
<xsl:if test="$toolpoint[@index = $i] = 100">
<xsl:text> SetDo RoughMotorOn, 1;
</xsl:text>
</xsl:if>
</xsl:if>
</xsl:if>
<xsl:text> MoveL [</xsl:text>
<xsl:text>[</xsl:text>
<xsl:value-of select="format-number(@x, '0.000000')"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="format-number(@y, '0.000000')"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="format-number(@z, '0.000000')"/>
<xsl:text>],</xsl:text>
<!-- More elements to complete "MoveL" line
but irrelevant to question
-->
</xsl:for-each>
</xsl:template>
И результат:
SetDo RoughMotorOn, 1;
MoveL [[-119.880476,2.012081,186.208920], ....
MoveL [[-119.359576,-4.849939,186.220865], ....
MoveL [[-117.434589,-11.072205,186.219202], ....
SetDo RoughMotorOn, 0;
MoveL [[-113.846437,-17.133645,185.787516], ....
MoveL [[-107.697823,-22.645023,185.765083], ....
MoveL [[-102.213016,-25.649298,185.527503], ....
SetDo RoughMotorOn, 1;
MoveL [[-95.371503,-27.801876,185.264439], ....
Я думаю, теперь все ясно и работает!
Еще раз прошу прощения за то, что вы ошиблись.И спасибо за ваши быстрые ответы.