Contribution:
sax
Headline
Push-based XML parsing in Language:Java with Technology:SAX
Characteristics
Illustration
The data model is implemented as xml files (sampleCompany.xml) that conform to a schema (Company.xsd).
Feature:Parsing is implemented by loading a Technology:sax XMLreader:
// here a handler can realise unparsing (see Cut)
public static void parse(DefaultHandler handler, String file) throws SAXException, IOException {
XMLReader xreader = XMLReaderFactory.createXMLReader();
xreader.setContentHandler(handler);
xreader.setErrorHandler(handler);
FileReader reader = new FileReader(file);
xreader.parse(new InputSource(reader));
}
Feature:Unparsing can be implemented by a handler (see Cut).
Feature:Total is implemented by a SAX handler that totals during a parse:
/**
* Return the final result of query for totaling salaries.
*/
public double getTotal() {
return total;
}
Feature:Cut is implemented by a SAX handler that outputs an XML-file with XMLStreamWriter.
The schema is not needed for the basic operations, but one can perform XML validation with regard to the schema (see package org.softlang.company.features.sax)
Test cases are implemented for all Namespace:Features.
Relationships
For DOM-like implementations of in-memory XML processing see Contribution:dom, Contribution:jdom and Contribution:xom.
For a query-based implementation of in-memory XML processing see Contribution:xpathAPI.
For push-based XML processing see Contribution:sax.
For Object/XML mapping see Contribution:jaxbChoice (XSD with choice for different subunits), Contribution:jaxbComposition (XSD with object composition), Contribution:jaxbExtension (XSD with type extension) and Contribution:jaxbSubstitution (XSD with substitution groups).
Architecture
The contribution follows a standardized structure:
- inputs contains input files for tests
- src/main/java contains the following packages:
- org.softlang.company.features for implementations of Functional requirements.
- org.softlang.company.features.sax for additional Technology:sax functionality.
- org.softlang.company.features for implementations of Functional requirements.
- src/test/java contains the following packages:
- org.softlang.company.tests for Technology:JUnit test cases for Namespace:Features.
Usage
This contribution uses Technology:Gradle for building. Technology:Eclipse is supported.
See https://github.com/101companies/101simplejava/blob/master/README.md
There are no revisions for this page.
User contributions
User edits
Syntax for editing wiki
For you are available next options:will make text bold.
will make text italic.
will make text underlined.
will make text striked.
will allow you to paste code headline into the page.
will allow you to link into the page.
will allow you to paste code with syntax highlight into the page. You will need to define used programming language.
will allow you to paste image into the page.
is list with bullets.
is list with numbers.
will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.
will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.
will allow your to insert code snippets from @worker.
Syntax for editing wiki
For you are available next options:will make text bold.
will make text italic.
will make text underlined.
will make text striked.
will allow you to paste code headline into the page.
will allow you to link into the page.
will allow you to paste code with syntax highlight into the page. You will need to define used programming language.
will allow you to paste image into the page.
is list with bullets.
is list with numbers.
will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.
will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.
will allow your to insert code snippets from @worker.