Indeed, I could reproduce. I wasn’t aware of this and it looks like a bug (or a serious limitation) to me.
And the javadoc doesn’t mention anything about not returning xobjects:
/**
* Load the document in the provided revision.
*
* @param document the current document
* @param revision the revision of the document
* @return the {@link XWikiDocument} instance or null if none existing
* @throws XWikiException when failing to load the document revision
*/
XWikiDocument getRevision(XWikiDocument document, String revision) throws XWikiException;
Let’s see what others say, but I’d open a jira issue about it (I couldn’t find one and it’s surprising, I probably haven’t searched well enough).
It is just a programming error.
The documentation states for xwiki.getDocument different results depending on parameter types:
Document getDocument(Document doc, String rev)
Load a specific revision of a document
Document getDocument(String documentReference)
Loads an Document from the database.
Document getDocument(String space, String fullname)
Loads an Document from the database.
Document getDocument(DocumentReference reference)
Loads a Document from the database.
Document getDocument(DocumentReference reference, String revision)
Load a specific revision of a document
My example code uses a String type first parameter and not a DocumentReference.
The result is a new file with the name of the revision string.
This file does not contain any XObjects of course.