Headline

Exercise in-memory XML processing with Technology:XOM in Language:Java

Characteristics

See Contribution:dom for a general motivation for exercising in-memory XML processing. The present implementation simply exercises yet another DOM-like API. We end up providing a descendants axis to this end.

Illustration

The data model is implemented as xml files (sampleCompany.xml) that conform to a schema (Company.xsd).

Feature:Open serialization is implemented using Technology:xom Builder:

    public static Element deserializeCompany(String file) throws ValidityException, ParsingException, IOException {
        return (new Builder().build(new File(file)).getRootElement());
    }

Feature:Total and Feature:Cut are implemented by using descendants:

	public static double total(Element elem) {
		double total = 0;
		for (Element s : descendants(elem, "salary"))
			total += Double.valueOf(s.getValue());
		return total;
	}

	public static void cut(Element elem) {
		for (Element s : descendants(elem, "salary")) {
			double value = Double.valueOf(s.getValue());
			value /= 2;
			s.removeChildren();
			s.appendChild(new Text(Double.toString(value)));
		}
	}

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.xom for descendants helper.
  • src/test/java contains the following packages:

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

    This user never has never made submissions.

    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.