This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Force UTF-8 output in text mode
- From: "Cutler, Dan" <Dan dot Cutler at vacationclub dot com>
- To: "'XSL-List at lists dot mulberrytech dot com'" <XSL-List at lists dot mulberrytech dot com>
- Date: Thu, 9 May 2002 10:05:35 -0400
- Subject: [xsl] Force UTF-8 output in text mode
- Reply-to: xsl-list at lists dot mulberrytech dot com
Howdy!
I have a simple XSL file that transforms an XML doc into "insert"
statements. (a crude data loader for Oracle).
The XSL works beautifully except for one thing:
I have set the encoding type to "UTF-8" with this line:
<xsl:output method="text" encoding="UTF-8"/>
I get UTF-16 no matter what I try. I have tried both "XML Spy" and Michael
Kay's "Instant Saxon"
Pasted in below is my XSL and my XML.
Does anyone see what I'm doing wrong?
advTHANKSance!
--Dan
XSL file...
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:variable name="digits" select='-01234567809'/>
<xsl:template match="Import">
<xsl:text>
</xsl:text>
<xsl:for-each select="Row">
<xsl:text>
</xsl:text>
<xsl:text>insert into customer_0_A (</xsl:text>
<xsl:for-each select="*">
<xsl:value-of select="name(.)"/>
<xsl:choose><xsl:when
test="position()!=last()"><xsl:text>,</xsl:text></xsl:when></xsl:choose>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:text>) values (</xsl:text>
<xsl:for-each select="*">
<xsl:choose>
<xsl:when
test="not(contains($digits,substring(normalize-space(.),1,1)))">
<xsl:text>'</xsl:text>
</xsl:when>
</xsl:choose>
<xsl:value-of select="."/>
<xsl:choose><xsl:when
test="not(contains($digits,substring(normalize-space(.),1,1)))"><xsl:text>'<
/xsl:text></xsl:when></xsl:choose>
<xsl:choose><xsl:when
test="position()!=last()"><xsl:text>,</xsl:text></xsl:when></xsl:choose>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:text>); 
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
XML file...
<Import>
<Row>
<CUSTOMER_KEY>2</CUSTOMER_KEY>
<_DATE_MODIFIED> sysdate</_DATE_MODIFIED>
<_LATEST_FLAG> 1</_LATEST_FLAG>
<_NAME_FIRST>Joe</_NAME_FIRST>
<_NAME_LAST>Bloe</_NAME_LAST>
<_GENDER>Male</_GENDER>
<_TITLE>UNKNOWN</_TITLE>
<_ADDRESS>UNKNOWN</_ADDRESS>
<_CITY>UNKNOWN</_CITY>
<_STATE_PROVINCE>UNKNOWN</_STATE_PROVINCE>
<_ZIPCODE>UNKNOWN</_ZIPCODE>
<_COUNTY>UNKNOWN</_COUNTY>
<_COUNTRY>UNKNOWN</_COUNTRY>
<_PHONE_AREA_CODE> 0</_PHONE_AREA_CODE>
<_PHONE_EVENING>UNKNOWN</_PHONE_EVENING>
<_PHONE_6_DIGITS> 0</_PHONE_6_DIGITS>
<_EMAIL_ADDRESS>UNKNOWN</_EMAIL_ADDRESS>
<_MARITAL_STATUS>UNKNOWN</_MARITAL_STATUS>
<_COMPANY_NAME>UNKNOWN</_COMPANY_NAME>
<_CREDIT_RATING>UNKNOWN</_CREDIT_RATING>
<_BIN_INCOME>UNKNOWN</_BIN_INCOME>
<_DATE_OF_BIRTH>UNKNOWN</_DATE_OF_BIRTH>
<_DO_NOT_SOLICIT> 0</_DO_NOT_SOLICIT>
<_R_SCORE>UNKNOWN</_R_SCORE>
</Row>
</Import>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list