XML TYP export

This XSL transformation file will help you to export XML TYP's files into the text cgpsmapper file format.

To copy the file on your computer, use the "grab" button at the bottom of the XML code below.
You may also be interested with TYP.xsd, a schema definition file which is an easy way to validate your XML TYP with an XML editor.

TYP.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!--makeTyp http://emerald-island.eu-->
<xsl:template match="/">
; http://emerald-island.eu

[_id]<xsl:for-each select="TYP">
<xsl:apply-templates select="FID"/>
<xsl:apply-templates select="PRODUCT"/>
<xsl:apply-templates select="CODEPAGE"/>
[end]
<xsl:variable name="nbDraworders"><xsl:value-of select="count(DRAWORDER)"/></xsl:variable>
<xsl:if test="$nbDraworders > 0">
[_drawOrder]
</xsl:if>
<xsl:apply-templates select="DRAWORDER"/>
<xsl:if test="$nbDraworders > 0">[end]
</xsl:if>

<xsl:apply-templates select="LINE"/>
<xsl:apply-templates select="POLYGON"/>
<xsl:apply-templates select="POINT"/>
</xsl:for-each>
</xsl:template>

<xsl:template match="FID">
FID=<xsl:value-of select="@val"/>
</xsl:template>

<xsl:template match="PRODUCT">
ProductCode=<xsl:value-of select="@val"/>
</xsl:template>

<xsl:template match="CODEPAGE">
codePage=<xsl:value-of select="@val"/>
</xsl:template>

<xsl:template match="DRAWORDER">Type=0x<xsl:value-of select="@hexType"/>,<xsl:value-of select="@level"/>;
</xsl:template>

<xsl:template match="LINE">
[_line]
Type=0x<xsl:value-of select="@hexType"/>
<xsl:apply-templates select="FONTSTYLE"/>
<xsl:apply-templates select="LABEL"/>
<xsl:apply-templates select="COLORSCHEME"/>
<xsl:apply-templates select="PATTERN"/>
[end]
</xsl:template>

<xsl:template match="POLYGON">
[_polygon]
Type=0x<xsl:value-of select="@hexType"/>
<xsl:apply-templates select="FONTSTYLE"/>
<xsl:apply-templates select="LABEL"/>
<xsl:apply-templates select="COLORSCHEME"/>
<xsl:apply-templates select="PATTERN"/>
[end]
</xsl:template>

<xsl:template match="POINT">
[_point]
Type=0x<xsl:value-of select="@hexType"/>
<xsl:apply-templates select="FONTSTYLE"/>
<xsl:apply-templates select="LABEL"/>
<xsl:apply-templates select="COLORSCHEME"/>
<xsl:apply-templates select="PATTERN"/>
[end]
</xsl:template>

<xsl:template match="FONTSTYLE">
StringStyle=<xsl:value-of select="@size"/>,<xsl:apply-templates select="@hexDay"/><xsl:apply-templates select="@hexNight"/>
</xsl:template>

<xsl:template match="@hexDay">day,0x<xsl:value-of select="../@hexDay"/>,</xsl:template>

<xsl:template match="@hexNight">night,0x<xsl:value-of select="../@hexNight"/></xsl:template>

<xsl:template match="LABEL">
String<xsl:value-of select="@id"/>=<xsl:value-of select="@lang"/>,<xsl:value-of select="@string"/></xsl:template>

<xsl:template match="PATTERN">
<xsl:variable name="display"><xsl:value-of select="@display"/></xsl:variable>
<xsl:variable name="night">night</xsl:variable>
<xsl:variable name="nbImages"><xsl:value-of select="count(IMAGE)"/></xsl:variable>
<xsl:variable name="nbPixels"><xsl:value-of select="count(PIXELS)"/></xsl:variable>
<xsl:choose>
<xsl:when test="$nbImages > 0">
<xsl:choose>
<xsl:when test="$display=$night">
NightXpm="<xsl:value-of select="IMAGE/@width"/><xsl:text> </xsl:text><xsl:value-of select="IMAGE/@height"/><xsl:text> </xsl:text><xsl:value-of select="count(COLOR)"/><xsl:text> </xsl:text>1"</xsl:when>
<xsl:otherwise>
DayXpm="<xsl:value-of select="IMAGE/@width"/><xsl:text> </xsl:text><xsl:value-of select="IMAGE/@height"/><xsl:text> </xsl:text><xsl:value-of select="count(COLOR)"/><xsl:text> </xsl:text>1"</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$display=$night">
NightXpm="<xsl:value-of select="PIXELS/@width"/><xsl:text> </xsl:text><xsl:value-of select="PIXELS/@height"/><xsl:text> </xsl:text><xsl:value-of select="count(COLOR)"/><xsl:text> </xsl:text><xsl:value-of select="PIXELS/@pixelWidth"/>"</xsl:when>
<xsl:otherwise>
DayXpm="<xsl:value-of select="PIXELS/@width"/><xsl:text> </xsl:text><xsl:value-of select="PIXELS/@height"/><xsl:text> </xsl:text><xsl:value-of select="count(COLOR)"/><xsl:text> </xsl:text><xsl:value-of select="PIXELS/@pixelWidth"/>"</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$nbImages = 0">
<xsl:if test="$nbPixels = 0">
DayXpm="<xsl:text>0 0 </xsl:text><xsl:value-of select="count(COLOR)"/><xsl:text> 0</xsl:text>"</xsl:if></xsl:if>
<xsl:apply-templates select="COLOR"/>
<xsl:apply-templates select="IMAGE"/>
<xsl:apply-templates select="PIXELS"/>
</xsl:template>

<xsl:template match="COLORSCHEME">
ColorScheme=<xsl:value-of select="@type"/>
</xsl:template>

<xsl:template match="COLOR">
"<xsl:value-of select="@key"/> c<xsl:choose>
<xsl:when test="@hexValue = 'none'"> None</xsl:when>
<xsl:when test="@hexValue = 'None'"> None</xsl:when>
<xsl:when test="@hexValue = 'NONE'"> None</xsl:when>
<xsl:otherwise> 0x<xsl:value-of select="@hexValue"/></xsl:otherwise>
</xsl:choose>"</xsl:template>

<xsl:template match="IMAGE">
image="<xsl:value-of select="@src"/>"</xsl:template>

<xsl:template match="PIXELS">
<xsl:for-each select="ROW">
"<xsl:apply-templates/>"</xsl:for-each>
</xsl:template>

<xsl:template match="ROW">
<xsl:value-of select="."/>
</xsl:template>

</xsl:stylesheet>





CategoryResource
Some rights reserved
Except where otherwise noted, content on this site is licensed
under a Creative Commons Attribution - Noncommercial - No Derivative Works 3.0 License.