I have this XML file:
<Elements>
<Element name="A.B.C.x">
<Child>...</Child>
<Child>...</Child>
<Child>...</Child>
</Element>
<Element name="A.B.C.y">
<Child>...</Child>
<Child>...</Child>
</Element>
<Element name="A.D.E.y">
<Child>...</Child>
</Element>
<Element name="A.D.E.z">
<Child>...</Child>
<Child>...</Child>
<Child>...</Child>
</Element>
</Elements>
I need to create XSL to get this result:
<Elements>
<Element name="A.B.C">
<LastToken name="x" childCount="3" />
<LastToken name="y" childCount="2" />
</Element>
<Element name="A.D.E">
<LastToken name="y" childCount="1" />
<LastToken name="z" childCount="3" />
</Element>
</Elements>
I am limited to XSL 1.0 with no extensions and I cannot figure out how to achieve the result.
Any help appreciated.
Thanks in advance.
EDIT: As some answers came in I saw I have to clarify my question/task:
Tokens in name attribute of Element node are not limited to one character. Sample value of ‘name’ attribute could be This.Is.Grouping.Target.AndThisIsGroupChild
Just for fun, a general XSLT 1.0 solution without extensions:
Output: