GithubHelp home page GithubHelp logo

rlane2126 / appstream-appdata-java Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jgarciao/appstream-appdata-java

1.0 1.0 0.0 3.82 MB

A simple Java library to parse AppData files

License: Apache License 2.0

Java 100.00%

appstream-appdata-java's Introduction

appstream-appdata-java

This is a simple Java library to parse AppData files. It is used in linux-store-backend

How this lib has been created

  • Create a new maven project

    • IntelliJ > File > New > Project
    • Maven > Create from archetype: org.apache.maven.archetypes:maven-archetype-quickstart
      • GroupID: org.freedesktop.appstream
      • ArtifactID: appstream-appdata
  • Create an example App Data file xds/appstream-seed.xml

    • It contains an example component with most of the appstream spec.
    • It's added twice in the file on purpose to tell the system that we'll have a list of components.
  • IntelliJ > Select xds/appstream-seed.xml > Generate XSD schema from XML file:

    • Result schema file name: appstream.xsd
    • Design type: local elements/types
    • Detect simple content type: smart
  • Rename obtained file appstream-seed.xml1.xsd to appstream-lang.xsd

  • Edit xds/appstream.xsd

    • Import appstream-lang.xsd
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:import namespace="http://www.w3.org/XML/1998/namespace"
        schemaLocation="appstream-lang.xsd"/>
    
    • Manually modify "description" type
    # Before
    <xs:element name="description">
      <xs:complexType>
        <xs:choice maxOccurs="unbounded" minOccurs="0">
          <xs:element ref="p"/>
          <xs:element ref="ul"/>
          <xs:element ref="ol"/>
        </xs:choice>
        <xs:attribute ref="xml:lang"/>
      </xs:complexType>
    </xs:element>
    
    # After
    <!-- We manually modify description type to allow mixed content -->
    <xs:complexType name="description" mixed="true">
      <xs:sequence>
        <xs:element name="p" type="xs:string" maxOccurs="unbounded" minOccurs="0"/>
        <xs:element ref="ul"  minOccurs="0"/>
        <xs:element ref="ol"  minOccurs="0"/>
      </xs:sequence>
      <xs:attribute ref="xml:lang"/>
    </xs:complexType>
    
    <xs:element name="description" type="description"/>
    
  • Create bindings using xcj:

  cd ROOT_OF_THE_PROJECT
  xjc -d src/main/java/ -p org.freedesktop.appstream.appdata xsd/appstream.xsd 

Building appstream-appdata-java

mvn install

appstream-appdata-java's People

Contributors

jgarciao avatar

Stargazers

 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.