GithubHelp home page GithubHelp logo

hamdikarray / simple-api-for-sgml-dist Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 577 KB

SGML Parser Reader Writer distribution

License: GNU Affero General Public License v3.0

HTML 66.13% CSS 5.92% Java 27.95%
reader parser xml sgml

simple-api-for-sgml-dist's Introduction

Simple API for SGML

Simple API for SGML (SAS) is an event-driven, serial-access mechanism for accessing SGML documents with JAVA. Very similar to SAX it allows you to handle events :

  • Error Handler : to handle warning, error and fatal erros
  • Declaration Handler : events related to the parsing of the SGML declaration part
  • Definition Handler : events related to the parsing of the SGML definition part (DTD)
  • Instance Handler : events related to the parsing of the SGML document it self

Very simple to use, it allows you also to deal with the SGML document as XML document :

  • Convert from SGML to XML with many options

  • Convert from XML back to SGML

    • infine allows converting from SGML to SGML
    • transparency : dealing only with XML
  • Transforming SGML with XSLT transform for various engine like SAXON API (directly as a source or throw extension function)

  • Thread SAFE : very usefull for big data

Usage

Like SAX, we need to declare a Reader :

final SASParserFactory factory = SASParserFactory.newInstance();
factory.setValidating(true);

final CatalogResolver catalogResolver = new CatalogResolver();
catalogResolver.addCatalog("file:/d:/sgml/sgml.catalog");

SASParser parser = factory.newSASParser();
Reader reader = parser.getSGMLReader();
reader.setEntityResolver(catalogResolver);

This is a catalog sample :


SGMLDECL "docbook.dec"
PUBLIC "ISO 8879-1986//ENTITIES Added Latin 1//EN" "entities/Isolat1.ent"
DOCTYPE BOOK "doctypes/book.dtd"

The SGMLDECL and the DOCTYPE entries are mandatory.

For dealing with SGML events :

reader.setInstanceHandler(new InstanceHandler() {
		
		@Override
		public void startElement(String[] grpList, String qName) throws SASException {
		}
		
		@Override
		public void startElement(String qName) throws SASException {
		}
		
		@Override
		public void startDocument() throws SASException {
		}
		
		@Override
		public void startContent() throws SASException {
		}
		
		@Override
		public void setDocumentLocator(Locator locator) {
		}
		
		@Override
		public void processingInstruction(String content) throws SASException {
		}
		
		@Override
		public void endElement(String[] grpList, String qName) throws SASException {
		}
		
		@Override
		public void endElement(String qName) throws SASException {
		}
		
		@Override
		public void endDocument() throws SASException {
		}
		
		@Override
		public void emptyStartElement() throws SASException {
		}
		
		@Override
		public void emptyEndElement() throws SASException {
		}
		
		@Override
		public void comment(String string) throws SASException {
		}
		
		@Override
		public void characters(char[] ch, int start, int length) throws SASException {
		}
		
		@Override
		public void attribute(String qName, String value) throws SASException {
		}
});
				
reader.parse(new InputSource("file:/d:/sgml/file.sgm"));

or more simple for converting to XML document :


XMLReader xr = reader.asXMLReader();
Source src = new SAXSource(xr, new InputSource("file:/d:/sgml/file.sgm"));

Result res = new StreamResult("file:/d:/sgml/file.xml");
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.transform(src, res);

We can configure the SASParserFactory :

factory.setFeature(SASParserFeatures.QUANTITY_CHECKING, true);
factory.setFeature(SASParserFeatures.CAPACITY_CHECKING, false);
factory.setFeature(SASParserFeatures.ID_REF_CHECKING, true);

Version

Home Edition

See the documentation

This is an evaluation version with some features desactivated :

  • Fully java support for SAS like support, conversion in XML, parsing SGML declarartion and DTD definition
  • Some SGML declaration features not supported : DATATAG, RANK
  • Somme DTD features not supported : USEMAP, PIENTITY, STARTAGENTITY, ENDTAGENTITY and MSENTITY
  • Some instance handler event deactivated for entities and attrbutes : all event fired as character event or ignored

Professional Edition

See the documentation

adds a number of features to HE version :

  • All SGML declaration features supported
  • All DTD features supported
  • Fully instance handler event support

Entreprise Edition (coming soon)

The fully-featured product with in addition :

  • SGML reader and writer support :
    • Directly for performance
    • Transparency with XML support
  • DTD canonizing
  • ...

Evaluation

For PE or EE version, please create an issue with the following informations :

Information
* First Name
* Last Name
Company
* Country
* Email
Phone

simple-api-for-sgml-dist's People

Contributors

hamdikarray avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.