How could I get the last elem of a list??

Hi, I would like to get the last elem of a list but I don’t know which XQuery command to use. I have try with “last” but It doesn’t work. I need to expand the list of elements by adding the last elem by copying It newly at the end of the list and changing some elements of this new element (but this will be other step). This is my query:

declare namespace rp210Elements=“urn:SMPTE:Dictionary”
declare namespace DMS1=“urn:SMPTE:Groups:DMS1”

for $a in input()/DVD/Media/DMS1:ClipFramework
return $a/last()

This doen’t work. Later I have to update the xml document by adding this last element at the end of the list.
I enclose also the xml file. If someone could help me I will be grateful,
DVD4.xml (24.7 KB)

This question is solved. I have try with this expression and it works.

update insert input()/DVD/Media/DMS1:ClipFramework[last()]
into input()/DVD/Media