@Test public void testWikiWordTransformation() throws Exception { String testInput = "This is a WikiWord, Another\u00D9ne, XWikiEnterprise, not one: XWiki"; Parser parser = this.componentManager.getInstance(Parser.class, "xwiki/2.1"); XDOM xdom = parser.parse(new StringReader(testInput)); this.wikiWordTransformation.transform(xdom, new TransformationContext()); WikiPrinter printer = new DefaultWikiPrinter(); BlockRenderer xwiki21BlockRenderer = this.componentManager.getInstance(BlockRenderer.class, "xwiki/2.1"); xwiki21BlockRenderer.render(xdom, printer); Assert.assertEquals("This is a [[doc:WikiWord]], [[doc:Another\u00D9ne]], [[doc:XWikiEnterprise]], " + "not one: XWiki", printer.toString()); }
@Override public void transform(Block block, TransformationContext transformationContext) throws TransformationException { for (WordBlock wordBlock : this.filter.getChildrenByType(block, WordBlock.class, true)) { Matcher matcher = WIKIWORD_PATTERN.matcher(wordBlock.getWord()); if (matcher.matches()) { ResourceReference linkReference = new DocumentResourceReference(wordBlock.getWord()); wordBlock.getParent().replaceChild(new LinkBlock(wordBlock.getChildren(), linkReference, false), wordBlock); } } }
WikiWordTransformation extends AbstractTransformation { @Override public void transform(Block block, TransformationContext transformationContext) throws TransformationException { for (WordBlock wordBlock : this.filter.getChildrenByType(block, WordBlock.class, true)) { Matcher matcher = WIKIWORD_PATTERN.matcher(wordBlock.getWord()); if (matcher.matches()) { ResourceReference linkReference = new DocumentResourceReference(wordBlock.getWord()); wordBlock.getParent().replaceChild(new LinkBlock(wordBlock.getChildren(), linkReference, false), wordBlock); } } } }
WikiWordTransformation extends AbstractTransformation { @Override public void transform(Block block, TransformationContext transformationContext) throws TransformationException { for (WordBlock wordBlock : this.filter.getChildrenByType(block, WordBlock.class, true)) { Matcher matcher = WIKIWORD_PATTERN.matcher(wordBlock.getWord()); if (matcher.matches()) { ResourceReference linkReference = new DocumentResourceReference(wordBlock.getWord()); wordBlock.getParent().replaceChild(new LinkBlock(wordBlock.getChildren(), linkReference, false), wordBlock); } } }  }
WikiWordTransformation extends AbstractTransformation { @Override public void transform(Block block, TransformationContext transformationContext) throws TransformationException { for (WordBlock wordBlock : this.filter.getChildrenByType(block, WordBlock.class, true)) { Matcher matcher = WIKIWORD_PATTERN.matcher(wordBlock.getWord()); if (matcher.matches()) { ResourceReference linkReference = new DocumentResourceReference(wordBlock.getWord()); wordBlock.getParent().replaceChild(new LinkBlock(wordBlock.getChildren(), linkReference, false), wordBlock); } } }  @Override void transform(Block block, TransformationContext transformationContext); }
WikiWordTransformation extends AbstractTransformation { @Override public void transform(Block block, TransformationContext transformationContext) throws TransformationException { for (WordBlock wordBlock : this.filter.getChildrenByType(block, WordBlock.class, true)) { Matcher matcher = WIKIWORD_PATTERN.matcher(wordBlock.getWord()); if (matcher.matches()) { ResourceReference linkReference = new DocumentResourceReference(wordBlock.getWord()); wordBlock.getParent().replaceChild(new LinkBlock(wordBlock.getChildren(), linkReference, false), wordBlock); } } }  @Override void transform(Block block, TransformationContext transformationContext);  }