Hi Wim,

There is no if-else functionality in XSL. Instead, you use xsl:choose with a
series of nested xsl:when elements and an optional final xsl:otherwise.


    <xsl:when test="'foo'">Do something</xsl:when>
    <xsl:when test="'foobar'">Do something else</xsl:when>
    <xsl:otherwise>Perform some default action</xsl:otherwise>

If I understand correctly what you're trying to do, you'd want your
intermediate transform to output ASCII or whatever encoding you require by
using an xsl:output element as a child of xsl:stylesheet:

<xsl:output type="xml" encoding="ASCII" />

You would use a standard copy type scenario but include a template for text
that calls the transform function. So your transform would look something
like this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"

     <!-- Set encoding attribute per your choice -->
    <xsl:output method="xml" encoding="ASCII" />

    <xsl:template match="/">
        <xsl:apply-templates />

    <xsl:template match="*">
            <xsl:for-each select="@*">
                <xsl:copy-of select="."/>
            <xsl:apply-templates />

    <xsl:template match="text()" priority="2">
            <xsl:when test="contains(., "UnicodeCharacter1)">
                <xsl:value-of select="translate(., "UnicodeCharacter1",
            <xsl:when test="contains(., "UnicodeCharacter2)">
                <xsl:value-of select="translate(., "UnicodeCharacter2",
            <xsl:otherwise><xsl:value-of select="."/>/xsl:otherwise>


Hope this helps,


On 5/5/06 2:43 AM, "Wim Hooghwinkel (Scriptware)" <wimh at scriptware.nl>

> Hello all,
> I am trying to create a XSLT template to transform uncode characters to ansii
> on import of XML in FM. This concerns the unicode characters for CE/EE
> languages that can not be read by FM.
> As I don't have any experience with XSLT, could anyone point me in the right
> direction? Probably need a kind of if-else construction or variables to use
> the 'transate' function.
> How does FM react when an XSLT refers to Javascript?
> Met vriendelijke groet / kind regards,
> Wim Hooghwinkel wimh at scriptware.nl
> DTP and XML Management

Reply via email to