What is the difference between DocumentReference, PageReference and WikiReference?

The codebase of each says that:

  • DocumentReference
    • Represents a reference to a document (wiki, space and document names)
  • PageReference
    • Represents a reference to a page. Note that nested pages are supported.
  • WikiReference
    • Represents a reference to a wiki (wiki name). This is the topmost reference and it doesn’t have a parent reference.

The definitions of the first two are circular, and leads to the question:

  • What is difference between document and page?

I vaguely understand what WikiReference is, but then it confuses with another class called XWikiDocument. I think XWikiDocument is the visible page, the front end — and its backend is XWikiReference. In that sense, they’re related. Is that understanding correct?

Please help me understand these classes.

Also, if I want to programmatically create wiki pages like:

  • /view/Users/Sarfaraz_Nawaz
  • /view/Users/Idan_Nawaz

Which set of classes do I need to look at? In the above scheme of pages, my current understanding is that Users is a space and Sarfaraz_Nawaz is the page? I’m not trying to create user-profiles but user-pages. By profile, I mean /view/XWiki/Sarfaraz_Nawaz (which I’m already able to create) and for each such profile, I want to create a page /view/Users/Sarfaraz_Nawaz (which allows nested pages) — something like Home page for the user.

I’ve now tried to improve the documentation, see https://github.com/xwiki/xwiki-platform/blob/87350e2075fc2ae5adc81bde305444bf5d1c5cb4/xwiki-platform-core/xwiki-platform-model/xwiki-platform-model-api/src/main/java/org/xwiki/model/reference/PageReference.java#L34-L46

Let me know if this is understandable now!

I think you’re missing this doc:

Nope. It’s the object containing the page content.

There’s no such class :slight_smile:

In what language? Java? Scripting?

Correct! (almost). Then it depends if Sarfaraz_Nawaz is a terminal page or not. See https://www.xwiki.org/xwiki/bin/view/Documentation/UserGuide/Features/ContentOrganization/ :slight_smile:

So to create a page using velocity for ex:

Hope it helps

1 Like