Thnak you.

one question: 

if you say  <xsl:output type="xml" encoding="ASCII" /> - does this mean that 
the whole target XML will be in ASCII or only the 'changed' parts? What effect 
would this have on other unicode characters that we don't want to convert? And: 
can such a XSLT also be used on export of XML to transform the ASCII back to 
Unicode without loss of data?

Met vriendelijke groet / kind regards,

Wim Hooghwinkel wimh at scriptware.nl
DTP and XML Management

Scriptware bv http://www.scriptware.nl
tel : +31 (0)23 548 48 84
fax : +31 (0)23 548 48 85
http://www.scriptware.nl
info at scriptware.nl info at scriptware.nl 


-----Original Message-----
From: John Root [mailto:jr...@publisys.com]
Sent: Saturday, May 06, 2006 9:43 PM
To: Wim Hooghwinkel (Scriptware); Framers List
Subject: Re: FM 7.2 XSLT and unicode characters


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.

i.e.: 

<xsl:choose>
    <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>
</xsl:choose>

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"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

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

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

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

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

</xsl:stylesheet>


Hope this helps,

John





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

> 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