Package org.omegat.filters3.xml
Class Handler
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.omegat.filters3.xml.Handler
- All Implemented Interfaces:
ContentHandler,DTDHandler,EntityResolver,ErrorHandler,DeclHandler,LexicalHandler
The part of XML filter that actually does the job. This class is called back
by SAXParser.
Entities described on Add entities in XML ENTITY Declaration
-
Constructor Summary
ConstructorsConstructorDescriptionHandler(Translator translator, XMLDialect dialect, File inFile, @Nullable File outFile, FilterContext fc) Creates a new instance of Handler -
Method Summary
Modifier and TypeMethodDescriptionvoidNot used: An attribute type declaration.voidcharacters(char[] ch, int start, int length) Receive notification of character data inside an element.voidcomment(char[] ch, int start, int length) Receive notification of an XML comment anywhere in the document.Resolves an external entity and provides an InputSource for the entity.voidelementDecl(String name, String model) Not used: An element type declaration.voidendCDATA()Report the end of a CDATA section.voidReceive notification of the end of the document.voidendDTD()Report the end of DTD declarations.voidendElement(String uri, String localName, String qName) Receive notification of the end of an element.voidReport the end of an entity.voidexternalEntityDecl(String name, String publicId, String systemId) Report a parsed external entity declaration.voidReport a fatal XML parsing error.Returns external files this handler has processed, because they were included into main file.voidignorableWhitespace(char[] ch, int start, int length) Receive notification of ignorable whitespace in element content.voidinternalEntityDecl(String name, String value) Report an internal entity declaration.booleanisParagraphTag(Tag tag) Returns whether the tag starts a new paragraph.voidprocessingInstruction(String target, String data) Receive notification of an XML processing instruction anywhere in the document.resolveEntity(String publicId, String systemId) Resolves an external entity.voidReport the start of a CDATA section.voidReceive notification of the beginning of the document.voidReport the start of DTD declarations, if any.voidstartElement(String uri, String localName, String qName, Attributes attributes) Receive notification of the start of an element.voidstartEntity(String name) Not used: Report the beginning of some internal and external XML entities.Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, error, notationDecl, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl, warningMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xml.sax.ContentHandler
declaration
-
Constructor Details
-
Handler
public Handler(Translator translator, XMLDialect dialect, File inFile, @Nullable File outFile, FilterContext fc) throws IOException Creates a new instance of Handler- Throws:
IOException
-
-
Method Details
-
getProcessedFiles
Returns external files this handler has processed, because they were included into main file. Each entry isFile. -
getContext
-
doResolve
Resolves an external entity and provides an InputSource for the entity. The method handles resolving based on the public ID and system ID provided, and checks for specific URI schemas to determine the type of resolution required. Additionally, it performs translation and writing if necessary and resolves external entities from the project's source folder.- Parameters:
publicId- The public identifier of the entity being resolved.systemId- The system identifier of the entity being resolved.- Returns:
- An InputSource object representing the resolved entity. If the entity cannot be resolved, it returns an empty InputSource.
- Throws:
SAXException- If there is an error during XML parsing.
-
isParagraphTag
Returns whether the tag starts a new paragraph. -
resolveEntity
Resolves an external entity.- Specified by:
resolveEntityin interfaceEntityResolver- Overrides:
resolveEntityin classDefaultHandler- Throws:
SAXException
-
startElement
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException Receive notification of the start of an element.- Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Throws:
SAXException
-
endElement
Receive notification of the end of an element.- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler- Throws:
SAXException
-
characters
Receive notification of character data inside an element.- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classDefaultHandler- Throws:
SAXException
-
ignorableWhitespace
public void ignorableWhitespace(char[] ch, int start, int length) Receive notification of ignorable whitespace in element content.- Specified by:
ignorableWhitespacein interfaceContentHandler- Overrides:
ignorableWhitespacein classDefaultHandler
-
comment
Receive notification of an XML comment anywhere in the document.- Specified by:
commentin interfaceLexicalHandler- Throws:
SAXException
-
processingInstruction
Receive notification of an XML processing instruction anywhere in the document.- Specified by:
processingInstructionin interfaceContentHandler- Overrides:
processingInstructionin classDefaultHandler
-
startDocument
Receive notification of the beginning of the document.- Specified by:
startDocumentin interfaceContentHandler- Overrides:
startDocumentin classDefaultHandler- Throws:
SAXException
-
endDocument
Receive notification of the end of the document.- Specified by:
endDocumentin interfaceContentHandler- Overrides:
endDocumentin classDefaultHandler- Throws:
SAXException
-
fatalError
Report a fatal XML parsing error. Is used to provide feedback.- Specified by:
fatalErrorin interfaceErrorHandler- Overrides:
fatalErrorin classDefaultHandler- Throws:
SAXException
-
startDTD
Report the start of DTD declarations, if any.- Specified by:
startDTDin interfaceLexicalHandler
-
endDTD
public void endDTD()Report the end of DTD declarations. Queues the DTD declaration with all the entities declared.- Specified by:
endDTDin interfaceLexicalHandler
-
startCDATA
public void startCDATA()Report the start of a CDATA section.- Specified by:
startCDATAin interfaceLexicalHandler
-
endCDATA
public void endCDATA()Report the end of a CDATA section.- Specified by:
endCDATAin interfaceLexicalHandler
-
startEntity
Not used: Report the beginning of some internal and external XML entities.- Specified by:
startEntityin interfaceLexicalHandler
-
endEntity
Report the end of an entity.- Specified by:
endEntityin interfaceLexicalHandler- Parameters:
name- The name of the entity that is ending.- Throws:
SAXException- The application may raise an exception.- See Also:
-
internalEntityDecl
Report an internal entity declaration.- Specified by:
internalEntityDeclin interfaceDeclHandler- Throws:
SAXException
-
externalEntityDecl
Report a parsed external entity declaration.- Specified by:
externalEntityDeclin interfaceDeclHandler- Throws:
SAXException
-
elementDecl
Not used: An element type declaration.- Specified by:
elementDeclin interfaceDeclHandler
-
attributeDecl
public void attributeDecl(String eName, String aName, String type, String valueDefault, String value) Not used: An attribute type declaration.- Specified by:
attributeDeclin interfaceDeclHandler
-