XRD Header File Generator
Version 1.4, updated March 27, 2006.
(Version 1.4 makes sure that numbers are not stripped from symbol names. )
In order to support our own Palm development, Llamagraphics has created an XSLT template file that generates a C/C++ header file from a Palm .xrd resource file. The symbols defined in the header file are based on comment attributes in the resource file. This allows your C/C++ code to refer to resources by name instead of by number. We've tried to make this as compatible as possible with the header files generated by Constructor for Palm OS. In other words, if you convert a Constructor resource to .xrd format using the PalmSource GenerateXRD Wizard, and then use this template to generate a header file from the .xrd file, you should get the same set of definitions that you would have gotten by generating the header from Constructor.
If you have questions, comments or corrections, please send email to samalone@llamagraphics.com.
We're distributing this file as open source under an MIT-style license. The template supports several optional parameters that control the style of output — see the comments inside the file for details. The file should work with any XSLT processor, but here are instructions for integrating it with the Palm OS Developer Suite distributed at the PalmSource conference:
- Install the Palm OS Developer Suite.
- Install libxslt from Cygwin:
- Download and run Cygwin Setup. On the "Choose A Download Source" screen select "Install from Internet". Cygwin Setup should automatically detect the proper root directory.
- When you get to the "Select Packages" screen, click on the "Keep" button so that none of the packages used by PODS will be upgraded. Then open up the "Devel" section by clicking on it.

- Scroll down until you find libxslt, and click once in the New column so that it displays a version number. This will have the side effect of also selecting the libxml2 package that libxslt requires. Note that the version numbers you see may not match the ones shown here.

- Continue with Cygwin Setup and it will download and install the necessary packages.
- Download xrd2header.xsl and move it to
C:\Program Files\PalmSource\Palm OS Developer Suite\PalmOSTools. - Open your project in Palm OS Developer Suite, and edit makefile-engine.mk:
- Find the definition of RESOURCE_LIST_TO_OBJS. After that definition, add:
# function for converting resources into resource header files define RESOURCE_LIST_TO_HEADERS $(addsuffix _res.h, $(foreach file, $(RESOURCES), $(basename $(file)))) endef
- Find the definition of RESOURCE_OBJS. After that definition, add:
RESOURCE_HEADERS = $(RESOURCE_LIST_TO_HEADERS)
- Find the comment
# XRD source processing. After those two definitions, add:# XRD header file generation %_res.h: %.xrd xsltproc "$(TOOLS_DIR)xrd2header.xsl" $< > $@
- Find the target definitions for
deviceandsimulator, and add$(RESOURCE_HEADERS)to them so they read:device: $(RESOURCE_HEADERS) $(OBJ_DIR) $(RSC_OBJ_DIR) $(TARGET) simulator: $(RESOURCE_HEADERS) $(SIM_OBJ_DIR) $(RSC_OBJ_DIR) $(SIM_TARGET)
- Add lines like
#include "ResourceFile_res.h"to the appropriate source files in your project. - In PODS, do a "make depend" on your project to update the dependency information to include the new header files.
- Do a "make all" to rebuild your project. The header files should be automatically generated, and updated whenever the resource files change.