SAXParser
classin packageklyn.io.xml.sax
public class SAXParser extends Object implements XMLReader, Parser
└ SAXParser
All Implemented Interfaces: XMLReader, Parser

Pure Klyn non-validating SAX parser.

The parser implements the SAX2 XMLReader API and the deprecated SAX1 Parser API. It reports document, element, Namespace, character, processing instruction, CDATA, comment and DTD lexical events without using native code.

This implementation focuses on well-formed XML parsing. It does not validate documents and does not read external entities by default.

Example
import klyn.io.xml.sax
import org.xml.sax

parser = SAXParser()
parser.setContentHandler(DefaultHandler())
parser.parse(InputSource("file:/tmp/doc.xml"))
Properties
Modifier and Type Member Description
public property entityExpansionLimit
entityExpansionLimit as Int
Maximum general-entity expansions per parse (2500, as in JDK 25).
public property maxGeneralEntitySizeLimit
maxGeneralEntitySizeLimit as Int
Maximum UTF-16 size of one general entity, declared or expanded (100000).
public property totalEntitySizeLimit
totalEntitySizeLimit as Int
Maximum cumulative expanded entity text in UTF-16 units (100000).
Inherited Properties
propertyInherited Properties from Object: type
Constructors
Modifier and Type Member Description
public SAXParser Creates a non-validating SAX parser.
Methods
Modifier and Type Member Description
public getContentHandler
getContentHandler() as ContentHandler
Returns the SAX2 content handler.
public getDTDHandler
getDTDHandler() as DTDHandler
Returns the DTD handler.
public getEntityResolver
getEntityResolver() as EntityResolver
Returns the entity resolver.
public getErrorHandler
getErrorHandler() as ErrorHandler
Returns the error handler.
public getFeature Returns the current feature value.
public getProperty Returns a SAX property value.
public parse
parse(input as InputSource) as Void throws IOException, SAXException
Parses XML from an input source.
public parse
parse(input as InputSource, handler as ContentHandler) as Void throws IOException, SAXException
Parses an input source with a content handler.
public parse
parse(input as InputSource, handler as DefaultHandler) as Void throws IOException, SAXException
Parses an input source with a DefaultHandler.
public parse
parse(systemId as String) as Void throws IOException, SAXException
Parses XML from a system identifier.
public parse
parse(systemId as String, handler as ContentHandler) as Void throws IOException, SAXException
Parses a system identifier with a content handler.
public parse
parse(systemId as String, handler as DefaultHandler) as Void throws IOException, SAXException
Parses a system identifier with a DefaultHandler.
public setContentHandler
setContentHandler(handler as ContentHandler) as Void
Registers the SAX2 content handler.
public setDTDHandler
setDTDHandler(handler as DTDHandler) as Void
Registers the DTD handler.
public setDocumentHandler
setDocumentHandler(handler as DocumentHandler) as Void
Registers the SAX1 document handler.
public setEntityResolver
setEntityResolver(resolver as EntityResolver) as Void
Registers the entity resolver.
public setErrorHandler
setErrorHandler(handler as ErrorHandler) as Void
Registers the error handler.
public setFeature
setFeature(name as String, value as Boolean) as Void throws SAXNotRecognizedException, SAXNotSupportedException
Sets a feature value.
public setLocale
setLocale(locale as Locale) as Void throws SAXException
Accepts a preferred diagnostics locale.
public setProperty
setProperty(name as String, value as Object) as Void throws SAXNotRecognizedException, SAXNotSupportedException
Sets a SAX property value.
Inherited Methods
methodInherited Methods from Object: deepCopy, fromJson, hash, toDict, toJson, toMap, toString, toXml
methodInherited Methods from Parser: parse, parse