Вопрос: Nested for-each не работает с уровня XML PLAN_ENROLLED_INFO, с PLAN_ENROLLED_INFO - элементы XML этого уровня дублируются вместо новых значений из цикла. На уровне IO_DEVICE_INFO_ITEM элементы XML цикличны, но с элементами внутреннего цикла дублируются
XML:
<IO_DEVICE_INFO_ITEM>
<ESN>260730008835603</ESN>
<CARRIER_NAME>ATT</CARRIER_NAME>
<SERVICE_END_DATE>2020-10-10T00:00:00.000-04:00</SERVICE_END_DATE>
<PLAN_ENROLLED_INFO>
<PLAN_ENROLLED_INFO_ITEM>
<PLANID>5803843</PLANID>
<PLAN_NAME>CES Data Club Annual Service - B2B</PLAN_NAME>
<PLAN_DESCRIPTION>CES $50 Data Club Annual - AUTO REFILL</PLAN_DESCRIPTION>
<PLAN_TYPE>DATA_CLUB</PLAN_TYPE>
</PLAN_ENROLLED_INFO_ITEM>
<PLAN_ENROLLED_INFO_ITEM>
<PLANID>5803842</PLANID>
<PLAN_NAME>CES Data Club LowBalance 1GB - B2B</PLAN_NAME>
<PLAN_DESCRIPTION>CES $10 Data Club Low Balance</PLAN_DESCRIPTION>
<PLAN_TYPE>DATA_CLUB_LOWBALANCE</PLAN_TYPE>
<AUTO_REFILL_MAX_LIMIT>999</AUTO_REFILL_MAX_LIMIT>
</PLAN_ENROLLED_INFO_ITEM>
</PLAN_ENROLLED_INFO>
</IO_DEVICE_INFO_ITEM>
<IO_DEVICE_INFO_ITEM>
<ESN>260730008789875</ESN>
<SERVICE_END_DATE>2019-11-08T00:00:00.000-05:00</SERVICE_END_DATE>
<PLAN_ENROLLED_INFO>
<PLAN_ENROLLED_INFO_ITEM>
<PLANID>5804297</PLANID>
<PLAN_NAME>UNLIMITED 20 GB ILD 30-DAY PLAN CES- B2B</PLAN_NAME>
<PLAN_DESCRIPTION> Unlimited Talk, Text and Data (20 GB Data @ 4G speed) + ILD /30 Days AUTO REFILL</PLAN_DESCRIPTION>
<PLAN_TYPE>BASE_PLAN</PLAN_TYPE>
<NEXT_CHARGE_DATE>2019-11-08T12:06:08.000-05:00</NEXT_CHARGE_DATE>
</PLAN_ENROLLED_INFO_ITEM>
<PLAN_ENROLLED_INFO_ITEM>
<PLANID>5804312</PLANID>
<PLAN_NAME> $10 ILD B2B</PLAN_NAME>
<PLAN_DESCRIPTION> $10 ILD - Auto Refill on Low Balance</PLAN_DESCRIPTION>
<PLAN_TYPE>ILD</PLAN_TYPE>
<BANK_ACCNT_NO xsi:nil="true"/>
</PLAN_ENROLLED_INFO_ITEM>
</PLAN_ENROLLED_INFO>
</IO_DEVICE_INFO_ITEM>
XSLT-преобразование с вложенным для каждого, нужна помощь ниже
<xsl:for-each select="/ns0:OutputParameters/ns0:IO_DEVICE_INFO/ns0:IO_DEVICE_INFO_ITEM">
<tns:accountDevice>
<tns:esn>
<xsl:value-of select="ns0:ESN"/>
</tns:esn>
<tns:enrollments>
<xsl:for-each select="ns0:PLAN_ENROLLED_INFO/ns0:PLAN_ENROLLED_INFO_ITEM">
<tns:enrollment>
<tns:enrolledPlanId>
<xsl:value-of select="/ns0:OutputParameters/ns0:IO_DEVICE_INFO/ns0:IO_DEVICE_INFO_ITEM/ns0:PLAN_ENROLLED_INFO/ns0:PLAN_ENROLLED_INFO_ITEM/ns0:PLANID"/>
</tns:enrolledPlanId>
<tns:type>AUTO_REFILL</tns:type>
<tns:name>DATA_LOW_BALANCE</tns:name>
<tns:characteristics>
<tns:characteristic>
<tns:name>PLAN_NAME</tns:name>
<tns:value>
<xsl:value-of select="/ns0:OutputParameters/ns0:IO_DEVICE_INFO/ns0:IO_DEVICE_INFO_ITEM/ns0:PLAN_ENROLLED_INFO/ns0:PLAN_ENROLLED_INFO_ITEM/ns0:PLAN_NAME"/>
</tns:value>
</tns:characteristics>
</tns:enrollment>
</xsl:for-each>
</tns:enrollments>
</tns:accountDevice>
</xsl:for-each>