PXML specification

From Pandora Wiki
Revision as of 04:10, 14 February 2010 by Skeezix (talk | contribs) (The clockspeed element)
Jump to: navigation, search

Download this page as PDF

Attention: at the present time, the PXML file format isn't set in stone, and is therefore subject to change. There is no guarantee that the format or the schema are bug-free or will be changed at any time. Please wait until this standard is finished before writing a PXML file.

This is the human-readable specification for the PXML file format. The PXML file format is used in your applications for the OpenPandora® that you package in ".pnd"-files or distribute otherwise, to make it possible for menus and launchers to use your applications and their properties.

A PXML file should be appended to your ".pnd"-file, using the tools provided for that purpose, or put in a directory that you want to serve as a redistributable package, to make it possible for launchers and menus to find it. It should have the name "PXML.xml" not case sensitive, and there should only be one such file. The contents of the PXML file should also comply to this specification without exception, to guarantee that everyone will be able to read it.

XML compatibility

The PXML format is XML-based and fully XML-compliant, which means that it can be read and written by any XML reader or writer. Included with this specification should also be a ".xsd"-file, which is used by XML tools to validate PXML files. A ".xsd"-file is also known as a XML schema, and can be called the "computer-readable" version of this document. It is very good practice to validate your PXML-files with that schema before publishing them.

To write a PXML file, you also need to know the basics of writing a XML file. It boils down to the following:

  1. If an element contains text or other elements, it needs a start-tag and an end-tag. This looks like (1)
  2. If an element does not contain other elements or text, but only attributes, it looks like (2)
<exampleelement someattribute="something">something inside it</exampleelement> <!-- (1) -->
<exampleelement2 someattribute="something" /> <!-- (2) -->

Format

The PXML-file is split up into multiple so-called elements, each of which specify one property of the ".pnd"-package. All of these elements are surrounded with a "<PXML>"-tag, which tells the readers of the file that the data within that tag belongs to a PXML file. The tag and elements should be defined as follows:

The PXML-tag

Description

The PXML-tag serves as the container for all PXML elements. It is the first thing that should occur in your PXML file. An example "<PXML>"-tag would look like this:

<PXML xmlns="http://openpandora.org/namespaces/PXML" id="uniqueID">
  <!--All of the PXML elements should be put here-->
</PXML>

As you can see, the PXML tag accepts a few attributes, namely the "id" and "xmlns" attributes.

  • The "xmlns" attribute is required by the XML standard, and guarantees that this file will be identified as a PXML file. You must include the xmlns attribute, exactly as shown, in your PXML file, with the URL as specified. Only then can it be guaranteed that the file will be read at all by launchers and menu apps.
  • The "id" attribute specifies an identifier for your PND package, and should be something globally unique so that no two PND packages have the same id. This can be achieved by appending some random number to your application name, and to use that as your id; or to simply generate a completely random, very long id. If this id already is used in another PND file, those two PND files will conflict with each other, and unforseeable errors will occur. Please put effort into generating an unique id for your PXML-file.

The title element

Description

The title element specifies the text that is shown to the users of your PND file as the application title. This element can be specified multiple times in multiple languages the language is indicated by the lang attribute.

At least one "title"-element is required, in the "en_US" American English language.

Example

<title lang="en_US">Your application name</title>
<title lang="de_DE">Deinen Programmnamen</title>

The description element

Description

The description element specifies the text that is shown to the users of your PND file as the application description. This element can be specified multiple times in multiple languages the language is indicated by the lang attribute.

At least one "description"-element is required, in the "en_US" American English language.

Example

<description lang="en_US">Your long description of this application, describing it's purpose and highlighting it's features.</description>
<description lang="de_DE">Deine etwas längere Programmbeschreibung, die den Sinn des Programmes und den wichtigsten Features beschreiben sollte.</description>

The exec element

Description

