XML is the most popular platform-independent data expression language which is used to specify various digital content such as web content, multimedia content, bio-chemical data, etc. These various forms of XML data are continuously increasing by a large amount and there is a strong demand on effectively managing such data in digital libraries or archives. The most popular query language to search and retrieve information from such semi-structured XML digital libraries is XQuery. XQuery has a very powerful syntax which allows users to iterate over data items and perform calculation, string matching, and output formatting. However, it lacks a simple and easy way to group and provide summaries on vast amounts of XML data. This grouping and summary function is especially important for large digital archives where users like to obtain an overview or summary of the contents in the digital library. Our work is focused on providing an easy way for grouping in XQuery at the query language level. We provide several cases where this can be considered to be effective. We have also implemented an XQuery processing system with grouping functions based on the eXist Native XML Database.