You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by Ashay <as...@yahoo.com> on 2003/06/30 11:01:18 UTC

dynamically setting encoding parameter of xsl:output

Hi,
I need to set the encoding parameter of xsl:output dynamically. I think this is definately possible.
I am aware of the XalanTransformer::setStylesheetParam() function but it doesn't seem to work for me. Am I using the wrong function and is there some other function I should use ?
I am using the following XSL file:
--------------------------------------------

<?xml version="1.0"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"version="1.0"><xsl:param name="param1"/>  <xsl:output method="html" encoding="$param1"/>  <xsl:template match="/">    <html>      <head/>      <xsl:value-of select="."/>    </html>  </xsl:template></xsl:stylesheet>-------------------------------------------

Before compiling the stlesheet, I am using:

theXalanTransformer.setStylesheetParam("param1","/"GB2312/"");

I then compile the stylesheet and transform my DOM using the XalanTrabsformer::transform() function.

However, in the HTML ouput, I always get:<META http-equiv="Content-Type" content="text/html; charset=UTF-8">

Is there something wrong with my XSL file ?

I would appreciate some detailed help regarding this.

Thanks in advance

Ashay.





---------------------------------
Do you Yahoo!?
Free online calendar with sync to Outlook(TM).

Re: dynamically setting encoding parameter of xsl:output

Posted by da...@us.ibm.com.



> Hi,
> I need to set the encoding parameter of xsl:output dynamically. I think
this is
> definately possible.

No, such a feature is not currently available.

> I am aware of the XalanTransformer::setStylesheetParam() function but it
doesn't
> seem to work for me. Am I using the wrong function and is there some
other function
> I should use.

...

> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
> <xsl:param name="param1"/>
> <xsl:output method="html" encoding="$param1"/>

You can't just use a variable everywhere in a stylesheet where you want
dynamic behavior.  A good book on XSLT, or a quick read of the XSLT
recommendation will explain the xsl:output element.  You should also
understand that a processor is not required to support encodings other than
UTF-8 and UTF-16.  Xalan-C will support whatever encodings Xerces-C
supports, which changes depending on the platform, and the transcoding
system it was built with:

   http://xml.apache.org/xerces-c/faq-parse.html#faq-21

Dave