The exec element should specify all the information needed to execute your application. An exec element must be included in every PXML file. It accepts the following attributes:

  • The command attribute specifies the path to the executable file. This should be a relative path to a file within the PND package.
  • The startdir attribute specifies the starting directory (Also known as the working directory) that the application should start in. This should be a relative path to a directory within the PND package, or to a well-known directory in the Pandora file system.
  • The standalone attribute specifies whether or not this application can run on its own, or if it needs parameters to run. A value of "true" or "1" means that the application can be run without parameters. A value of "false" or "0" means that the application must be run with parameters (Meaning that no icon will appear for it in a launcher; it will only be run via file associations or via the terminal).
  • The background attribute specifies whether or not this application should run in the background, and it should be possible to switch to other apps while it is running, or if it is the only application that should be running. A value of "true" or "1" means that the application can run in the background. A value of "false" or "0" means that the application must be run as the only application.

Example

<exec background="true" startdir="/usr/share/icons/" standalone="true" command="myprogram"/>

The icon element

Description

The icon element should specify a nice icon for your program. An icon element is optional. It accepts the following attributes:

  • The src attribute specifies the path to the image file used as the icon.

Example

<icon src="images/icon.png"/>

The previewpics element

Description

The previewpics element is an element that contains multiple other elements. A previewpics element is optional.

It contains multiple pic-elements. Every pic-element represents one preview picture. If the previewpics element is specified, it must contain at least one pic element.

  • The src attribute on a pic element specifies the path to the image file used as the preview picture.

Example

<previewpics>
  <pic src="preview/pic1.jpg"/>
  <pic src="preview/pic2.jpg"/>
</previewpics>

The author element

Description

The author element is an element that is used by the author to introduce him/herself. An author element is optional. It accepts the following attributes:

  • The name attribute specifies the name of the author.
  • The website attribute specifies the website of the author.
  • The email attribute specifies the e-mail of the author. This attribute is not yet supported by libpnd, but please specify it anyways.

Example

<author name="Bjornhild Andersson" website="http://some.website.with.author.info"/>

The version element

Description

The version element specifies the application version. A version element is required. It accepts the following attributes:

  • The major attribute specifies the major version number. This number should be 0 or more.
  • The minor attribute specifies the minor version number. This number should be 0 or more.
  • The release attribute specifies the release number. This number should be 0 or more.
  • The build attribute specifies what build the application is at. This number should be 0 or more.

Example

<version major="1" minor="1" release="1" build="2"/>

The osversion element

Description

The osversion element specifies the application version. An osversion element is optional. It accepts the same attributes as the version element.

Example

<osversion major="1" minor="1" release="1" build="2"/>

The categories element

Description

The categories element is an element that contains multiple other elements. A categories element is required, and must contain at least one category.

Menus that use your PXML in any shape or form will use the category information to sort your application entry into the tree or sub menus. Depending on the menu system, this will be done differently every time. It is therefore advisable to specify as many categories and subcategories as possible (and as suitable; don't specify that your application belongs in a category if it doesn't).

The "categories" element contains multiple category-elements. Every category-element represents one category that this app can be sorted into. Valid top-level categories are (among others):

  1. AudioVideo
  2. Audio
  3. Video
  4. Development
  5. Education
  6. Game
  7. Graphics
  8. Network
  9. Office
  10. Settings
  11. System
  12. Utility

Please see the FreeDesktop specification for more information. In it, you will also find valid subcategories for your top-level categories.

The category-element takes one attribute: The name-attribute. This attribute represents the category name, which preferrably should be one of the above.

A category-element can contain further child-elements: subcategory-elements. These represent the subcategories of a category that the app will be sorted into.

The subcategory-element also takes a name-attribute; this attibute can contain a name for your subcategory.

Example

<categories>
  <!-- This app belongs in the "Game/StrategyGame" category -->
  <category name="Game">
    <subcategory name="StrategyGame"/>
  </category>
  <!-- This app also belongs in the "Graphics/ImageProcessing" category -->
  <category name="Graphics">
    <subcategory name="ImageProcessing"/>
  </category>
</categories>

The associations element

Description

The associations element is an element that contains multiple other elements. An associations element is optional, except if exec.standalone is false.

