XSLT filter and choose first element



I have an xml file like:



<work>
<job name="dummy">
<task>template</task>
<user>template</user>
</job>
<job name="unit1">
<task>abc</task>
<user>def</user>
</job>
<job name="unit2">
<task>abc1</task>
<user>xyz</user>
</job>
</work>


I want to remove all the elements except the first job whose name is not "dummy". Some files may or may not contain jobs with name "dummy". So in the end the tranformed file should look like,



<work>
<job name="unit1">
<task>abc</task>
<user>def</user>
</job>
</work>


How do I filter and select in xslt?


No comments:

Post a Comment