[page XML Configured Processor] [t1]XML Configured Processor[t1] [section] The [javadoc hoglet,org.hoglet.tools.XMLConfiguredProcessor,lastid=y /] class allows a [javadoc hoglet,org.hoglet.Processor,lastid=y /] instance to be configured via a XML file. The XML file should define the [link tags.html]tags[link] and [link tag-handlers.html]tag handlers[link] that hoglet should use to process a string of text. It should also contain what delimiters that hoglet should in processing the text. See an example: [link tag-handlers.xml /] file. The file passed to the processor should have a root element of: tagHandlers. [t3]Usage[t3] To use the processor just do: [java linenums=y] XMLConfiguredProcessor xcp = new XMLConfiguredProcessor ( new File ("/path/to/tag-handlers.xml")); // Process a file. String content = xcp.process (new File ("/path/to/myfile.txt")); [java] Alternatively you could use the: [link tools.html#FileProcessor]FileProcessor[link] to process a file. [/section] [t2]Defining Tag Handlers[t2] [section] Each tag handler is defined by using a handler element, which should be a child of: tagHandlers. [t3]Element definition[t3] The table below defines the elements that can be used in defining a tag handler to be used by hoglet in the XML file. Note: attributes are marked with either a R - meaning the attribute is required and must have a non-blank value or O - meaning the attribute is optional. [table] [tr header]Element|Attributes|Required|Child Elements|Parent Elements|Description[tr] [tr]handler|class (string, R), tag (string, R)|Yes|init|tagHandlers|Defines a tag handler that hoglet should use in processing a string of text. The class attribute should be a fully-qualified class name of a class that implements the [javadoc hoglet,org.hoglet.handlers.TagHandler,lastid=y /] interface. The tag attribute should be a string that defines the tag to be used. The child element init will be passed to the handler instance, but only if the class implements the [javadoc hoglet,org.hoglet.handlers.core.JDOMInitable,lastid=y /] interface. The class must also have a no-args constructor.[tr] [tr]init|Variable upon the handler|No|Variable upon the handler|handler|This element will be passed to the handler instance if it implements the [javadoc hoglet,org.hoglet.handlers.core.JDOMInitable,lastid=y /] interface. The content of this element and whether it has any attributes is entirely dependent upon the handler.[tr] [table] [t3]Example[t3] [xml] \[\[VALUE]]]]> [xml] [/section] [t2]Specifying Delimiters[t2] [section] The delimiters that hoglet should use are also defined in the XML file. Each delimiter is specified by using an attribute on the tagHandlers element. All the attributes are required and must have a non-blank value. Only the first character of the attribute is used as the delimiter. The attributes are: [table] [tr header]Name|Description[tr] [tr]openTag|Is the delimiter for the opening of a tag, i.e. \[.[tr] [tr]closeTag|Is the delimiter for the closing of a tag, i.e. ].[tr] [tr]shortClosePrefix|Is the delimiter for closing an opening tag that doesn't have an end tag, it can also be used to prefix an end tag, i.e. /.[tr] [tr]escape|Is the delimiter for escaping other delimiters, i.e. \.[tr] [tr]tagOptionsSeparator|Is the delimiter for separating a tag name from it's options, i.e. whitespace.[tr] [tr]optionsSeparator|Is the delimiter for separating options, i.e. ,.[tr] [tr]optionNameSeparator|Is the delimiter for separating option names and values, i.e. =.[tr] [table] [t3]Example[t3] [xml] [xml] [/section] [t2]The _default handler[t2] [section] The [link tag-handlers.html#Default Handler]default handler[link] is specified by using a tag name _default for a handler definition. [t3]Example[t3] [xml] [xml] [/section] [/page]