• Home
  • News
  • Usage guide
  • Download
  • Development
  • Samples
  • FAQ
  • English
  • Romana

Samples

Our directory structure would be

  • site
    • index.xml
    • copyright.xml
    • menu.xml
    • header.xml
  • config.xml
This is actually the most simple structure since there is only one real file: index.xml.

config.xml

<config>
	<site src='site' build='build'/>
	<lang>
		<en/><ro/>
	</lang>
	<copyright ref='site://copyright.xml'/>
	<header ref='site://header.xml'/>
	<menu ref='site://menu.xml'/>
</config>

Let's talk about each of the options:

  • site. src is the folder where we store the XML files (copyright and contents...). build is the output folder. It is often better not to use the same folder because it will just fill the folder with xml and html files.
  • lang has a list of tags representing all the languages the the site is written for. The first one is the default language. All the xml files will generate html files. The name of the SomeFile.xml becomes thus SomeFile.language.html. or SomeFile.html if language is the default language (the first one in the list).
  • The copyright, menu and header tags specify a relative link to the respective files. Note the ad-hoc protocol site://.

Running the program

There are many ways to run staticxjam:

  • run java -jar xjam.jar
  • if you have Java WebStart, double click xjam.jar
  • if you have ant, run ant run. This way you'll also have an uptodate version of the software because a build will occour if some files have changed

index.xml

index.xml is the an actual site file (that will generate index.html and index.ro.html).

<html>
 <title>
 	<lang>
		<ro>
			Romanian title
		</ro>
		<en>
			English title
		</en>		
	</lang>
 </title>
 <body>
 	The actual site contents, with valid xhtml.
	<lang>
		<ro>
			salut
		</ro>
		<en>
			hy
		</en>
	</lang>
 </body>
</html>
There are a few things worth mentioning here:
  • There is no head tag and only the title. The global head tag will be defined in header.xml. Notice how the title is automatically written for 2 languages.
  • There is no menu or copyright info since these are also in 2 separate files.
  • We may use <lang> anywhere...

header.xml

header.xml has all the stuff that you would usually place in the <head> section:

<head>
	<meta option='value'/>
	<link type="shortcut icon"
		ref="site://favicon.gif" lang='none'/>
</head>
There are also some new things here
  • Do no use link independently as it is a special xjam tag. Use LINK instead if you still want to reffer to the old one. We'll discuss the link options later on.
  • We don't add a title here since the title from the document (for example index.xml) will be added here by xjam.

menu.xml

This is where the global menu is defined. It is up to you to actually define the menu (however do you want it).

<ul>
	<li>
		<link ref='site://index.html'>
			<lang>
				<ro>acasa</ro>
				<en>home</en>
			</lang>
		</link>
	</li>
	
	<li>
		<link ref='site://products/list.html'>
			<lang>
				<ro>Produse</ro>
				<en>Products</en>
			</lang>
		</link>
	</li>
	
	<li>
		<a href='http://server.com'>Absolute link</a>
	</li>
</ul>
This could be one way of defining your menu. It is up to your html and css skills.
  • All the link tags will be translated to a href= and the existing a href will be left alone. We are using link to allow xjam to generate relative paths. (Note that products/list.html was not in the site structure...).

copyright.xml

<div id='copyright'>
	<timestamp/>
	
	<lang>
		<en>Legal boring stuff</en>
		<ro>Copyight...</ro>
	</lang>
</div>
  • Everything will be added at the end, while respecting the language specifications
  • Misc features: <timestamp/>. It will generate the date and time when the site was generated by xjam. Usefull for last updated messages.

The <link> tag

The link tag is a rather central tag since it is the one we use to reffer to pages within out own site. Since xjam will generate relative and not absolute paths, it's worth it (we'll be able to move the generated site freely).

Referring to a different file

Suppose we are in site/a.xml and want a link to site/emi/b.xml. What do we use ? <link ref='site://emi/b.html'/>link name</link> This will get translated to <a href='emi/b.html'>link name</a> Please note that this assumes that the current language is the default one. In b.en.html, the link will become <a href='emi/b.en.html'>link name</a>

Forcing a specific language or filename

Sometimes we want to link to a specific variant of the file or the file doesn't have multiple versions (for each language). This is where the lang attribute comes. <link ref='site://emi/b.html' lang='ch'>link name</link> becomes <a href='emi/b.ch.html'>link name</a> (assuming that ch is not the default language...).

With lang=none we say that the file has no variants. <link ref='site://emi/movie.mpg' lang='none'>link name</link> and thus <a href='emi/movie.mpg'>link name</a>

Referring to the same file

You need some way to make a link from a file to the same file but in the other language. Here is where <link ref='self://' lang='something'>link name</link> comes in handy. The self:// protocol means that this link is for the very same file that contains it; and with the lang attribute we force a specific language. This is so easy that I usually add it to the menus (like here).

The type attribute

Link also uses the type attribute, which is optional:

  • <link type="shortcut icon" ref="site://favicon.gif" lang='none'/> will generate the tag for the shortcut icon. Note that I've also used the lang attribute since we don't usually have specific favicons for every language.
  • <link type="stylesheet" ref="site://style.css" lang='none'/> will generate the tag for the stylesheet.
  • <link type="rawstring" ref="site://./." lang='none'/> will produce only the 'path/to/ref/' text. This is here mostly because I needed it but it might be usefull.

Adding an image

To inser an image we have the <icon ref='site://some.gif'/>. The language is ignored by default.

The <ignore> element

The program ignores ignore elements and prints only their content.

This file is copyrighted (C) 2004 by Emilian Bold under the GNU Free Documentation License.

This file was generated using xjam.

Many thanks to Patrick Riley (SIMS, U.C. Berkeley)

This product includes software developed by the Apache Software Foundation (http://www.apache.org/).

Thanks to sourceforge for the hosting.