Class DocBookParser

All Implemented Interfaces:
LogEnabled, Markup, XmlMarkup, DocbookMarkup, SimplifiedDocbookMarkup, Parser

@Component(role=Parser.class, hint="docbook") public class DocBookParser extends AbstractXmlParser implements DocbookMarkup, SimplifiedDocbookMarkup
Parse a Simplified DocBook document and emit events into the specified doxia Sink.
Since:
1.0
  • Field Details

    • level

      private int level
      Level counter for calculating the section level.
    • isBold

      private boolean isBold
      Used to distinguish italic from bold.
    • inHead

      private boolean inHead
    • ignore

      private boolean ignore
    • simpleTag

      private boolean simpleTag
    • trademark

      private char trademark
    • parent

      private final Stack<String> parent
      A selective stack of parent elements
    • HIER_ELEMENTS

      private static final Collection<String> HIER_ELEMENTS
      The list of DocBook elements that introduce a new level of hierarchy.
    • META_ELEMENTS

      private static final Collection<String> META_ELEMENTS
      Simplified DocBook elements that are direct children of <article> and that should be emitted into the Sink's head.
    • ARTICLEINFO_ELEMENTS

      private static final Collection<String> ARTICLEINFO_ELEMENTS
      Simplified DocBook elements that occur within <articleinfo> and that are currently recognized by the parser.
    • VERBATIM_ELEMENTS

      private static final Collection<String> VERBATIM_ELEMENTS
      The list of DocBook elements that will be rendered verbatim
    • BOLD_ELEMENTS

      private static final Collection<String> BOLD_ELEMENTS
      The list of DocBook elements that will be rendered inline and bold
    • ITALIC_ELEMENTS

      private static final Collection<String> ITALIC_ELEMENTS
      The list of DocBook elements that will be rendered inline and italic
    • MONOSPACE_ELEMENTS

      private static final Collection<String> MONOSPACE_ELEMENTS
      The list of DocBook elements that will be rendered inline and monospace
    • IGNORABLE_ELEMENTS

      private static final Collection<String> IGNORABLE_ELEMENTS
      The list of DocBook elements that may be ignored, either because they don't require any special processing or because they are not yet implemented.
  • Constructor Details

    • DocBookParser

      public DocBookParser()
  • Method Details

    • init

      protected void init()
      Initialize the parser. This is called first by AbstractParser.parse(java.io.Reader, org.apache.maven.doxia.sink.Sink) and can be used to set the parser into a clear state so it can be re-used.
      Overrides:
      init in class AbstractParser
    • handleStartTag

      protected void handleStartTag(org.codehaus.plexus.util.xml.pull.XmlPullParser parser, Sink sink) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, MacroExecutionException
      Goes through the possible start tags.
      Specified by:
      handleStartTag in class AbstractXmlParser
      Parameters:
      parser - A parser, not null.
      sink - the sink to receive the events.
      Throws:
      org.codehaus.plexus.util.xml.pull.XmlPullParserException - if there's a problem parsing the model
      MacroExecutionException - if there's a problem executing a macro
    • handleEndTag

      protected void handleEndTag(org.codehaus.plexus.util.xml.pull.XmlPullParser parser, Sink sink) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, MacroExecutionException
      Goes through the possible end tags.
      Specified by:
      handleEndTag in class AbstractXmlParser
      Parameters:
      parser - A parser, not null.
      sink - the sink to receive the events.
      Throws:
      org.codehaus.plexus.util.xml.pull.XmlPullParserException - if there's a problem parsing the model
      MacroExecutionException - if there's a problem executing a macro
    • handleComment

      protected void handleComment(org.codehaus.plexus.util.xml.pull.XmlPullParser parser, Sink sink) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
      Handles comments.

      This is a default implementation, all data are emitted as comment events into the specified sink.

      Overrides:
      handleComment in class AbstractXmlParser
      Parameters:
      parser - A parser, not null.
      sink - the sink to receive the events. Not null.
      Throws:
      org.codehaus.plexus.util.xml.pull.XmlPullParserException - if there's a problem parsing the model
    • handleCdsect

      protected void handleCdsect(org.codehaus.plexus.util.xml.pull.XmlPullParser parser, Sink sink) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
      Handles CDATA sections.

      This is a default implementation, all data are emitted as text events into the specified sink.

      Overrides:
      handleCdsect in class AbstractXmlParser
      Parameters:
      parser - A parser, not null.
      sink - the sink to receive the events. Not null.
      Throws:
      org.codehaus.plexus.util.xml.pull.XmlPullParserException - if there's a problem parsing the model
    • handleEntity

      protected void handleEntity(org.codehaus.plexus.util.xml.pull.XmlPullParser parser, Sink sink) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
      Handles entities.

      This is a default implementation, all entities are resolved and emitted as text events into the specified sink, except:

      • the entities with names #160, nbsp and #x00A0 are emitted as nonBreakingSpace() events.
      Overrides:
      handleEntity in class AbstractXmlParser
      Parameters:
      parser - A parser, not null.
      sink - the sink to receive the events. Not null.
      Throws:
      org.codehaus.plexus.util.xml.pull.XmlPullParserException - if there's a problem parsing the model
    • handleText

      protected void handleText(org.codehaus.plexus.util.xml.pull.XmlPullParser parser, Sink sink) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
      Handles text events.

      This is a default implementation, if the parser points to a non-empty text element, it is emitted as a text event into the specified sink.

      Overrides:
      handleText in class AbstractXmlParser
      Parameters:
      parser - A parser, not null.
      sink - the sink to receive the events. Not null.
      Throws:
      org.codehaus.plexus.util.xml.pull.XmlPullParserException - if there's a problem parsing the model
    • handleArticleInfoStartTags

      private void handleArticleInfoStartTags(String name, Sink sink, SinkEventAttributeSet attribs)
    • handleArticleInfoEndTags

      private void handleArticleInfoEndTags(String name, Sink sink)
    • handleCaptionStart

      private void handleCaptionStart(Sink sink, SinkEventAttributeSet attribs)
    • handleCaptionEnd

      private void handleCaptionEnd(Sink sink)
    • handleEmailStart

      private void handleEmailStart(org.codehaus.plexus.util.xml.pull.XmlPullParser parser, Sink sink, SinkEventAttributeSet attribs) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
      Throws:
      org.codehaus.plexus.util.xml.pull.XmlPullParserException
    • handleFigureStart

      private void handleFigureStart(Sink sink, SinkEventAttributeSet attribs)
    • handleArticleStart

      private void handleArticleStart(Sink sink, SinkEventAttributeSet attribs)
    • handleSectionElements

      private void handleSectionElements(Sink sink, String name, SinkEventAttributeSet attribs)
    • handleAnchorStart

      private void handleAnchorStart(Sink sink, SinkEventAttributeSet attribs)
    • handleImageDataStart

      private void handleImageDataStart(Sink sink, SinkEventAttributeSet attribs) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
      Throws:
      org.codehaus.plexus.util.xml.pull.XmlPullParserException
    • handleItemizedListStart

      private void handleItemizedListStart(Sink sink, SinkEventAttributeSet attribs)
    • handleLinkStart

      private void handleLinkStart(Sink sink, SinkEventAttributeSet attribs) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
      Throws:
      org.codehaus.plexus.util.xml.pull.XmlPullParserException
    • handleListItemStart

      private void handleListItemStart(Sink sink, SinkEventAttributeSet attribs)
    • handleOrderedListStart

      private void handleOrderedListStart(Sink sink, SinkEventAttributeSet attribs)
    • handleParaEnd

      private void handleParaEnd(Sink sink)
    • handleParaStart

      private void handleParaStart(Sink sink, SinkEventAttributeSet attribs)
    • handleTableStart

      private void handleTableStart(Sink sink, SinkEventAttributeSet attribs)
    • handleTitleStart

      private void handleTitleStart(Sink sink, SinkEventAttributeSet attribs)
    • handleTitleEnd

      private void handleTitleEnd(Sink sink)
    • handleUlinkStart

      private void handleUlinkStart(Sink sink, SinkEventAttributeSet attribs) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
      Throws:
      org.codehaus.plexus.util.xml.pull.XmlPullParserException
    • handleVariableListStart

      private void handleVariableListStart(Sink sink, SinkEventAttributeSet attribs)
    • handleXrefStart

      private void handleXrefStart(Sink sink, SinkEventAttributeSet attribs) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
      Throws:
      org.codehaus.plexus.util.xml.pull.XmlPullParserException
    • ignorable

      private boolean ignorable(String name)
    • isParent

      private boolean isParent(String element)
      Determines if the given element is a parent element.
      Parameters:
      element - the element to determine.
      Returns:
      true if the given element is a parent element.
    • linkStartTag

      private boolean linkStartTag(String name, Sink sink, SinkEventAttributeSet attribs) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
      Throws:
      org.codehaus.plexus.util.xml.pull.XmlPullParserException
    • listStartTags

      private boolean listStartTags(String name, Sink sink, SinkEventAttributeSet attribs)
    • mediaStartTag

      private boolean mediaStartTag(String name, Sink sink, SinkEventAttributeSet attribs) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
      Throws:
      org.codehaus.plexus.util.xml.pull.XmlPullParserException
    • styleStartTags

      private boolean styleStartTags(String name, Sink sink, SinkEventAttributeSet attribs)
    • tableStartTags

      private boolean tableStartTags(String name, Sink sink, SinkEventAttributeSet attribs)