RE: [xsl] Force UTF-8 output in text mode

Subject: RE: [xsl] Force UTF-8 output in text mode
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Thu, 9 May 2002 19:08:32 +0100
Nothing is wrong with your XSLT, what is wrong is the way you are invoking
the processor. Either the XSLT processor isn't doing the serialization, or
it is serializing to a character stream not a byte stream.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Cutler, Dan
> Sent: 09 May 2002 15:06
> To: 'XSL-List@xxxxxxxxxxxxxxxxxxxxxx'
> Subject: [xsl] Force UTF-8 output in text mode
>
>
> 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>&#x0A;</xsl:text>
> 	<xsl:for-each select="Row">
> 		<xsl:text>&#x0A;</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></x
> sl:choose>
> 		      	<xsl:text>&#x0A;</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></x
> sl:choose>
> 		      	<xsl:text>&#x0A;</xsl:text>
> 		</xsl:for-each>
> 		<xsl:text>); &#x0A;</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
>
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread