Reputation: 25
in my xml i have node <action/>
in different places through the document.
Every action node should get the value "U".
I tried this but it did not work:
input xml :
<?xml version="1.0" encoding="UTF-8"?><operationsSchedule>
<id>test</id>
<operationsRequests>
<operationsRequest>
<id>20572152</id>
<segmentRequirements>
<segmentRequirement>
<id>W1</id>
<materialRequirements>
<action/>
<hierarchyScope>default</hierarchyScope>
<materialDefinitionID>510000533</materialDefinitionID>
<materialRequirementID>510000533_0004</materialRequirementID>
<materialRequirementProperties>
<materialRequirementProperty>
<action/>
<dataType>Text</dataType>
<hierarchyScope>default</hierarchyScope>
<materialDefinitionPropertyID>BAG_NR</materialDefinitionPropertyID>
<materialRequirementPropertyID>BAG_NR</materialRequirementPropertyID>
<materialRequirementPropertyValueTexts>
<materialRequirementPropertyValueText>
<languageID>EN</languageID>
<uiid>47275</uiid>
<value><![CDATA[1]]></value>
</materialRequirementPropertyValueText>
</materialRequirementPropertyValueTexts>
<materialUse>Other</materialUse>
<requiredByRequestedSegmentResponse>Other</requiredByRequestedSegmentResponse>
</materialRequirementProperty>
<materialRequirementProperty>
<action/>
<dataType>Text</dataType>
<hierarchyScope>default</hierarchyScope>
<materialDefinitionPropertyID>SCENARIO</materialDefinitionPropertyID>
<materialRequirementPropertyID>SCENARIO</materialRequirementPropertyID>
<materialRequirementPropertyValueTexts>
<materialRequirementPropertyValueText>
<languageID>EN</languageID>
<uiid>47276</uiid>
<value><![CDATA[C]]></value>
</materialRequirementPropertyValueText>
</materialRequirementPropertyValueTexts>
<materialUse>Other</materialUse>
<requiredByRequestedSegmentResponse>Other</requiredByRequestedSegmentResponse>
</materialRequirementProperty>
</materialRequirements>
</segmentRequirement>
</segmentRequirements>
</operationsRequest>
</operationsRequests>
</operationsSchedule>
xsl:
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="action">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:text>U</xsl:text>
</xsl:copy>
</xsl:template>
<xsl:template match="materialRequirements"/>
</xsl:stylesheet>
Upvotes: 0
Views: 574
Reputation: 167561
You need to remove the <xsl:template match="materialRequirements"/>
as that way the materialRequirements
elements are not processed and obviously if the contain any action
elements your template for them is never used.
Upvotes: 1