com.g11ntoolkit.parser.html
Class NekoDOMParser

java.lang.Object
  |
  +--com.g11ntoolkit.parser.html.NekoDOMParser

public class NekoDOMParser
extends java.lang.Object

CyberNeko HTML/JSP Parser walker for creating XLIFF file.

This class requires CyberNeko HTML Parser which is patched for supporting JSP format.

Version:
$Revision: 1.4 $ $Date: 2005/07/26 18:25:15 $
Copyright © 2005, webMethods, Inc. All rights reserved.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

See License Agreement.

Author:
Masahiko Mori
See Also:
XLIFFBuilder, XHTMLWriter, org.w3c.dom

Field Summary
private  int _acflg
          Auto correction flag
private  java.lang.String _contextFile
          Target file language (Default: NULL)
private  boolean _DBG
          Debug flag
private  boolean _dspflg
          DSP file type flag
private  java.lang.String _ftype
          File type (Default: Unknown)
private  boolean _htmlflg
          HTML file type flag
private  java.lang.String _inEnc
          Source file encoding (Default: ISO8859_1)
This encoding name have to match org.apache.xerces.util.EncodingMap
private  java.lang.String _inLang
          Source file language (Default: en-us)
private  boolean _jspflg
          JSP file type flag
private  java.lang.String _outEnc
          Target file encoding (Default: UTF-8)
private  java.lang.String _outFile
          Target file language (Default: nekoParser.xlf)
private  org.apache.xerces.parsers.DOMParser _parser
           
private  java.lang.String _prodName
          Product name
private  java.lang.String _prodVer
          Product version
private  short _sklMode
          Set external skelton mode for XLIFF editor
private  java.lang.String _targLang
          Target file language (Default: NULL)
private  boolean _XLEDMode
          XLIFF editor mode flag
private  XLIFFBuilder _xliff
          CyberNeko DOM parser cleass
private  boolean _xmlflg
          XML file type flag
 
Constructor Summary
NekoDOMParser()
          Create a new NekoDOMParser.
NekoDOMParser(java.lang.String file)
          Create a new NekoDOMParser with Input File name.
 
Method Summary
protected  org.apache.xerces.parsers.DOMParser createParser()
          Create Parser class with setting features and properties.
 org.apache.xerces.parsers.DOMParser getParser()
          Get Parser class.
 XLIFFBuilder getXLIFFFile()
          Get XLIFF table class.
static void main(java.lang.String[] args)
          Main program.
 void parse(java.lang.String file)
          Parse just one file.
 void parse(java.lang.String[] args)
          Parse files with option flags.
protected  void setFileType(java.lang.String arg)
          Set File type and auto tag-balance correction by file extantion.
 void setLanguage(java.lang.String targLang)
          Set target language for XLIFF file.
 void setProduct(java.lang.String prodName, java.lang.String prodVer)
          Set product name and version.
 void write()
          Print out XLIFF table to current output file in current encoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_prodName

private java.lang.String _prodName
Product name


_prodVer

private java.lang.String _prodVer
Product version


_ftype

private java.lang.String _ftype
File type (Default: Unknown)


_inLang

private java.lang.String _inLang
Source file language (Default: en-us)


_inEnc

private java.lang.String _inEnc
Source file encoding (Default: ISO8859_1)
This encoding name have to match org.apache.xerces.util.EncodingMap


_targLang

private java.lang.String _targLang
Target file language (Default: NULL)


_outEnc

private java.lang.String _outEnc
Target file encoding (Default: UTF-8)


_outFile

private java.lang.String _outFile
Target file language (Default: nekoParser.xlf)


_contextFile

private java.lang.String _contextFile
Target file language (Default: NULL)


_parser

private org.apache.xerces.parsers.DOMParser _parser

_xliff

private XLIFFBuilder _xliff
CyberNeko DOM parser cleass


_htmlflg

private boolean _htmlflg
HTML file type flag


_xmlflg

private boolean _xmlflg
XML file type flag


_jspflg

private boolean _jspflg
JSP file type flag


_dspflg

private boolean _dspflg
DSP file type flag


_acflg

private int _acflg
Auto correction flag


_XLEDMode

private boolean _XLEDMode
XLIFF editor mode flag


_sklMode

private short _sklMode
Set external skelton mode for XLIFF editor


_DBG

private boolean _DBG
Debug flag

Constructor Detail

NekoDOMParser

public NekoDOMParser()
              throws java.lang.Exception
Create a new NekoDOMParser.


NekoDOMParser

public NekoDOMParser(java.lang.String file)
              throws java.lang.Exception
Create a new NekoDOMParser with Input File name.

Parameters:
file - Input File name
Method Detail

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Main program.

Usage: This Class (Options) Files...
-h, -help: Help
-debug: Set debug mode on
-E: Set XLIFF editor mode on
-I: Set internal skelton file on
-H: Set html file type on
-X: Set xml file type on
-J: Set jsp file type on
-D: Set dsp file type on
-A: Force auto correction on
-a: Force auto correction off
-p {name}: Set Product name
-v {ver}: Set Product version
-s {lang}: Set source language (Default: "en-us")
-t {lang}: Set target language (Default: NULL)
-e {name}: Set input encoding (Default: "ISO8859_1")
-o {name}: Set output file name (Default: "nekoParser.xlf")

Parameters:
args - HTML File name and options.
java.lang.Exception

setProduct

public void setProduct(java.lang.String prodName,
                       java.lang.String prodVer)
Set product name and version.

Parameters:
prodName - Product name
prodVer - Product version

setLanguage

public void setLanguage(java.lang.String targLang)
Set target language for XLIFF file.

If the target language is specified, the <taget> section of XLIFF file is created.

Parameters:
targLang - product name. (Default: null)

getParser

public org.apache.xerces.parsers.DOMParser getParser()
Get Parser class.

Returns:
CyberNeko Parser class

getXLIFFFile

public XLIFFBuilder getXLIFFFile()
Get XLIFF table class.

Returns:
XLIFF table class

parse

public void parse(java.lang.String[] args)
           throws java.lang.Exception
Parse files with option flags.

Parameters:
args - String array of file names and options
java.lang.Exception

parse

public void parse(java.lang.String file)
           throws java.lang.Exception
Parse just one file.

Parameters:
file - Input file name
java.lang.Exception

write

public void write()
           throws java.lang.Exception
Print out XLIFF table to current output file in current encoding.

java.lang.Exception

createParser

protected org.apache.xerces.parsers.DOMParser createParser()
                                                    throws java.lang.Exception
Create Parser class with setting features and properties.

NameIDValue
CDATA Sectionhttp://cyberneko.org/html/features/scanner/cdata-sectionstrue
Notify Char Refshttp://apache.org/xml/features/scanner/notify-char-refstrue
Notify Builtin Refshttp://apache.org/xml/features/scanner/notify-builtin-refstrue
Notify Builtin Refshttp://cyberneko.org/html/features/scanner/notify-builtin-refstrue
Element namehttp://cyberneko.org/html/properties/names/elemsmatch
Attribute namehttp://cyberneko.org/html/properties/names/attrsno-change
Ignore Specified Charsethttp://cyberneko.org/html/features/scanner/ignore-specified-charsettrue
Error Reporthttp://cyberneko.org/html/features/report-errorstrue

java.lang.Exception

setFileType

protected void setFileType(java.lang.String arg)
                    throws java.lang.Exception
Set File type and auto tag-balance correction by file extantion.

In fact, in case of JSP and DSP file type, turn off auto tag-balance correction.

Parameters:
arg - File name
java.lang.Exception