My XML file looks like
<templates>
<template type="ORC">
<field/>
</template>
<template type="OBR">
<field/>
</template>
<template type="OBX">
<field/>
</template>
<template type="OBX">
<field/>
</template>
<template type="SPM">
<field/>
</template>
<template type="ORC">
<field/>
</template>
<template type="OBR">
<field/>
</template>
<template type="OBX">
<field/>
</template>
<template type="OBX">
<field/>
</template>
<template type="SPM">
<field/>
</template>
</templates>
I would like to group the order details (template/@type='ORC') and convert above sample XML into below format with XSLT 2.0
<templates>
<order-details>
<template type="ORC">
<field/>
</template>
<template type="OBR">
<field/>
</template>
<template type="OBX">
<field/>
</template>
<template type="OBX">
<field/>
</template>
<template type="SPM">
<field/>
</template>
</order-details>
<order-details>
<template type="ORC">
<field/>
</template>
<template type="OBR">
<field/>
</template>
<template type="OBX">
<field/>
</template>
<template type="OBX">
<field/>
</template>
<template type="SPM">
<field/>
</template>
</order-details>
</templates>
@type="ORC"@type="ORC". See Pavel's answer to see how to do this in XSLT 2.0. It's also easy in 1.0; I can add an answer with a 1.0 solution if you'd like.