Hi and thanks a lot !
Your link towards the rendering stuff helped me a lot !
Especially the getting started page
(
http://rendering.xwiki.org/xwiki/bin/view/Main/GettingStarted).
Using this I was able to very quickly grab all JARs I needed and implement
something as :
// Parse XWiki 2.1 Syntax using a Parser.
Parser parser = componentManager.getInstance(Parser.class,
Syntax.XWIKI_2_1.toIdString());
XDOM xdom = parser.parse(new StringReader(pageContents));
for (Block block : xdom.getBlocks(new
SectionByIdBlockMatcher("MySectionId"), Block.Axes.DESCENDANT)) {
// Do my stuff
}
// Generate XWiki 2.1 Syntax as output for example
WikiPrinter printer = new DefaultWikiPrinter();
BlockRenderer renderer = componentManager.getInstance(BlockRenderer.class,
Syntax.XWIKI_2_1.toIdString());
renderer.render(xdom, printer);
With the following helper BlockMatcher :
private class SectionByIdBlockMatcher extends ClassBlockMatcher {
private String sectionId;
public SectionByIdBlockMatcher(String sectionId) {
super(SectionBlock.class);
this.sectionId = sectionId;
}
@Override
public boolean match(Block block) {
return (super.match(block) &&
sectionId.equals(getSectionId((SectionBlock)block)));
}
private String getSectionId(SectionBlock sectionBlock) {
return sectionBlock.getHeaderBlock().getId();
}
}
Now I just have to transform my blocks as I need. Easy stuff !
Thanks a lot for your help,
Stephane.
--
View this message in context:
http://xwiki.475771.n2.nabble.com/Retrieve-modify-page-sections-with-Rest-o…
Sent from the XWiki- Users mailing list archive at
Nabble.com.