XMLMill - convert xml to pdf with java. Generate PDF from xml/xsl.

XMLMill User Guide

Version: 3.00 Date: January 2nd, 2008
This tutorial is opened in a separate window in order to maximize the legibility of this tutorial.
To return to XMLMill, close this browser window

This page as PDFPrinter friendly pageThis guide (!) as PDF

XMLMill Namespace

XMLMill has its own namespace: ml:. This largely facilitates developing XSL stylesheets using the XMLMill elements and appropriate attributes.

Defining the ml: namespace in your xsl document

Namespaces are implemented by attaching a prefix to each element and attribute. Each prefix is mapped to a URI by an xmlns:prefix attribute. Default URIs can also be provided for elements that don't have a prefix by xmlns attributes. Elements and attributes that are attached to the same URI are in the same namespace.

In order to use the namespace it needs to be defined in the xsl stylesheet. Following information needs to be added to the xsl stylesheet:

[001] 
[002] <?xml version="1.0" encoding="UTF-16" ?> 
[003]   <xsl:stylesheet version="1.0"   
[004]     xmlns:ml="http://www.xmlmill.com/XSL/Format"
[005]                     
[006]                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                           
[008]                     
[009]                     xsi:schemaLocation="http://www.xmlmill.com/XSL/Format 
                          xmlmill.xsd"
[011]                     
[012]     xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
[013]     <xsl:output method="xml" indent="yes"  encoding="UTF-16"/>
[014]     <xsl:template match="/">
[015]       <ml:documents linefeed-treatment="ignore">
[016]         <ml:document file ="output\phonelist.pdf">
[017]           <ml:info>   
[018]             ...
[019]         

1

Define the ml: namespace by referring to the correct namespace name. In this case the namespace name is a URI mapping to: http://www.xmlmill.com/XSL/Format.

2

Define that an instance of a XMLSchema will be defined.

3

Define where the instance of the XMLSchema is located. The XMLSchema is referenced using the namespace name (http://www.xmlmill.com/XSL/Format). The second parameter (xmlmill.xsd) defines the actual location and name of .xsd schema.

When the xml document is transformed with the xsl stylesheet, an internal .mill result-tree is generated, used to generate the .pdf document.

  • The docs/xsd/ directory contains the xmlmill.xsd and a default default.xsl stylesheet (referring to the schema).

Using a namespace facilitates developing an xsl stylesheet, as your xml editor will probably control which attributes are valid for a tag:

images/xmlspy-xsl.gif
Select to enlarge

Above is a screenshot from Altova xmlSpy 2005 release 3

Defining the ml: namespace in your mill document

In case you want to generate directly a mill document without using a .xsl sheet, start your .mill document with following:

[001] 
[002] <?xml version="1.0" encoding="UTF-16"?>
[003]   <ml:documents 
[004]     xmlns:ml="http://www.xmlmill.com/XSL/Format" 
[005]     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
[006]     xsi:schemaLocation="http://www.xmlmill.com/XSL/Format xmlmill.xsd"> 
[007]   <ml:document file="output\article.pdf">
[008]     <ml:info>
[009]      
           ...	
1

Define the ml: namespace by referring to the correct namespace name. In this case the namespace name is a URI mapping to: http://www.xmlmill.com/XSL/Format.

2

Define that an instance of a XMLSchema will be defined.

3

Define where the instance of the XMLSchema is located. The XMLSchema is referenced using the namespace name (http://www.xmlmill.com/XSL/Format). The second parameter (xmlmill.xsd) defines the actual location and name of .xsd schema.

  • Note that the xsl namespace declaration (xmlns:xsl="http://www.w3.org/1999/XSL/Transform" is absent.

Using a namespace facilitates the development of a .mill document as your xml editor will probably control which elements/attributes are valid.

images/xmlspy-mill.gif
Select to enlarge

Above is a screenshot from Altova xmlSpy 2005 release 3

Copyright © 2001 - 2012. All rights reserved. XMLMill and XMLMill logo are trademarks of Pecunia Data Systems, bvba.
Powered by Apache CocoonPowered by XMLMill