It contains multiple association-elements. Every association-element represents one file action association.

  • The name attribute on an association element specifies the user-friendly action name for the association.
  • The filetype attribute on an association element specifies what file types (in MIME format) that this association should apply to.
  • The exec attribute on an association element specifies the command-line arguments that should be given to the program, when this action is performed. The exec can contain a "%s", which indicates where the file name of the file, that the action is performed on, should be inserted. For example, if the exec-line is "--file %s --type lol", and you have a file "lol.bmp" that the action is performed on, the exec-line is transformed into "--file "lol.bmp" --type lol"

Example

<associations>
  <association name="Open Bitmap Image" filetype="image/bmp" exec="-f %s --no-deinterlacing"/>
  <association name="Crash the computer with a stylesheet" filetype="text/css" exec="-f %s --crash-on-success"/>
</associations>

The clockspeed element

Description

The clockspeed element specifies what clockspeed this app should run at. Please do only specify this element if your application *needs* to run at the specified clock speed. A clockspeed element is optional. It accepts the following attributes:

  • The frequency attribute specifies the wanted frequency, in megahertz (MHz).

Example

<clockspeed frequency="600"/>


The mkdir element

Description

The PXML may request creation of directories on the SD card.

This should be used sparingly.

There are a number of scenarios in which this may be useful; should an application wish to attempt to establish a canonicle location for a file, it can request a path be created. This can avoid user confusion -- user merely plugs in SD, waits a few moments, pulls out SD, and inspects it to see what directories he may populate. Consider 'id' files for Quake -- the user might have many ports of the game, such as Quake, or ioquake, or others. They could all share the same id pak files, but the user may not know where to put them. (Especially since the pnd-file itself does not have user documentation available perhaps.) Consider ROM-paths for emulators .. perhaps the emulator expects ROMs in a specific location? If so, the author may wish to have that location created, to make it obvious.

NOTES The paths are created on the SD that contains the pnd. The paths may not include ".." or wildcards.

It accepts the following attributes:

  • dir -> the name of the path to be created; it may be multiple levels deep, and the series will be created.

Example

<mkdir>

 <dir path="/foo/bar"/>

</mkdir>

If this is in /pandora/desktop on SD1 (/media/mmcblk0p1 say), then /media/mmcblk0p1/foo/bar will be created.

Example file

<?xml version="1.0" encoding="UTF-8"?>
<PXML id="youruniqueID" xmlns="http://openpandora.org/namespaces/PXML">
  <title lang="en_US">Program Title</title>
  <title lang="de_DE">German Program Title</title>

  <exec background="true" startdir="/usr/share/icons/" standalone="true" command="program"/>

  <icon src="program.png"/>

  <description lang="en_US">This is the English Description of the file.</description>
  <description lang="de_DE">This would be the German description.</description>

  <previewpics>
    <pic src="preview/pic1.jpg"/>
    <pic src="preview/pic2.jpg"/>
  </previewpics>

  <author name="Some Dudeson" website="http://a.bc.de"/>

  <version major="1" minor="1" release="1" build="2"/>
  <osversion major="1" minor="0" release="0" build="0"/>

  <categories>
    <category name="Game">
      <subcategory name="StrategyGame"/>
    </category>
    <category name="Graphics">
      <subcategory name="ImageProcessing"/>
    </category>
  </categories>

  <associations>
    <association name="View Word File" filetype="application/msword" exec="-f %s -t doc"/>
  </associations>

  <clockspeed frequency="600"/>
</PXML>

Validation

To validate a PXML file, you need a XSD (XML schema) validator, and you have to know how to use it.

You will also need to put the XML schema for the PXML format in the same folder as your PXML file.

When you have done that, and know how to use it, you need to change a few things in your PXML file. In your PXML tag, change the contents from this...

<PXML id="..." xmlns="http://openpandora.org/namespaces/PXML"> ...

...to this:

<PXML id="..." xmlns="http://openpandora.org/namespaces/PXML" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PXML_schema.xsd"> ...

Now the PXML file can be validated.