On Nov 10, 2010, at 4:16 PM, Mark Wallace wrote:
On 11/10/2010 9:42 AM, Vincent Massol wrote:
Hi Mark,
On Nov 10, 2010, at 3:24 PM, Mark Wallace wrote:
On 11/5/2010 1:15 PM, Vincent Massol wrote:
. . .
A different example of what I'm trying to do, using a syntax flavor closer to the XWiki 2.1 syntax, might be:
Berlin is located in [[Germany>>doc:Main.Germany||property="locatedIn"]]
This is a link. If you don't need a link you should instead write:
Berlin is located in (% property="locatedIn" %)Germany(%%)
or
Berlin is located in (% property="locatedIn" %)[[Germany>>Main.Germany]](%%)
Note: This is going to generate a FormatBlock in XDOM, which you can access with Transformation and Macros.
This is something I do from Java? Can you point me to where to get started? I've spent a good bit of time with the source code and xwiki.org documentation, but have not yet been able to determine where to get started. :-(
There are several places where you can interact with the document's DOM (we call it the XDOM): - in Rendering Transformations - in scripts written in pages since you can get the XDOM using doc.getXDOM() and thus get this information to perform whatever you want - in Renderers. For example you might want to generate something visual or an auto link.
If you want more help you need to tell us what you want to do with this information.
Vincent, thanks so much for your help and patience.
What I want to do is have the semantic functionality described at the bottom of this google code "wikimodel" homepage [1] which is: “Semantic Web compatibility” One of the most important issues is to be compatible with the main standard/datamodel of Semantic Web – with Resource Description Framework (RDF). It means that both models (WEM as well as WOM) offer the possibility to map elements from wiki pages to RDF-statements. So each wiki page can be considered as a node in an RDF-graph. It allows to transform wiki-tools into powerful yet simple Semantic Web applications. Or if you are familiar with Semantic Mediawiki (SMW) [2], I am looking to get its basic functionality. (I have used SMW extensively, but now want to consider XWiki because it is Java based and I hope it will be easier to extend in various ways.)
That functionality is: 1) Treat pages as nodes in an RDF graph. This includes the ability to categorize pages (make them a member of an owl:Class) 2) Treat links between pages as owl:ObjectProperties. 3) Treat certain values on pages as owl:DatatypeProperties 4) Dynamically query wiki model based on these classes and properties.
For example, say I have a page on Berlin and a page on Germany. The Berlin page looks like this in standard XWiki markup:
Berlin is located in [[Germany>>doc:Main.Germany]] and has a population of 3,400,000.
So we know there is a link between Berlin and Germany, but we don't know what the link means. We also don't know what kind of "object" Berlin is.
For my RDF-ish model of information, I'd like to add a bit more markup to the page to clarify this, e.g.
Berlin is located in [[Germany>>doc:Main.Germany||property="locatedIn"]] and has a population of (% property="population" %)3,400,000(%%).
[[Category:City]]
Note how I've given a type to the link between Germany and Berlin (it is a locatedIn property), some structure to the formerly plain text value 3,400,000 (it is now a named property of Berlin), and finally, with the [[Category:City]] markup (or something like it) I have stated the kind of "object" Berlin is; it is a city.
When this page is saved, I want the database to know the following:
Berlin hastype City Berlin locatedIn Germany Berlin population 3,400,000
I want the database/datamodel to know this so I can: 1) query this kind of information from other pages for dynamic table building
Right now what is stored in the database on the XWiki side is the document's content in plain text. Thus in order to access it as an XDOM you need to get the document and ask for its XDOM. For example in groovy this is done like this: {{groovy}} def xdom = doc.document.getXDOM() /* Algo: - look for LinkBlock - get the property etc {{/groovy}} However you won't be able to query the whole wiki for this information since it isn't stored in the DB. If you wanted to do that you'd need to write an EventListener and catch the document save event and when your listener is called navigate the XDOM to extract the information you want from it and store it in your own tables in the DB (for example - you could also save it anywhere else you wish: lucene, another external storage, etc).
2) render this information as RDF through a SPARQL endpoint.
You'd need to implement your own Renderer for this (or extend our XHTML Renderer). Note that if all you want is to generate special XHTML based only on the content of the current doc you don't need step 1) above. Thanks -Vincent
I hope this clarifies my intent. In summary, I want to intercept page markup on page edits and maintain an RDF-ish model of the knowledge in the wiki.
Thanks for any help you can provide.
-Mark
References [1] http://code.google.com/p/wikimodel/ [2] http://semantic-mediawiki.org/wiki/Introduction_to_SMW
Regarding the Rendering system, it's documented here:
http://code.xwiki.org/xwiki/bin/view/Modules/RenderingModule
Thanks -Vincent