If you're using distinct-values() then you're using XSLT 2.0
>So basically, I'm trying to:
1) get a list of the unique ID's
2) for each unique id, iterate thru the nodes (in order) that have the id, and format it (this will need to be recursive as there are nested lists as well)
That's basically a description of what xsl:for-each-group does. In XSLT this is usually much easier to use than distinct-values().
<xsl:for-each-group select="/w:document/w:body/w:p" group-by="@w:rsidP">
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference