0

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>
3
  • Can you post an input sample and the output you get and the one you want instead? Commented Aug 1, 2016 at 10:58
  • I added input xml. Commented Aug 1, 2016 at 11:32
  • The input is not well-formed XML; it has no </materialRequirementProperties> closing tag. Commented Aug 1, 2016 at 11:42

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.