You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2010/06/22 14:28:53 UTC
svn commit: r956861 - in /servicemix/maven-plugins/docs-maven-plugin/trunk:
./ src/main/java/org/apache/servicemix/docs/
src/main/java/org/apache/servicemix/docs/confluence/
src/test/java/org/apache/servicemix/docs/confluence/
src/test/resources/org/ap...
Author: gnodet
Date: Tue Jun 22 12:28:53 2010
New Revision: 956861
URL: http://svn.apache.org/viewvc?rev=956861&view=rev
Log:
Use mylyn wikitext to transform confluence to docbook
Added:
servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/confluence/ConfluenceLanguage.java
servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/confluence/DocBookDocumentBuilder.java
Modified:
servicemix/maven-plugins/docs-maven-plugin/trunk/pom.xml
servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/ConfluenceToDocbookMojo.java
servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/confluence/ConfluenceConverter.java
servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/java/org/apache/servicemix/docs/confluence/ConfluenceDocumentTest.java
servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/code-blocks.xml
servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/document1.xml
servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/document2.xml
servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/images.xml
servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/links.wiki
servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/links.xml
servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/lists.xml
servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/tables.xml
Modified: servicemix/maven-plugins/docs-maven-plugin/trunk/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/docs-maven-plugin/trunk/pom.xml?rev=956861&r1=956860&r2=956861&view=diff
==============================================================================
--- servicemix/maven-plugins/docs-maven-plugin/trunk/pom.xml (original)
+++ servicemix/maven-plugins/docs-maven-plugin/trunk/pom.xml Tue Jun 22 12:28:53 2010
@@ -67,5 +67,15 @@
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.eclipse.mylyn.wikitext</groupId>
+ <artifactId>confluence.core</artifactId>
+ <version>1.3.0.v20100608-0100-e3x</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.mylyn.wikitext</groupId>
+ <artifactId>core</artifactId>
+ <version>1.3.0.v20100608-0100-e3x</version>
+ </dependency>
</dependencies>
</project>
Modified: servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/ConfluenceToDocbookMojo.java
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/ConfluenceToDocbookMojo.java?rev=956861&r1=956860&r2=956861&view=diff
==============================================================================
--- servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/ConfluenceToDocbookMojo.java (original)
+++ servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/ConfluenceToDocbookMojo.java Tue Jun 22 12:28:53 2010
@@ -20,6 +20,8 @@ import java.io.FileFilter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
import org.apache.commons.io.FilenameUtils;
import org.apache.maven.plugin.AbstractMojo;
@@ -51,6 +53,8 @@ public class ConfluenceToDocbookMojo ext
*/
private final FileFilter filter = new DefaultFileFilterImpl();
+ private final ConfluenceConverter converter = new ConfluenceConverter();
+
public void execute() throws MojoExecutionException {
doConvert(input);
}
@@ -62,7 +66,8 @@ public class ConfluenceToDocbookMojo ext
doConvert(file);
} else {
getLog().info("Creating DocBook from " + file.getAbsolutePath());
- FileWriter writer = null;
+ Reader reader = null;
+ Writer writer = null;
try {
String relativePath = FilenameUtils.getPath(file.getAbsolutePath().replace(input.getAbsolutePath(), ""));
@@ -71,15 +76,20 @@ public class ConfluenceToDocbookMojo ext
result.getParentFile().mkdirs();
}
+ reader = new FileReader(file);
writer = new FileWriter(result);
- ConfluenceConverter converter =
- new ConfluenceConverter(new FileReader(file), writer);
-
- converter.convert();
+ converter.convert(reader, writer);
} catch (IOException e) {
throw new MojoExecutionException("Unable to convert " + file, e);
} finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ // ignore this
+ }
+ }
if (writer != null) {
try {
writer.close();
Modified: servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/confluence/ConfluenceConverter.java
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/confluence/ConfluenceConverter.java?rev=956861&r1=956860&r2=956861&view=diff
==============================================================================
--- servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/confluence/ConfluenceConverter.java (original)
+++ servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/confluence/ConfluenceConverter.java Tue Jun 22 12:28:53 2010
@@ -15,322 +15,29 @@
*/
package org.apache.servicemix.docs.confluence;
-import java.io.BufferedReader;
-import java.io.FileReader;
import java.io.IOException;
-import java.io.PrintStream;
-import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Stack;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+
+import org.eclipse.mylyn.wikitext.core.parser.MarkupParser;
/**
* Represents a document in Confluence wiki markup
*/
public class ConfluenceConverter {
- private static Pattern CHAPTER = Pattern.compile("^h1\\. .*");
- private static Pattern CHAPTER_OR_SECTION = Pattern.compile("^h[1-6]\\. .*");
-
- private BufferedReader reader;
- private PrintWriter writer;
-
- private int currentLevel = 0;
-
- private Stack<String> elements = new Stack<String>();
-
- public ConfluenceConverter(Reader reader, Writer writer) {
- if (reader instanceof BufferedReader) {
- this.reader = (BufferedReader) reader;
- } else {
- this.reader = new BufferedReader(reader);
- }
- if (writer instanceof PrintWriter) {
- this.writer = (PrintWriter) writer;
- } else {
- this.writer = new PrintWriter(writer);
- }
- }
-
- public void convert() throws IOException {
- String line = null;
-
- while ((line = reader.readLine()) != null) {
- String trimmed = line.trim();
- if (CHAPTER_OR_SECTION.matcher(line).matches()) {
- writeChapterOrSection(line);
- } else if (trimmed.startsWith("!") && trimmed.endsWith("!")) {
- writeImage(line);
- } else if (trimmed.startsWith("||") && trimmed.endsWith("||")) {
- writeTableHeader(line);
- } else if (trimmed.startsWith("|") && trimmed.endsWith("|")) {
- writeTableBody(line);
- } else if (line.startsWith("*")) {
- writeBulletList(line);
- } else if (line.startsWith("#")) {
- writeNumberedList(line);
- } else if (line.startsWith("-")) {
- writeGlossaryList(line);
- } else if (trimmed.startsWith("{code")) {
- writeProgramListing(line);
- } else {
- writePara(line);
- }
- }
-
- // let's close everying that was opened
- closeElements();
-
- }
-
- private void writeGlossaryList(String line) {
- ensureElementOpen("variablelist");
-
- String[] keyvalue = line.substring(1).trim().split("::");
- openElement("varlistentry");
- writeElement("term", filter(keyvalue[0].trim()));
- writeListItem(keyvalue[1]);
- closeElement("varlistentry");
- }
-
- private void writeTableBody(String line) {
- ensureElementOpen("tbody");
-
- writeTableRow(line.substring(1, line.length() - 1).split("\\|"));
- }
-
- private void writeTableHeader(String line) {
- ensureElementOpen("informaltable");
- ensureElementOpen("thead");
-
- writeTableRow(line.substring(2, line.length() - 2).split("\\|\\|"));
-
- closeElement("thead");
- }
-
- private void writeTableRow(String[] cells) {
- openElement("tr");
- for (String cell : cells) {
- writeElement("td", filter(cell.trim()));
- }
- closeElement("tr");
- }
-
- private void writeNumberedList(String line) {
- ensureElementOpen("orderedlist");
- writeListItem(line.substring(1));
- }
-
- private void ensureElementOpen(String element) {
- if (!isCurrentElement(element)) {
- openElement(element);
- }
- }
-
- private void writeBulletList(String line) {
- ensureElementOpen("itemizedlist");
- writeListItem(line.substring(1));
- }
-
- private void writeListItem(String data) {
- openElement("listitem");
- writeElement("para", filter(data.trim()));
- closeElement("listitem");
- }
-
- private void writeImage(String line) {
- String file = line.trim().replaceAll("!", "");
- openElement("imageobject");
- writeRaw(String.format("<imagedata fileref=\"%s\"/>", file));
- closeElement("imageobject");
- }
-
- private void writeProgramListing(String line) throws IOException {
- String language = Macro.parse(line).getParameter("lang");
- if (language == null) {
- writeRaw("<programlisting><![CDATA[");
- } else {
- writeRaw(String.format("<programlisting language=\"%s\"><![CDATA[", language));
- }
-
- while ((line = reader.readLine()) != null && !line.equals("{code}")) {
- writeRaw(line, "");
- }
-
- writeRaw("]]></programlisting>");
- }
-
- private void writePara(String line) {
- // a <para/> shouldn't
- ensureClosed("informaltable");
-
+ final ConfluenceLanguage markupLanguage = new ConfluenceLanguage();
- if (line.trim().length() == 0) {
- if (elements.contains("para")) {
- closeElement("para");
- }
- } else {
- if (!elements.peek().equals("para")) {
- openElement("para");
- }
- writeText(line);
- }
+ public ConfluenceConverter() {
}
- private void ensureClosed(String element) {
- if (elements.contains(element)) {
- closeElement(element);
- }
+ public void convert(Reader reader, Writer writer) throws IOException {
+ DocBookDocumentBuilder builder = new DocBookDocumentBuilder(writer);
+ MarkupParser parser = new MarkupParser();
+ parser.setMarkupLanguage(markupLanguage);
+ parser.setBuilder(builder);
+ parser.parse(reader);
+ writer.flush();
}
- private String filter(String line) {
- Map<String,String> replacements = new LinkedHashMap<String,String>();
- replacements.put("&", "&");
- replacements.put("<", "<");
- replacements.put(">", ">");
- replacements.put("\\{\\{(.*)\\}\\}", "<code>$1</code>");
-
- replacements.put("\\*([^*]*)\\*", "<emphasis role=\\\"bold\\\">$1</emphasis>");
-
- replacements.put("([^\\\\])\\[([^\\|\\]]*)\\|([^\\]]*)\\]", "$1<ulink url=\\\"$3\\\">$2</ulink>");
- replacements.put("^\\[([^\\|\\]]*)\\|([^\\]]*)\\]", "<ulink url=\\\"$2\\\">$1</ulink>");
- replacements.put("([^\\\\])\\[([^\\|\\]]*)\\]", "$1<ulink url=\\\"$2\\\">$2</ulink>");
- replacements.put("^\\[([^\\|\\]]*)\\]", "<ulink url=\\\"$1\\\">$1</ulink>");
-
- replacements.put("\\\\\\[", "[");
- replacements.put("\\\\\\]", "]");
-
- String filtered = line;
- for (String key : replacements.keySet()) {
- filtered = filtered.replaceAll(key, replacements.get(key));
- }
-
- return filtered;
- }
-
- private void writeRaw(String text) {
- writeRaw(text, indent());
- }
-
- private void writeRaw(String text, String indent) {
- writer.printf("%s%s%n", indent, text);
- }
-
- private void writeText(String text) {
- writeText(text, indent());
- }
-
- private void writeText(String text, String indent) {
- writer.printf("%s%s%n", indent, filter(text));
-
-
- }
-
- private void writeChapterOrSection(String line) {
- int level = Integer.parseInt(line.substring(1, 2));
- while (currentLevel >= level) {
- closeElement("section");
- currentLevel--;
- }
- if (CHAPTER.matcher(line).matches()) {
- openElement("chapter");
- } else {
- openElement("section");
- }
- writeElement("title", filter(line.substring(3).trim()));
- currentLevel = level;
- }
-
- private void writeElement(String element, String value) {
- writer.printf("%s<%s>%s</%s>%n", indent(), element, value, element);
- }
-
- private void openElement(String element) {
- if (elements.size() == 0) {
- //adding namespace to root element
- writer.printf("%s<%s xmlns=\"http://docbook.org/ns/docbook\">%n", indent(), element);
- } else {
- writer.printf("%s<%s>%n", indent(), element);
- }
- elements.push(element);
- }
-
- private void closeElements() {
- while (!elements.isEmpty()) {
- closeElement(elements.peek());
- }
- }
-
- private void closeElement(String element) {
- if (!elements.isEmpty()) {
- String next = elements.pop();
- writer.printf("%s</%s>%n", indent(), next);
- if (!element.equals(next)) {
- // recursive call to close everything down to the required element
- closeElement(element);
- }
- }
- }
-
- private String indent() {
- StringBuffer buffer = new StringBuffer();
- for (int i = 0 ; i < elements.size(); i++) {
- buffer.append(" ");
- }
- return buffer.toString();
- }
-
- private boolean isCurrentElement(String element) {
- return elements.peek().equals(element);
- }
-
- /*
- * Helper class to represent a Confluence macro
- * {name:parm1=value1?parm2=value2}
- */
- private static final class Macro {
-
- private String name;
- private final Map<String, String> parameters = new HashMap<String, String>();
-
- /**
- * Get the macro name
- */
- public String getName() {
- return name;
- }
-
- /**
- * Get a macro parameter value
- */
- public String getParameter(String name) {
- return parameters.get(name);
- }
-
- /**
- * Parse a line containing a confluence macro
- */
- public static Macro parse(String line) {
- Macro result = new Macro();
- String macro = line.substring(line.indexOf("{"), line.indexOf("}"));
- if (macro.contains(":")) {
- String[] split = macro.split(":");
- result.name = split[0];
- String[] parms = split[1].split("\\?");
- for (String parm : parms) {
- String[] pair = parm.split("=");
- result.parameters.put(pair[0], pair[1]);
- }
- } else {
- result.name = macro;
- }
- return result;
- }
-
- }
}
Added: servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/confluence/ConfluenceLanguage.java
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/confluence/ConfluenceLanguage.java?rev=956861&view=auto
==============================================================================
--- servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/confluence/ConfluenceLanguage.java (added)
+++ servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/confluence/ConfluenceLanguage.java Tue Jun 22 12:28:53 2010
@@ -0,0 +1,451 @@
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.docs.confluence;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.mylyn.internal.wikitext.confluence.core.block.AbstractConfluenceDelimitedBlock;
+import org.eclipse.mylyn.internal.wikitext.confluence.core.block.ColorBlock;
+import org.eclipse.mylyn.internal.wikitext.confluence.core.block.ExtendedPreformattedBlock;
+import org.eclipse.mylyn.internal.wikitext.confluence.core.block.ExtendedQuoteBlock;
+import org.eclipse.mylyn.internal.wikitext.confluence.core.block.HeadingBlock;
+import org.eclipse.mylyn.internal.wikitext.confluence.core.block.ListBlock;
+import org.eclipse.mylyn.internal.wikitext.confluence.core.block.QuoteBlock;
+import org.eclipse.mylyn.internal.wikitext.confluence.core.block.TableOfContentsBlock;
+import org.eclipse.mylyn.internal.wikitext.confluence.core.block.TextBoxBlock;
+import org.eclipse.mylyn.internal.wikitext.confluence.core.phrase.ConfluenceWrappedPhraseModifier;
+import org.eclipse.mylyn.internal.wikitext.confluence.core.phrase.EmphasisPhraseModifier;
+import org.eclipse.mylyn.internal.wikitext.confluence.core.phrase.ImagePhraseModifier;
+import org.eclipse.mylyn.internal.wikitext.confluence.core.phrase.SimplePhraseModifier;
+import org.eclipse.mylyn.internal.wikitext.confluence.core.phrase.SimpleWrappedPhraseModifier;
+import org.eclipse.mylyn.internal.wikitext.confluence.core.token.EscapedCharacterReplacementToken;
+import org.eclipse.mylyn.wikitext.core.parser.Attributes;
+import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder;
+import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder.BlockType;
+import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder.SpanType;
+import org.eclipse.mylyn.wikitext.core.parser.LinkAttributes;
+import org.eclipse.mylyn.wikitext.core.parser.markup.Block;
+import org.eclipse.mylyn.wikitext.core.parser.markup.ContentState;
+import org.eclipse.mylyn.wikitext.core.parser.markup.PatternBasedElement;
+import org.eclipse.mylyn.wikitext.core.parser.markup.PatternBasedElementProcessor;
+import org.eclipse.mylyn.wikitext.core.parser.markup.token.EntityReferenceReplacementToken;
+import org.eclipse.mylyn.wikitext.core.parser.markup.token.ImpliedHyperlinkReplacementToken;
+import org.eclipse.mylyn.wikitext.core.parser.markup.token.PatternEntityReferenceReplacementToken;
+import org.eclipse.mylyn.wikitext.core.parser.markup.token.PatternLineBreakReplacementToken;
+import org.eclipse.mylyn.wikitext.core.parser.markup.token.PatternLiteralReplacementToken;
+
+
+public class ConfluenceLanguage extends org.eclipse.mylyn.wikitext.confluence.core.ConfluenceLanguage {
+
+ private final List<Block> nestedBlocks = new ArrayList<Block>();
+
+ private final ContentState contentState = new ContentState();
+
+ @Override
+ protected void clearLanguageSyntax() {
+ super.clearLanguageSyntax();
+ nestedBlocks.clear();
+ }
+
+ public List<Block> getNestedBlocks() {
+ return nestedBlocks;
+ }
+
+ @Override
+ protected void addStandardBlocks(List<Block> blocks, List<Block> paragraphBreakingBlocks) {
+ // IMPORTANT NOTE: Most items below have order dependencies. DO NOT REORDER ITEMS BELOW!!
+
+ HeadingBlock headingBlock = new HeadingBlock();
+ blocks.add(headingBlock);
+ paragraphBreakingBlocks.add(headingBlock);
+ nestedBlocks.add(headingBlock);
+ ConfluenceGlossaryBlock glossaryBlock = new ConfluenceGlossaryBlock();
+ blocks.add(glossaryBlock);
+ paragraphBreakingBlocks.add(glossaryBlock);
+ nestedBlocks.add(glossaryBlock);
+ ListBlock listBlock = new ListBlock();
+ blocks.add(listBlock);
+ paragraphBreakingBlocks.add(listBlock);
+ nestedBlocks.add(listBlock);
+ blocks.add(new QuoteBlock());
+ TableBlock tableBlock = new TableBlock();
+ blocks.add(tableBlock);
+ paragraphBreakingBlocks.add(tableBlock);
+ nestedBlocks.add(tableBlock);
+ ExtendedQuoteBlock quoteBlock = new ExtendedQuoteBlock();
+ blocks.add(quoteBlock);
+ paragraphBreakingBlocks.add(quoteBlock);
+ ExtendedPreformattedBlock noformatBlock = new ExtendedPreformattedBlock();
+ blocks.add(noformatBlock);
+ paragraphBreakingBlocks.add(noformatBlock);
+
+ blocks.add(new TextBoxBlock(BlockType.PANEL, "panel")); //$NON-NLS-1$
+ blocks.add(new TextBoxBlock(BlockType.NOTE, "note")); //$NON-NLS-1$
+ blocks.add(new TextBoxBlock(BlockType.INFORMATION, "info")); //$NON-NLS-1$
+ blocks.add(new TextBoxBlock(BlockType.WARNING, "warning")); //$NON-NLS-1$
+ blocks.add(new TextBoxBlock(BlockType.TIP, "tip")); //$NON-NLS-1$
+ CodeBlock codeBlock = new CodeBlock();
+ blocks.add(codeBlock);
+ paragraphBreakingBlocks.add(codeBlock);
+ blocks.add(new TableOfContentsBlock());
+ ColorBlock colorBlock = new ColorBlock();
+ blocks.add(colorBlock);
+ paragraphBreakingBlocks.add(colorBlock);
+ }
+
+ @Override
+ protected void addStandardPhraseModifiers(PatternBasedSyntax phraseModifierSyntax) {
+ phraseModifierSyntax.beginGroup("(?:(?<=[\\s\\.,\\\"'?!;:\\)\\(\\[\\]])|^)(?:", 0); //$NON-NLS-1$
+ phraseModifierSyntax.add(new HyperlinkPhraseModifier());
+ phraseModifierSyntax.add(new SimplePhraseModifier("*", SpanType.STRONG, true)); //$NON-NLS-1$
+ phraseModifierSyntax.add(new EmphasisPhraseModifier());
+ phraseModifierSyntax.add(new SimplePhraseModifier("??", SpanType.CITATION, true)); //$NON-NLS-1$
+ phraseModifierSyntax.add(new SimplePhraseModifier("-", SpanType.DELETED, true)); //$NON-NLS-1$
+ phraseModifierSyntax.add(new SimplePhraseModifier("+", SpanType.UNDERLINED, true)); //$NON-NLS-1$
+ phraseModifierSyntax.add(new SimplePhraseModifier("^", SpanType.SUPERSCRIPT, false)); //$NON-NLS-1$
+ phraseModifierSyntax.add(new SimplePhraseModifier("~", SpanType.SUBSCRIPT, false)); //$NON-NLS-1$
+ phraseModifierSyntax.add(new SimpleWrappedPhraseModifier("{{", "}}", DocumentBuilder.SpanType.MONOSPACE, false)); //$NON-NLS-1$ //$NON-NLS-2$
+ phraseModifierSyntax.add(new ConfluenceWrappedPhraseModifier("{quote}", DocumentBuilder.SpanType.QUOTE, true)); //$NON-NLS-1$
+ phraseModifierSyntax.add(new ImagePhraseModifier());
+ phraseModifierSyntax.endGroup(")(?=\\W|$)", 0); //$NON-NLS-1$
+ }
+
+ @Override
+ protected void addStandardTokens(PatternBasedSyntax tokenSyntax) {
+ tokenSyntax.add(new PatternLineBreakReplacementToken("(\\\\\\\\)")); // line break //$NON-NLS-1$
+ tokenSyntax.add(new EscapedCharacterReplacementToken()); // ORDER DEPENDENCY must come after line break
+ tokenSyntax.add(new EntityReferenceReplacementToken("(tm)", "#8482")); //$NON-NLS-1$ //$NON-NLS-2$
+ tokenSyntax.add(new EntityReferenceReplacementToken("(TM)", "#8482")); //$NON-NLS-1$ //$NON-NLS-2$
+ tokenSyntax.add(new EntityReferenceReplacementToken("(c)", "#169")); //$NON-NLS-1$ //$NON-NLS-2$
+ tokenSyntax.add(new EntityReferenceReplacementToken("(C)", "#169")); //$NON-NLS-1$ //$NON-NLS-2$
+ tokenSyntax.add(new EntityReferenceReplacementToken("(r)", "#174")); //$NON-NLS-1$ //$NON-NLS-2$
+ tokenSyntax.add(new EntityReferenceReplacementToken("(R)", "#174")); //$NON-NLS-1$ //$NON-NLS-2$
+ tokenSyntax.add(new PatternEntityReferenceReplacementToken("(?:(?<=\\w\\s)(---)(?=\\s\\w))", "#8212")); // emdash //$NON-NLS-1$ //$NON-NLS-2$
+ tokenSyntax.add(new PatternEntityReferenceReplacementToken("(?:(?<=\\w\\s)(--)(?=\\s\\w))", "#8211")); // endash //$NON-NLS-1$ //$NON-NLS-2$
+ tokenSyntax.add(new PatternLiteralReplacementToken("(----)", "<hr/>")); // horizontal rule //$NON-NLS-1$ //$NON-NLS-2$
+ tokenSyntax.add(new ImpliedHyperlinkReplacementToken());
+ tokenSyntax.add(new AnchorReplacementToken());
+ }
+
+ @Override
+ protected ContentState createState() {
+ return contentState;
+ }
+
+ public static class CodeBlock extends AbstractConfluenceDelimitedBlock {
+
+ private String title;
+
+ private String language;
+
+ public CodeBlock() {
+ super("code"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected void beginBlock() {
+ if (title != null) {
+ Attributes attributes = new Attributes();
+ attributes.setTitle(title);
+ builder.beginBlock(DocumentBuilder.BlockType.PANEL, attributes);
+ }
+ Attributes attributes = new Attributes();
+ Attributes preAttributes = new Attributes();
+ if (language != null) {
+ attributes.setLanguage(language); //$NON-NLS-1$
+ }
+// builder.beginBlock(DocumentBuilder.BlockType.PREFORMATTED, preAttributes);
+ builder.beginBlock(DocumentBuilder.BlockType.CODE, attributes);
+ builder.charactersUnescaped("<![CDATA[");
+ }
+
+ @Override
+ protected void handleBlockContent(String content) {
+ builder.charactersUnescaped(content);
+ builder.charactersUnescaped("\n"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected void endBlock() {
+ builder.charactersUnescaped("]]>");
+ if (title != null) {
+ builder.endBlock(); // panel
+ }
+ builder.endBlock(); // code
+// builder.endBlock(); // pre
+ }
+
+ @Override
+ protected void resetState() {
+ super.resetState();
+ title = null;
+ }
+
+ @Override
+ protected void setOption(String key, String value) {
+ if (key.equals("title")) { //$NON-NLS-1$
+ title = value;
+ } else if (key.equals("lang")) {
+ language = value;
+ }
+ }
+
+ @Override
+ protected void setOption(String option) {
+ language = option.toLowerCase();
+ }
+ }
+
+ public static class ConfluenceGlossaryBlock extends Block {
+
+ static final Pattern startPattern = Pattern.compile("\\s*-\\s*+(.*?)\\s*+::\\s*+(.*?)\\s*+"); //$NON-NLS-1$
+
+ private Matcher matcher;
+ private int blockLineCount = 0;
+
+ @Override
+ public int processLineContent(String line, int offset) {
+ if (blockLineCount == 0) {
+ builder.beginBlock(BlockType.DEFINITION_LIST, new Attributes());
+ } else {
+ matcher = startPattern.matcher(line);
+ if (!matcher.matches()) {
+ setClosed(true);
+ return 0;
+ }
+ }
+ ++blockLineCount;
+ String key = matcher.group(1);
+ String val = matcher.group(2);
+ builder.beginBlock(BlockType.DEFINITION_TERM, new Attributes());
+ markupLanguage.emitMarkupLine(getParser(), state, key, 0);
+ builder.endBlock();
+ builder.beginBlock(BlockType.DEFINITION_ITEM, new Attributes());
+ markupLanguage.emitMarkupLine(getParser(), state, val, 0);
+ builder.endBlock();
+ return -1;
+ }
+
+ @Override
+ public boolean canStart(String line, int lineOffset) {
+ if (lineOffset == 0 && !markupLanguage.isFilterGenerativeContents()) {
+ matcher = startPattern.matcher(line);
+ return matcher.matches();
+ } else {
+ matcher = null;
+ return false;
+ }
+ }
+
+ @Override
+ public void setClosed(boolean closed) {
+ if (closed && !isClosed()) {
+ builder.endBlock();
+ }
+ super.setClosed(closed);
+ }
+ }
+
+
+ public static class TableBlock extends Block {
+
+ static final Pattern startPattern = Pattern.compile("(\\|(.*)?(\\|\\s*$))"); //$NON-NLS-1$
+
+ static final Pattern TABLE_ROW_PATTERN = Pattern.compile("\\|(\\|)?" + "((?:(?:[^\\|\\[]*)(?:\\[[^\\]]*\\])?)*)" //$NON-NLS-1$ //$NON-NLS-2$
+ + "(\\|\\|?\\s*$)?"); //$NON-NLS-1$
+
+ private int blockLineCount = 0;
+
+ private Matcher matcher;
+
+ public TableBlock() {
+ }
+
+ @Override
+ public int processLineContent(String line, int offset) {
+ if (blockLineCount == 0) {
+ Attributes attributes = new Attributes();
+ builder.beginBlock(BlockType.TABLE, attributes);
+ } else if (markupLanguage.isEmptyLine(line)) {
+ setClosed(true);
+ return 0;
+ }
+ ++blockLineCount;
+
+ if (offset == line.length()) {
+ return -1;
+ }
+
+ String textileLine = offset == 0 ? line : line.substring(offset);
+ Matcher rowMatcher = TABLE_ROW_PATTERN.matcher(textileLine);
+ if (!rowMatcher.find()) {
+ setClosed(true);
+ return 0;
+ }
+
+ builder.beginBlock(BlockType.TABLE_ROW, new Attributes());
+
+ do {
+ int start = rowMatcher.start();
+ if (start == textileLine.length() - 1) {
+ break;
+ }
+
+ String headerIndicator = rowMatcher.group(1);
+ String text = rowMatcher.group(2).trim(); // MODIFIED: added trim()
+ int lineOffset = offset + rowMatcher.start(2);
+
+ boolean header = headerIndicator != null && "|".equals(headerIndicator); //$NON-NLS-1$
+
+ Attributes attributes = new Attributes();
+ builder.beginBlock(header ? BlockType.TABLE_CELL_HEADER : BlockType.TABLE_CELL_NORMAL, attributes);
+
+ markupLanguage.emitMarkupLine(getParser(), state, lineOffset, text, 0);
+
+ builder.endBlock(); // table cell
+ } while (rowMatcher.find());
+
+ builder.endBlock(); // table row
+
+ return -1;
+ }
+
+ @Override
+ public boolean canStart(String line, int lineOffset) {
+ blockLineCount = 0;
+ if (lineOffset == 0) {
+ matcher = startPattern.matcher(line);
+ return matcher.matches();
+ } else {
+ matcher = null;
+ return false;
+ }
+ }
+
+ @Override
+ public void setClosed(boolean closed) {
+ if (closed && !isClosed()) {
+ builder.endBlock();
+ }
+ super.setClosed(closed);
+ }
+
+ }
+
+ public static class HyperlinkPhraseModifier extends PatternBasedElement {
+
+ @Override
+ protected String getPattern(int groupOffset) {
+ return "\\[(?:\\s*([^\\]\\|]+)\\|)?([^\\]]+)\\]"; //$NON-NLS-1$
+ }
+
+ @Override
+ protected int getPatternGroupCount() {
+ return 2;
+ }
+
+ @Override
+ protected PatternBasedElementProcessor newProcessor() {
+ return new HyperlinkPhraseModifierProcessor();
+ }
+
+ private static class HyperlinkPhraseModifierProcessor extends PatternBasedElementProcessor {
+ @Override
+ public void emit() {
+ String text = group(1);
+ String linkComposite = group(2);
+ String[] parts = linkComposite.split("\\s*\\|\\s*"); //$NON-NLS-1$
+ if (parts.length == 0) {
+ // can happen if linkComposite is ' |', see bug 290434
+ } else {
+ if (text != null) {
+ text = text.trim();
+ }
+ String href = parts[0];
+ if (href != null) {
+ href = href.trim();
+ }
+ if (href.charAt(0) == '#') {
+
+ }
+ String tip = parts.length > 1 ? parts[1] : null;
+ if (tip != null) {
+ tip = tip.trim();
+ }
+ if (text == null || text.length() == 0) {
+ text = href;
+ if (text.length() > 0 && text.charAt(0) == '#') {
+ text = text.substring(1);
+ }
+ if (href.charAt(0) == '#') {
+ href = "#" + state.getIdGenerator().getGenerationStrategy().generateId(href.substring(1));
+ }
+ Attributes attributes = new LinkAttributes();
+ attributes.setTitle(tip);
+ getBuilder().link(attributes, href, text);
+ } else {
+ if (href.charAt(0) == '#') {
+ href = "#" + state.getIdGenerator().getGenerationStrategy().generateId(href.substring(1));
+ }
+ LinkAttributes attributes = new LinkAttributes();
+ attributes.setTitle(tip);
+ attributes.setHref(href);
+ getBuilder().beginSpan(SpanType.LINK, attributes);
+
+ getMarkupLanguage().emitMarkupLine(parser, state, start(1), text, 0);
+
+ getBuilder().endSpan();
+ }
+ }
+ }
+ }
+ }
+
+ public static class AnchorReplacementToken extends PatternBasedElement {
+
+ @Override
+ protected String getPattern(int groupOffset) {
+ return "\\{anchor:([^\\}]+)\\}"; //$NON-NLS-1$
+ }
+
+ @Override
+ protected int getPatternGroupCount() {
+ return 1;
+ }
+
+ @Override
+ protected PatternBasedElementProcessor newProcessor() {
+ return new AnchorReplacementTokenProcessor();
+ }
+
+ private static class AnchorReplacementTokenProcessor extends PatternBasedElementProcessor {
+ @Override
+ public void emit() {
+ String name = group(1);
+ name = state.getIdGenerator().getGenerationStrategy().generateId(name);
+ Attributes attributes = new Attributes();
+ attributes.setId(name);
+ getBuilder().beginSpan(SpanType.SPAN, attributes);
+ getBuilder().endSpan();
+ }
+
+ }
+
+ }
+ }
Added: servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/confluence/DocBookDocumentBuilder.java
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/confluence/DocBookDocumentBuilder.java?rev=956861&view=auto
==============================================================================
--- servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/confluence/DocBookDocumentBuilder.java (added)
+++ servicemix/maven-plugins/docs-maven-plugin/trunk/src/main/java/org/apache/servicemix/docs/confluence/DocBookDocumentBuilder.java Tue Jun 22 12:28:53 2010
@@ -0,0 +1,645 @@
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.docs.confluence;
+
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.Stack;
+import java.util.TreeMap;
+import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.mylyn.internal.wikitext.core.util.css.CssParser;
+import org.eclipse.mylyn.internal.wikitext.core.util.css.CssRule;
+import org.eclipse.mylyn.wikitext.core.parser.Attributes;
+import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder;
+import org.eclipse.mylyn.wikitext.core.parser.LinkAttributes;
+import org.eclipse.mylyn.wikitext.core.parser.builder.AbstractXmlDocumentBuilder;
+import org.eclipse.mylyn.wikitext.core.util.FormattingXMLStreamWriter;
+import org.eclipse.mylyn.wikitext.core.util.XmlStreamWriter;
+
+/**
+ * A builder that can emit <a href="http://www.docbook.org/">Docbook</a>
+ *
+ */
+public class DocBookDocumentBuilder extends AbstractXmlDocumentBuilder {
+
+ private static final Pattern PERCENTAGE = Pattern.compile("(\\d+)%"); //$NON-NLS-1$
+
+ private static final Pattern CSS_CLASS_INLINE = Pattern.compile("(^|\\s+)inline(\\s+|$)"); //$NON-NLS-1$
+
+ private static Set<Integer> entityReferenceToUnicode = new HashSet<Integer>();
+ static {
+ entityReferenceToUnicode.add(215);
+ entityReferenceToUnicode.add(8211);
+ entityReferenceToUnicode.add(8212);
+ entityReferenceToUnicode.add(8220);
+ entityReferenceToUnicode.add(8221);
+ entityReferenceToUnicode.add(8216);
+ entityReferenceToUnicode.add(8217);
+
+ }
+
+// private String bookTitle;
+
+ private String namespace = "http://docbook.org/ns/docbook"; //$NON-NLS-1$
+
+ private final Map<String, String> acronyms = new HashMap<String, String>();
+
+ private int headingLevel = 0;
+
+ private final Stack<BlockDescription> blockDescriptions = new Stack<BlockDescription>();
+
+ private final Stack<HeadingDescription> headingDescriptions = new Stack<HeadingDescription>();
+
+ private boolean automaticGlossary = true;
+
+ public DocBookDocumentBuilder(Writer out) {
+ super(out);
+ }
+
+ public DocBookDocumentBuilder(XmlStreamWriter writer) {
+ super(writer);
+ }
+
+ protected XmlStreamWriter createXmlStreamWriter(Writer out) {
+ XmlStreamWriter writer = super.createXmlStreamWriter(out);
+ return new FormattingXMLStreamWriter(writer) {
+ @Override
+ protected boolean preserveWhitespace(String elementName) {
+ return elementName.equals("programlisting") || elementName.equals("code") || elementName.startsWith("literal"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ };
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+ @Override
+ public void acronym(String text, String definition) {
+ String previousDef = acronyms.put(text, definition);
+ if (previousDef != null && previousDef.length() > definition.length()) {
+ acronyms.put(text, previousDef);
+ }
+ writer.writeStartElement("glossterm"); //$NON-NLS-1$
+ characters(text);
+ writer.writeEndElement();
+ }
+
+ @Override
+ public void link(Attributes attributes, String href, final String text) {
+ link(attributes, href, new ContentEmitter() {
+ public void emit() {
+ writer.writeCharacters(text);
+ }
+ });
+ }
+
+ private void link(Attributes attributes, String href, ContentEmitter emitter) {
+ ensureBlockElementsOpen();
+ if (href.startsWith("#")) { //$NON-NLS-1$
+ if (href.length() > 1) {
+ writer.writeStartElement("link"); //$NON-NLS-1$
+ writer.writeAttribute("linkend", href.substring(1)); //$NON-NLS-1$
+ emitter.emit();
+ writer.writeEndElement(); // link
+ } else {
+ emitter.emit();
+ }
+ } else {
+ writer.writeStartElement("ulink"); //$NON-NLS-1$
+ writer.writeAttribute("url", href); //$NON-NLS-1$
+ emitter.emit();
+ writer.writeEndElement(); // ulink
+ }
+ }
+
+ private void transformId(String id) {
+
+ }
+
+ private interface ContentEmitter {
+ public void emit();
+ }
+
+ @Override
+ public void beginBlock(BlockType type, Attributes attributes) {
+ if (headingLevel == 0) {
+ beginHeading(1, new Attributes());
+ endHeading();
+ }
+
+ String elementName;
+ String[] elementNames = null;
+ boolean allowTitle = false;
+ boolean closeElementsOnBlockStart = false;
+ BlockDescription previousBlock = null;
+ if (!blockDescriptions.isEmpty()) {
+ previousBlock = blockDescriptions.peek();
+ }
+
+ switch (type) {
+ case BULLETED_LIST:
+ elementName = "itemizedlist"; //$NON-NLS-1$
+ break;
+ case NUMERIC_LIST:
+ elementName = "orderedlist"; //$NON-NLS-1$
+ break;
+ case DEFINITION_LIST:
+ elementName = "variablelist"; //$NON-NLS-1$
+
+ // variablelist
+ // varlistentry+
+ // term+
+ // listitem
+ //
+ break;
+ case DEFINITION_TERM:
+
+ BlockDescription blockDescription = findBlockDescription(BlockType.DEFINITION_LIST);
+ if (blockDescription.entrySize > 0) {
+ endBlockEntry(blockDescription);
+ }
+ openBlockEntry(blockDescription, new String[] { "varlistentry" }); //$NON-NLS-1$
+
+ elementName = "term"; //$NON-NLS-1$
+ break;
+ case DEFINITION_ITEM:
+ elementName = "listitem"; //$NON-NLS-1$
+ elementNames = new String[] { "para" }; //$NON-NLS-1$
+ closeElementsOnBlockStart = true;
+ break;
+ case FOOTNOTE:
+ case PARAGRAPH:
+ elementName = "para"; //$NON-NLS-1$
+ break;
+ case CODE:
+ elementName = "programlisting"; //$NON-NLS-1$
+ break;
+ case PREFORMATTED:
+ elementName = "literallayout"; //$NON-NLS-1$
+ break;
+ case QUOTE:
+ elementName = "blockquote"; //$NON-NLS-1$
+ break;
+ case LIST_ITEM:
+ elementName = "listitem"; //$NON-NLS-1$
+ elementNames = new String[] { "para" }; //$NON-NLS-1$
+ closeElementsOnBlockStart = true;
+ break;
+ case TABLE:
+ elementName = "informaltable"; //$NON-NLS-1$
+ break;
+ case TABLE_CELL_HEADER:
+ elementName = "th"; //$NON-NLS-1$
+ break;
+ case TABLE_CELL_NORMAL:
+ elementName = "td"; //$NON-NLS-1$
+ break;
+ case TABLE_ROW:
+ elementName = "tr"; //$NON-NLS-1$
+ break;
+ case INFORMATION:
+ elementName = "important"; //$NON-NLS-1$
+ allowTitle = true;
+ break;
+ case NOTE:
+ elementName = "note"; //$NON-NLS-1$
+ allowTitle = true;
+ break;
+ case WARNING:
+ elementName = "warning"; //$NON-NLS-1$
+ allowTitle = true;
+ break;
+ case TIP:
+ elementName = "tip"; //$NON-NLS-1$
+ allowTitle = true;
+ break;
+ case PANEL:
+ elementName = "note"; // docbook has nothing better for 'note' //$NON-NLS-1$
+ allowTitle = true;
+ break;
+ case DIV:
+ elementName = null;
+ break;
+ default:
+ throw new IllegalStateException(type.name());
+ }
+
+ int blockSize;
+ if (elementName != null) {
+ blockSize = 1;
+
+ if (previousBlock != null && previousBlock.closeElementsOnBlockStart) {
+ endBlockEntry(previousBlock);
+ }
+
+ writer.writeStartElement(elementName);
+ applyAttributes(attributes);
+
+ if (elementNames != null) {
+ for (String name : elementNames) {
+ writer.writeStartElement(name);
+ }
+ }
+
+ if (allowTitle && attributes.getTitle() != null) {
+ writer.writeStartElement("title"); //$NON-NLS-1$
+ writer.writeCharacters(attributes.getTitle());
+ writer.writeEndElement();
+ }
+ } else {
+ blockSize = 0;
+ }
+ blockDescriptions.push(new BlockDescription(type, blockSize, elementNames, closeElementsOnBlockStart));
+ }
+
+ @Override
+ public void endBlock() {
+ final BlockDescription blockDescription = blockDescriptions.pop();
+ int size = blockDescription.size + blockDescription.entrySize;
+ for (int x = 0; x < size; ++x) {
+ writer.writeEndElement();
+ }
+ }
+
+ private void endBlockEntry(BlockDescription blockDescription) {
+ for (int x = 0; x < blockDescription.entrySize; ++x) {
+ writer.writeEndElement();
+ }
+ blockDescription.entrySize = 0;
+ }
+
+ private void openBlockEntry(BlockDescription blockDescription, String[] entry) {
+ for (String ent : entry) {
+ writer.writeStartElement(ent);
+ }
+ blockDescription.entrySize += entry.length;
+ }
+
+ @Override
+ public void beginHeading(int level, Attributes attributes) {
+ closeSections(Math.max(level - 1, 0));
+
+ while (headingLevel < level) {
+ headingLevel++;
+
+ if (headingLevel == 1) {
+ writer.writeStartElement("chapter"); //$NON-NLS-1$
+ writer.writeNamespace("", namespace);
+
+ } else {
+ writer.writeStartElement("section"); //$NON-NLS-1$
+ }
+ if (attributes != null) {
+ applyAttributes(attributes);
+ attributes = null;
+ }
+
+ headingDescriptions.push(new HeadingDescription(level, attributes));
+ }
+
+ writer.writeStartElement("title"); //$NON-NLS-1$
+ }
+
+ @Override
+ public void endHeading() {
+ writer.writeEndElement(); // title
+ }
+
+ @Override
+ public void beginDocument() {
+ baseInHead = false;
+ }
+
+ @Override
+ public void beginSpan(SpanType type, Attributes attributes) {
+ ensureBlockElementsOpen();
+ switch (type) {
+ case BOLD:
+ case STRONG:
+ writer.writeStartElement("emphasis"); //$NON-NLS-1$
+ writer.writeAttribute("role", "bold"); //$NON-NLS-1$ //$NON-NLS-2$
+ break;
+ case CITATION:
+ writer.writeStartElement("citation"); //$NON-NLS-1$
+ break;
+ case CODE:
+ writer.writeStartElement("code"); //$NON-NLS-1$
+ break;
+ case DELETED:
+ writer.writeStartElement("emphasis"); //$NON-NLS-1$
+ writer.writeAttribute("role", "del"); //$NON-NLS-1$ //$NON-NLS-2$
+ break;
+ case EMPHASIS:
+ writer.writeStartElement("emphasis"); //$NON-NLS-1$
+ break;
+ case INSERTED:
+ writer.writeStartElement("emphasis"); //$NON-NLS-1$
+ writer.writeAttribute("role", "ins"); //$NON-NLS-1$ //$NON-NLS-2$
+ break;
+ case UNDERLINED:
+ writer.writeStartElement("emphasis"); //$NON-NLS-1$
+ writer.writeAttribute("role", "underline"); //$NON-NLS-1$ //$NON-NLS-2$
+ break;
+ case ITALIC:
+ writer.writeStartElement("emphasis"); //$NON-NLS-1$
+ writer.writeAttribute("role", "italic"); //$NON-NLS-1$ //$NON-NLS-2$
+ break;
+ case QUOTE:
+ writer.writeStartElement("quote"); //$NON-NLS-1$
+ break;
+ case SPAN:
+ writer.writeStartElement("phrase"); //$NON-NLS-1$
+ break;
+ case SUBSCRIPT:
+ writer.writeStartElement("subscript"); //$NON-NLS-1$
+ break;
+ case SUPERSCRIPT:
+ writer.writeStartElement("superscript"); //$NON-NLS-1$
+ break;
+ case MONOSPACE:
+ writer.writeStartElement("literal"); //$NON-NLS-1$
+ break;
+ case LINK: {
+ LinkAttributes linkAttributes = (LinkAttributes) attributes;
+ String href = linkAttributes.getHref();
+ if (href.startsWith("#")) { //$NON-NLS-1$
+ writer.writeStartElement("link"); //$NON-NLS-1$
+ if (href.length() > 1) {
+ writer.writeAttribute("linkend", href.substring(1)); //$NON-NLS-1$
+ }
+ } else {
+ writer.writeStartElement("ulink"); //$NON-NLS-1$
+ writer.writeAttribute("url", href); //$NON-NLS-1$
+ }
+ }
+ break;
+ default:
+ Logger.getLogger(DocBookDocumentBuilder.class.getName()).warning("No docbook mapping for " + type); //$NON-NLS-1$
+ writer.writeStartElement("phrase"); //$NON-NLS-1$
+ break;
+ }
+ applyAttributes(attributes);
+ }
+
+ private void applyAttributes(Attributes attributes) {
+ if (attributes.getId() != null) {
+ writer.writeAttribute("id", attributes.getId()); //$NON-NLS-1$
+ }
+ if (attributes.getLanguage() != null) {
+ writer.writeAttribute("language", attributes.getLanguage()); //$NON-NLS-1$
+ }
+ }
+
+ @Override
+ public void endDocument() {
+ closeSections(0);
+
+ writeGlossaryAppendix();
+
+// writer.writeEndElement(); // book
+ writer.writeEndDocument();
+
+ acronyms.clear();
+ }
+
+ private void closeSections(int toLevel) {
+ if (toLevel < 0) {
+ toLevel = 0;
+ }
+ while (headingLevel > toLevel) {
+ writer.writeEndElement();
+ --headingLevel;
+ headingDescriptions.pop();
+ }
+ }
+
+ private void writeGlossaryAppendix() {
+ if (!acronyms.isEmpty() && automaticGlossary) {
+ writer.writeStartElement("appendix"); //$NON-NLS-1$
+ writer.writeAttribute("id", "glossary"); //$NON-NLS-1$ //$NON-NLS-2$
+ writer.writeStartElement("title"); //$NON-NLS-1$
+ writer.writeAttribute("id", "glossary-end"); //$NON-NLS-1$ //$NON-NLS-2$
+ writer.writeCharacters("Glossary"); //$NON-NLS-1$
+ writer.writeEndElement(); // title
+ writer.writeStartElement("glosslist"); //$NON-NLS-1$
+
+ for (Map.Entry<String, String> glossEntry : new TreeMap<String, String>(acronyms).entrySet()) {
+
+ writer.writeStartElement("glossentry"); //$NON-NLS-1$
+
+ writer.writeStartElement("glossterm"); //$NON-NLS-1$
+ writer.writeCharacters(glossEntry.getKey());
+ writer.writeEndElement(); // glossterm
+
+ writer.writeStartElement("glossdef"); //$NON-NLS-1$
+ writer.writeStartElement("para"); //$NON-NLS-1$
+ writer.writeCharacters(glossEntry.getValue());
+ writer.writeEndElement(); // para
+ writer.writeEndElement(); // glossdef
+
+ writer.writeEndElement(); // glossentry
+ }
+ writer.writeEndElement(); // glosslist
+ writer.writeEndElement(); // appendix
+ }
+ }
+
+ @Override
+ public void endSpan() {
+ writer.writeEndElement();
+ }
+
+ @Override
+ public void characters(String text) {
+ ensureBlockElementsOpen();
+ super.characters(text);
+ }
+
+ @Override
+ public void charactersUnescaped(String literal) {
+ ensureBlockElementsOpen();
+ // note: this *may* have HTML tags in it
+ writer.writeLiteral(literal);
+ // Logger.getLogger(DocBookDocumentBuilder.class.getName()).warning("HTML literal not supported in DocBook");
+ }
+
+ private void ensureBlockElementsOpen() {
+ if (!blockDescriptions.isEmpty()) {
+ BlockDescription blockDescription = blockDescriptions.peek();
+ if (blockDescription.entrySize == 0 && blockDescription.nestedElementNames != null) {
+ openBlockEntry(blockDescription, blockDescription.nestedElementNames);
+ }
+ }
+ }
+
+ @Override
+ public void entityReference(String entity) {
+ ensureBlockElementsOpen();
+ if (entity.startsWith("#")) { //$NON-NLS-1$
+ String numeric = entity.substring(1);
+ int base = 10;
+ if (numeric.startsWith("x")) { //$NON-NLS-1$
+ numeric = entity.substring(1);
+ base = 16;
+ }
+ int unicodeValue = Integer.parseInt(numeric, base);
+ if (entityReferenceToUnicode.contains(unicodeValue)) {
+ writer.writeCharacters("" + ((char) unicodeValue)); //$NON-NLS-1$
+ return;
+ }
+ }
+ writer.writeEntityRef(entity);
+ }
+
+ @Override
+ public void image(Attributes attributes, String url) {
+ ensureBlockElementsOpen();
+ String cssClass = attributes.getCssClass();
+ boolean inlined = false;
+ if (cssClass != null && CSS_CLASS_INLINE.matcher(cssClass).find()) {
+ inlined = true;
+ }
+ emitImage(attributes, url, inlined);
+ }
+
+ private void emitImage(Attributes attributes, String url, boolean inline) {
+ // see http://www.docbook.org/tdg/en/html/imagedata-x.html
+ ensureBlockElementsOpen();
+ writer.writeStartElement(inline ? "inlinemediaobject" : "mediaobject"); //$NON-NLS-1$ //$NON-NLS-2$
+ applyAttributes(attributes);
+ writer.writeStartElement("imageobject"); //$NON-NLS-1$
+ writer.writeEmptyElement("imagedata"); //$NON-NLS-1$
+ writer.writeAttribute("fileref", makeUrlAbsolute(url)); //$NON-NLS-1$
+ String cssStyle = attributes.getCssStyle();
+ if (cssStyle != null) {
+ String width = null;
+ String depth = null;
+ Iterator<CssRule> ruleIterator = new CssParser().createRuleIterator(cssStyle);
+ while (ruleIterator.hasNext()) {
+ CssRule rule = ruleIterator.next();
+ if ("width".equals(rule.name)) { //$NON-NLS-1$
+ width = rule.value;
+ } else if ("height".equals(rule.name)) { //$NON-NLS-1$
+ depth = rule.value;
+ }
+ }
+ if (width != null) {
+ Matcher matcher = PERCENTAGE.matcher(width);
+ if (matcher.matches()) {
+ writer.writeAttribute("scale", matcher.group(1)); //$NON-NLS-1$
+ } else {
+ writer.writeAttribute("width", width); //$NON-NLS-1$
+ if (depth != null) {
+ writer.writeAttribute("depth", depth); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ writer.writeEndElement(); // imageobject
+ writer.writeEndElement(); // inlinemediaobject or mediaobject
+ }
+
+ @Override
+ public void imageLink(Attributes linkAttributes, final Attributes imageAttributes, String href,
+ final String imageUrl) {
+ link(linkAttributes, href, new ContentEmitter() {
+ public void emit() {
+ emitImage(imageAttributes, imageUrl, true);
+ }
+ });
+ }
+
+ @Override
+ public void lineBreak() {
+ ensureBlockElementsOpen();
+ // no equivalent in DocBook.
+ characters("\n"); //$NON-NLS-1$
+ }
+
+ private BlockDescription findBlockDescription(BlockType type) {
+ for (int x = blockDescriptions.size() - 1; x >= 0; --x) {
+ BlockDescription blockDescription = blockDescriptions.get(x);
+ if (blockDescription.type == type) {
+ return blockDescription;
+ }
+ }
+ return null;
+ }
+
+ private static class BlockDescription {
+ BlockType type;
+
+ int size;
+
+ int entrySize; // the size of an entry, if it is open, otherwise 0
+
+ final String[] nestedElementNames;
+
+ final boolean closeElementsOnBlockStart;
+
+ public BlockDescription(DocumentBuilder.BlockType type, int size, String[] nestedElementNames, boolean closeElementsOnBlockStart) {
+ this.size = size;
+ this.entrySize = nestedElementNames == null ? 0 : nestedElementNames.length;
+ this.type = type;
+ this.nestedElementNames = nestedElementNames;
+ this.closeElementsOnBlockStart = closeElementsOnBlockStart;
+ }
+ }
+
+ private static class HeadingDescription {
+
+ int level;
+ Attributes attributes;
+
+ private HeadingDescription(int level, Attributes attributes) {
+ this.level = level;
+ this.attributes = attributes;
+ }
+ }
+
+ /**
+ * Indicate if this builder should generate an automatic glossary if acronyms are used. When the automatic glossary
+ * is enabled and acronyms are used in the document, then an <code>appendix</code> with title 'Glossary' is added to
+ * the document, with a <code>glosslist</code> generated for all of the acronyms that appear in the document. The
+ * default is true.
+ */
+ public boolean isAutomaticGlossary() {
+ return automaticGlossary;
+ }
+
+ /**
+ * Indicate if this builder should generate an automatic glossary if acronyms are used. When the automatic glossary
+ * is enabled and acronyms are used in the document, then an <code>appendix</code> with title 'Glossary' is added to
+ * the document, with a <code>glosslist</code> generated for all of the acronyms that appear in the document. The
+ * default is true.
+ */
+ public void setAutomaticGlossary(boolean automaticGlossary) {
+ this.automaticGlossary = automaticGlossary;
+ }
+
+}
Modified: servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/java/org/apache/servicemix/docs/confluence/ConfluenceDocumentTest.java
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/java/org/apache/servicemix/docs/confluence/ConfluenceDocumentTest.java?rev=956861&r1=956860&r2=956861&view=diff
==============================================================================
--- servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/java/org/apache/servicemix/docs/confluence/ConfluenceDocumentTest.java (original)
+++ servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/java/org/apache/servicemix/docs/confluence/ConfluenceDocumentTest.java Tue Jun 22 12:28:53 2010
@@ -70,14 +70,15 @@ public class ConfluenceDocumentTest {
List<String> expected = IOUtils.readLines(getClass().getResourceAsStream(name + ".xml"));
- ConfluenceConverter document =
- new ConfluenceConverter(new InputStreamReader(getClass().getResourceAsStream(name + ".wiki")),
- writer);
+ ConfluenceConverter document = new ConfluenceConverter();
- document.convert();
+ document.convert(new InputStreamReader(getClass().getResourceAsStream(name + ".wiki")),
+ writer);
writer.flush();
writer.close();
+// System.err.println(writer.toString());
+
String[] results = writer.toString().split("\\r?\\n\\r?");
int i = 0;
Modified: servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/code-blocks.xml
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/code-blocks.xml?rev=956861&r1=956860&r2=956861&view=diff
==============================================================================
--- servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/code-blocks.xml (original)
+++ servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/code-blocks.xml Tue Jun 22 12:28:53 2010
@@ -1,9 +1,9 @@
-<chapter xmlns="http://docbook.org/ns/docbook">
+<chapter xmlns="http://docbook.org/ns/docbook" id="Chapter">
<title>Chapter</title>
- <section>
+ <section id="Section1">
<title>Section 1</title>
- <para>
- This section contains a piece of <code>code text</code>.
+ <para>This section contains a piece of
+ <literal>code text</literal>.
</para>
<programlisting><![CDATA[
<?xml version="1.0"?>
@@ -12,11 +12,9 @@
</hello>
]]></programlisting>
</section>
- <section>
+ <section id="Section2">
<title>Section 2</title>
- <para>
- The next one specifies the language for the code block.
- </para>
+ <para>The next one specifies the language for the code block.</para>
<programlisting language="xml"><![CDATA[
<?xml version="1.0"?>
<hello>
@@ -24,7 +22,9 @@
</hello>
]]></programlisting>
</section>
- <section>
- <title>Section with <code>code text</code></title>
+ <section id="Sectionwithcodetext">
+ <title>Section with
+ <literal>code text</literal>
+ </title>
</section>
</chapter>
\ No newline at end of file
Modified: servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/document1.xml
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/document1.xml?rev=956861&r1=956860&r2=956861&view=diff
==============================================================================
--- servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/document1.xml (original)
+++ servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/document1.xml Tue Jun 22 12:28:53 2010
@@ -1,12 +1,12 @@
-<chapter xmlns="http://docbook.org/ns/docbook">
+<chapter xmlns="http://docbook.org/ns/docbook" id="Chapter">
<title>Chapter</title>
- <section>
+ <section id="Section1">
<title>Section 1</title>
- <section>
+ <section id="Section1.1">
<title>Section 1.1</title>
</section>
</section>
- <section>
+ <section id="Section2">
<title>Section 2</title>
</section>
</chapter>
\ No newline at end of file
Modified: servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/document2.xml
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/document2.xml?rev=956861&r1=956860&r2=956861&view=diff
==============================================================================
--- servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/document2.xml (original)
+++ servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/document2.xml Tue Jun 22 12:28:53 2010
@@ -1,18 +1,12 @@
-<chapter xmlns="http://docbook.org/ns/docbook">
+<chapter xmlns="http://docbook.org/ns/docbook" id="Chapter">
<title>Chapter</title>
- <section>
+ <section id="Section1">
<title>Section 1</title>
- <para>
- Paragraph 1 starts here...
- </para>
- <para>
- Paragraph 2 starts here...
- </para>
- <section>
+ <para>Paragraph 1 starts here...</para>
+ <para>Paragraph 2 starts here...</para>
+ <section id="Section1.1">
<title>Section 1.1</title>
- <para>
- And one more paragraph
- </para>
+ <para>And one more paragraph</para>
</section>
</section>
</chapter>
\ No newline at end of file
Modified: servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/images.xml
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/images.xml?rev=956861&r1=956860&r2=956861&view=diff
==============================================================================
--- servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/images.xml (original)
+++ servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/images.xml Tue Jun 22 12:28:53 2010
@@ -1,12 +1,14 @@
-<chapter xmlns="http://docbook.org/ns/docbook">
+<chapter xmlns="http://docbook.org/ns/docbook" id="Chapter">
<title>Chapter</title>
- <section>
+ <section id="Section1">
<title>Section 1</title>
+ <para>This section contains an image</para>
<para>
- This section contains an image
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="image.png"/>
+ </imageobject>
+ </mediaobject>
</para>
- <imageobject>
- <imagedata fileref="image.png"/>
- </imageobject>
</section>
</chapter>
\ No newline at end of file
Modified: servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/links.wiki
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/links.wiki?rev=956861&r1=956860&r2=956861&view=diff
==============================================================================
--- servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/links.wiki (original)
+++ servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/links.wiki Tue Jun 22 12:28:53 2010
@@ -1,5 +1,7 @@
h1. Chapter
+{anchor:My Anchor}
+
h2. Section 1
This section contains a simple link to [http://www.google.be]
@@ -15,3 +17,10 @@ h2. Section 4
h2. Section 5
[http://www.google.be]
+
+h2. Section 6
+[#Section 5]
+
+h2. Section 7
+[#My Anchor]
+
Modified: servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/links.xml
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/links.xml?rev=956861&r1=956860&r2=956861&view=diff
==============================================================================
--- servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/links.xml (original)
+++ servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/links.xml Tue Jun 22 12:28:53 2010
@@ -1,41 +1,56 @@
-<chapter xmlns="http://docbook.org/ns/docbook">
+<chapter xmlns="http://docbook.org/ns/docbook" id="Chapter">
<title>Chapter</title>
- <section>
+ <para>
+ <phrase id="MyAnchor"></phrase>
+ </para>
+ <section id="Section1">
<title>Section 1</title>
- <para>
- This section contains a simple link to <ulink url="http://www.google.be">http://www.google.be</ulink>
+ <para>This section contains a simple link to
+ <ulink url="http://www.google.be">http://www.google.be</ulink>
</para>
</section>
- <section>
+ <section id="Section2">
<title>Section 2</title>
- <para>
- Click <ulink url="http://www.google.be">here</ulink> to follow the link with text
+ <para>Click
+ <ulink url="http://www.google.be">here</ulink> to follow the link with text
</para>
</section>
- <section>
+ <section id="Section3">
<title>Section 3</title>
- <para>
- Links in a variable list
+ <para>Links in a variable list</para>
<variablelist>
<varlistentry>
<term>search provider</term>
<listitem>
- <para><ulink url="http://www.google.be">Google</ulink> is often used for searching the web</para>
+ <para>
+ <ulink url="http://www.google.be">Google</ulink> is often used for searching the web
+ </para>
</listitem>
</varlistentry>
</variablelist>
- </para>
</section>
- <section>
+ <section id="Section4">
<title>Section 4</title>
<para>
<ulink url="http://www.google.be">Google</ulink>
</para>
</section>
- <section>
+ <section id="Section5">
<title>Section 5</title>
<para>
<ulink url="http://www.google.be">http://www.google.be</ulink>
</para>
</section>
+ <section id="Section6">
+ <title>Section 6</title>
+ <para>
+ <link linkend="Section5">Section 5</link>
+ </para>
+ </section>
+ <section id="Section7">
+ <title>Section 7</title>
+ <para>
+ <link linkend="MyAnchor">My Anchor</link>
+ </para>
+ </section>
</chapter>
\ No newline at end of file
Modified: servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/lists.xml
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/lists.xml?rev=956861&r1=956860&r2=956861&view=diff
==============================================================================
--- servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/lists.xml (original)
+++ servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/lists.xml Tue Jun 22 12:28:53 2010
@@ -1,43 +1,42 @@
-<chapter xmlns="http://docbook.org/ns/docbook">
+<chapter xmlns="http://docbook.org/ns/docbook" id="Chapter">
<title>Chapter</title>
- <section>
+ <section id="Section1">
<title>Section 1</title>
- <para>
- This section contains a bulleted list:
+ <para>This section contains a bulleted list:</para>
<itemizedlist>
<listitem>
<para>item 1</para>
</listitem>
<listitem>
- <para><code>item 2</code></para>
+ <para>
+ <literal>item 2</literal>
+ </para>
</listitem>
<listitem>
<para>item 3</para>
</listitem>
</itemizedlist>
- </para>
</section>
- <section>
+ <section id="Section2">
<title>Section 2</title>
- <para>
- This section contains a numbered list:
+ <para>This section contains a numbered list:</para>
<orderedlist>
<listitem>
<para>item 1</para>
</listitem>
<listitem>
- <para><code>item 2</code></para>
+ <para>
+ <literal>item 2</literal>
+ </para>
</listitem>
<listitem>
<para>item 3</para>
</listitem>
</orderedlist>
- </para>
</section>
- <section>
+ <section id="Variablelist">
<title>Variable list</title>
- <para>
- This section contains a variable list:
+ <para>This section contains a variable list:</para>
<variablelist>
<varlistentry>
<term>term1</term>
@@ -46,9 +45,13 @@
</listitem>
</varlistentry>
<varlistentry>
- <term><code>term2</code></term>
+ <term>
+ <literal>term2</literal>
+ </term>
<listitem>
- <para>Definition for term2 (including <code>code text</code>)</para>
+ <para>Definition for term2 (including
+ <literal>code text</literal>)
+ </para>
</listitem>
</varlistentry>
<varlistentry>
@@ -58,6 +61,5 @@
</listitem>
</varlistentry>
</variablelist>
- </para>
</section>
</chapter>
\ No newline at end of file
Modified: servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/tables.xml
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/tables.xml?rev=956861&r1=956860&r2=956861&view=diff
==============================================================================
--- servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/tables.xml (original)
+++ servicemix/maven-plugins/docs-maven-plugin/trunk/src/test/resources/org/apache/servicemix/docs/confluence/tables.xml Tue Jun 22 12:28:53 2010
@@ -1,30 +1,28 @@
-<chapter xmlns="http://docbook.org/ns/docbook">
+<chapter xmlns="http://docbook.org/ns/docbook" id="Chapter">
<title>Chapter</title>
- <section>
+ <section id="Aninformaltable">
<title>An informal table</title>
- <para>
- This section contains an informal table:
+ <para>This section contains an informal table:</para>
<informaltable>
- <thead>
<tr>
- <td>Header 1</td>
- <td>Header 2</td>
- <td>Header 3</td>
+ <th>Header 1</th>
+ <th>Header 2</th>
+ <th>Header 3</th>
</tr>
- </thead>
- <tbody>
<tr>
<td>Val 1.1</td>
<td>Val 1.2</td>
- <td><code>Val 1.3</code></td>
+ <td>
+ <literal>Val 1.3</literal>
+ </td>
</tr>
<tr>
<td>Val 2.1</td>
<td>Val 2.2</td>
- <td><code>Val 2.3</code></td>
+ <td>
+ <literal>Val 2.3</literal>
+ </td>
</tr>
- </tbody>
</informaltable>
- </para>
</section>
</chapter>
\ No newline at end of file