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 Ivanova <iv...@agenstvo.com> on 2007/11/14 09:53:05 UTC

Encoding

Hi. I want to transform XML to HTML using Xalan-C++ 1.10.
 And I have such xml (fragment):

 <a ... alt="текст"> текст </a>

And after XSL transformation, attribute values (written in russian 
language) become coded into HTML escape sequence:

 <a ... alt="&#1040;&#1074;&#1090;&#1086"> текст </a>

But text, inside attribute <a> stayed unchanged (and that's right).
How could I avoid converting values of attributes in tags ?

And one more question: how to perform xalan-c do not insert META tag
 <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
in  created html document.

Thanks for the answers.


Re: Encoding

Posted by Ivanova <iv...@agenstvo.com>.
David Bertoni wrote:
> If you're using the XalanTransformer class, you can call 
> XalanTransformer::setOmitMETATag(eOmitMETATagYes) to accomplish this.  
> If you're using the command line executable, you can use the -m 
> command line option.
I am using the XalanTransformer class, and when I call this function:

ptheXalanTransformer = new XalanTransformer();
		ptheXalanTransformer->setOmitMETATag(XalanTransformer::eOmitMETATagYes);

		....

		// Do the transform.
		if (NULL == ptheCompiledStylesheet || reloadXSL)
		{
			if (NULL != ptheCompiledStylesheet)
				ptheXalanTransformer->destroyStylesheet(ptheCompiledStylesheet);

			ptheXalanTransformer->setOmitMETATag(XalanTransformer::eOmitMETATagYes);
			theResult = ptheXalanTransformer->compileStylesheet(xsltsource, ptheCompiledStylesheet);
			if (0 != theResult)
			{
				cerr << "Error in file " << xsltsource << ": " << ptheXalanTransformer->getLastError() << endl;
				return theResult;
			}
			ptheXalanTransformer->setOmitMETATag(XalanTransformer::eOmitMETATagYes);
		}

		if (NULL != params)
		{
			for (map<string, string>::const_iterator it = params->begin(); it != params->end(); ++it)
			{
				ptheXalanTransformer->setStylesheetParam(it->first.c_str(), it->second.c_str());
			}
		}

		if (NULL != mode && '\0' != *mode)
		{
			ptheXalanTransformer->setStylesheetParam("mode", mode);
		}

		ptheXalanTransformer->setOmitMETATag(XalanTransformer::eOmitMETATagYes);
		theResult = ptheXalanTransformer->transform(xmlsource, ptheCompiledStylesheet, target);

		if(theResult != 0)
		{
			cerr << "Error: " << ptheXalanTransformer->getLastError() << endl;
		}
 it also insert meta tag <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> in created html-document




Re: Encoding

Posted by David Bertoni <db...@apache.org>.
Ivanova wrote:
> Hi. I want to transform XML to HTML using Xalan-C++ 1.10.
> And I have such xml (fragment):
> 
> <a ... alt="текст"> текст </a>
> 
> And after XSL transformation, attribute values (written in russian 
> language) become coded into HTML escape sequence:
> 
> <a ... alt="&#1040;&#1074;&#1090;&#1086"> текст </a>
Well, that's probably a bug, although it's hard to say for sure.  Please 
open a Jira issue and attach a small source document and stylesheet that we 
can use to reproduce the problem.  Here's a link to the Jira page for Xalan-C:

http://issues.apache.org/jira/browse/XALANC

Please try to make your sample document and stylesheet as simple as possible.
> 
> But text, inside attribute <a> stayed unchanged (and that's right).
> How could I avoid converting values of attributes in tags ?
<a> is not an attribute, it's an element.

> 
> And one more question: how to perform xalan-c do not insert META tag
> <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
> in  created html document.

If you're using the XalanTransformer class, you can call 
XalanTransformer::setOmitMETATag(eOmitMETATagYes) to accomplish this.  If 
you're using the command line executable, you can use the -m command line 
option.

Dave