Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 19th, 2006, 08:10 AM
Registered User
 
Join Date: Jan 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am still wrestling with this one. The problem is down to the output from the xsl processor generating a META tag with utf-16 rather than iso-8859-1 that is specified in the xsl:output instructon
eg <xsl:output encoding="iso-8859-1" />

generates:-
<META http-equiv="Content-Type" content="text/html; charset=UTF-16">

and i want :-
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

I tried character mapping but it caused errors. Is this allowed in version 1.0?

Can anyone help please?


 
Old January 19th, 2006, 08:21 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

transformNode always gets UTF-16, use:
Code:
xmlDom.transformNodeToObject(xmlStyle, Response);
--

Joe (Microsoft MVP - XML)
 
Old January 19th, 2006, 08:47 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If you are getting UTF-16 when you asked for something else, it's because you are sending the output to a character stream rather than a byte stream, which means the actual encoding is being done outside the XSLT processor's control. As Joe already said, you need to change the way you run the transformation.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old January 19th, 2006, 11:16 AM
Registered User
 
Join Date: Jan 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Tried using transformNodeToObject but it does not seam to produce any output.Am I doing something silly?

Here is the code fragment that i am using in asp.

   var stylesheet = new ActiveXObject("Msxml2.DOMDocument.3.0");
   stylesheet.async = false;
   stylesheet.loadXML(XSL);
   if (stylesheet.parseError.errorCode != 0) {
      var myErr = stylesheet.parseError;
      Response.Write("You have error " + myErr.reason);
            Response.Write("<XMLParseError>");
            Response.Write("<Error>" + myErr.errorCode + "::" + myErr.reason +"</Error>");
            Response.Write("</XMLParseError>");

   } else {
      // Set up the resulting document.
      var result = new ActiveXObject("Msxml2.DOMDocument.3.0");
      result.async = false;
      result.validateOnParse = true;
      // Parse results into a result DOM Document.
      Response.Write(source.transformNodeToObject(styles heet, result));
     //Response.Write(source.transformNode(stylesheet));
   }

NB the tranformNode line that is commented out works fine.



 
Old January 19th, 2006, 01:36 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Code:
Response.ContentType = "text/xml";
var stylesheet = new ActiveXObject("Msxml2.DOMDocument.3.0");
   stylesheet.async = false;
   stylesheet.loadXML(XSL);
   if (stylesheet.parseError.errorCode != 0) {
      var myErr = stylesheet.parseError;
      Response.Write("You have error " + myErr.reason);
            Response.Write("<XMLParseError>");
            Response.Write("<Error>" + myErr.errorCode + "::" + myErr.reason +"</Error>");
            Response.Write("</XMLParseError>");

   } else {
      // Set up the resulting document.
      var result = new ActiveXObject("Msxml2.DOMDocument.3.0");
      result.async = false;
      result.validateOnParse = true;
      // Parse results into a result DOM Document.
   source.transformNodeToObject(stylesheet, Response);
  Response.Flush();
  Response.End();     
   }
--

Joe (Microsoft MVP - XML)
 
Old January 19th, 2006, 02:16 PM
Registered User
 
Join Date: Jan 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Joe and Mike for your help on this. It now works fine.








Similar Threads
Thread Thread Starter Forum Replies Last Post
XSL: Currency symbol Euro elayaraja.s XSLT 2 August 12th, 2008 03:00 AM
entering £ (pound sign) into MySQL database - PHP crmpicco PHP Databases 1 November 14th, 2007 02:02 AM
pound sign and querystring ricespn Classic ASP Basics 3 October 19th, 2006 09:24 AM
XSL Transform with xsl string NOT xsl file skin XSLT 0 June 16th, 2003 07:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.