Alternate Syntax Quickstart

This quickstart describes how to create your own alternate syntax that is used to identify tags that will be handled by tag handlers. The XML syntax is the normal syntax that comes to mind when considering what tags look like. However, Tagneto was constructed to allow anything you can define as a regular expression to be considered a tag. The restrictions:
  1. The tag must have either a distinct start syntax, a tag body and a distinct end syntax. Example using XML syntax:
    <namespace:tagname> (start syntax)
    (tag body goes here)
    </namespace:tagname> (end syntax)
    the tag cannot have any body and end syntax. Examples using XML syntax and XML entity syntax:
    <namespace:tagname />
  2. Be careful of defining too many tag syntaxes. At some point the different regular expressions will interact in ways that cause undesirable effects.
Prerequisites for creating an alternate syntax:
  1. Download and and install Tagneto.
  2. Define a tagneticconfig configuration file. As part of the file, use the <elementsyntax> element to define what class will implement the Alternate Syntax.
You have to options to create an alternate syntax:

1. SimpleTagMatcher

Use org.tagnetic.core.parser.tagmatcher.SimpleTagMatcher to specify an simple alternate syntax that does not allow for tag bodies and end tag syntax. This is the class that is used to define the XML entity tag syntax that is supported by Tagneto.
SimpleTagMatcher allows you to specify a tag prefix, suffix, attribute separator and an name value separator. Here is the configuration that is used to support the XML entity syntax:
<elementsyntax classname="org.tagnetic.core.parser.tagmatcher.SimpleTagMatcher">
    <param name="prefix">&amp;</param>
    <param name="suffix">;</param>
    <param name="attributeseparator">-</param>
    <param name="namevalueseparator">:</param>
This will match tags that look like this:
Notice that the namespace and tagName are treated like a name value pair. SimpleTagMatcher recognizes the first name/value pair as the namespace and tag name, and treats the rest of the name/value pairs as attribute names and values.

2. Implement TagMatcher Interface

Create your own class that extends the org.tagnetic.core.parser.tagmatcher.TagMatcher interface. Use that class in the <elementsyntax> configuration element. An example of this is org.tagnetic.core.parser.tagmatcher.XmlTagMatcher, which provides the XML tag syntax matching for Tagneto.You can see both of the tag matcher classes described above in the Tagneto configuration files. These files are in the build package under the config directory, in a file called Syntax.xml.
Copyright © 2005