Hi Phillippe,
I have tried your sample with latest from apache. I don't see any=20
problem. The package name=20
com.sun.org.apache.xalan.internal.xsltc.TransletException suggests that=20
you may not be using apache version of Xalan.
Thanks!
Yash Talwar
Philippe Waltregny-Dengis <philippe.waltregny@nrb.be>=20
11/30/2005 08:14 AM
To
xalan-j-users@xml.apache.org
cc
"'Laurent Foramitti'" <laurent.foramitti@nrb.be>
Subject
Question about <xsl:output>
Hello,
I would like to report you the following problem in order to receive any=20
suggestion to understand and solve this issue.
I use Xalan-Java Version 2.7.0.
Let's assume the input data are given by the following original XML file:
=20
<?xml version=3D'1.0' encoding=3D'WINDOWS-1252'?>
<action>
<info>
<querystring>
<langue>N
</langue>
<idnewsletter>10
</idnewsletter>
<titreref>?
</titreref>
<idcategorie>3
</idcategorie>
<intro>test
</intro>
</querystring>
</info>
<db>
<query>
<status>1
</status>
<data>
</data>
</query>
<query>
<status>0
</status>
<data>
</data>
</query>
<query>
<status>
</status>
<data>
<L=5FTITRE>?
</L=5FTITRE>
<L=5FTEXTE>test
</L=5FTEXTE>
<L=5FLANGUE>N
</L=5FLANGUE>
<N=5FTITRE>Zuid musiek aan Luik
</N=5FTITRE>
<N=5FTEXTE>Lacuna Coil aan Dalhem (men kan droomen)
</N=5FTEXTE>
<N=5FID>2
</N=5FID>
<E=5FCODE>mu
</E=5FCODE>
<E=5FLIB=5FFR>Musique
</E=5FLIB=5FFR>
<E=5FLIB=5FNL>Musiek
</E=5FLIB=5FNL>
<E=5FLIB=5FEN>
</E=5FLIB=5FEN>
<E=5FLIB=5FAL>
</E=5FLIB=5FAL>
</data>
</query>
</db>
</action>
=20
Let's assume some other input data are given by the following alternate=20
XML file:
<?xml version=3D'1.0' encoding=3D'WINDOWS-1252'?>
<action>
<info>
<querystring>
<langue>N
</langue>
<idnewsletter>10
</idnewsletter>
<titreref>?
</titreref>
<idcategorie>3
</idcategorie>
<intro>test
</intro>
</querystring>
</info>
<db>
<query>
<status>
</status>
<data>
<L=5FTITRE>?
</L=5FTITRE>
<L=5FTEXTE>test
</L=5FTEXTE>
<L=5FLANGUE>N
</L=5FLANGUE>
<N=5FTITRE>Zuid musiek aan Luik
</N=5FTITRE>
<N=5FTEXTE>Lacuna Coil aan Dalhem (men kan droomen)
</N=5FTEXTE>
<N=5FID>2
</N=5FID>
<E=5FCODE>mu
</E=5FCODE>
<E=5FLIB=5FFR>Musique
</E=5FLIB=5FFR>
<E=5FLIB=5FNL>Musiek
</E=5FLIB=5FNL>
<E=5FLIB=5FEN>
</E=5FLIB=5FEN>
<E=5FLIB=5FAL>
</E=5FLIB=5FAL>
</data>
</query>
</db>
</action>
=20
=20
Let's assume the presentation is given by the following XSL file:
=20
<?xml version=3D"1.0" encoding=3D"WINDOWS-1252"?>
<xsl:stylesheet version=3D"1.0" xmlns:xsl=3D"
http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding=3D"WINDOWS-1252" method=3D"text" media-type=3D"text/pl=
ain;=20
charset=3DWINDOWS-1252" omit-xml-declaration=3D"yes"/>
<!--<xsl:output encoding=3D"WINDOWS-1252" media-type=3D"text/plain;=20
charset=3DWINDOWS-1252" omit-xml-declaration=3D"yes" />-->
<xsl:template match=3D"/">
<xsl:if=20
test=3D"count(//action/db[position()=3D1]/query[position()=3D3]/data/E=5FCO=
DE)">
<xsl:value-of=20
select=3D"/action/db[position()=3D1]/query[position()=3D3]/data/L=5FTITRE" =
disable-output-escaping=3D"yes" />
<xsl:text>
</xsl:text>
<xsl:value-of=20
select=3D"/action/db[position()=3D1]/query[position()=3D3]/data/L=5FTEXTE" =
disable-output-escaping=3D"yes" />
<xsl:text>
</xsl:text>
<xsl:for-each=20
select=3D"/action/db[position()=3D1]/query[position()=3D3]/data">
<xsl:choose>
<xsl:when test=3D"./L=5FLANGUE =3D 'N'">
[<xsl:value-of select=3D"./E=5FLIB=5FNL" disable-output-escaping=3D"yes" =
/>]
</xsl:when>
<xsl:when test=3D"./N=5FLANGUE =3D 'A'">
[<xsl:value-of select=3D"./E=5FLIB=5FAL" disable-output-escaping=3D"yes" =
/>]
</xsl:when>
<xsl:when test=3D"./N=5FLANGUE =3D 'E'">
[<xsl:value-of select=3D"./E=5FLIB=5FEN" disable-output-escaping=3D"yes" =
/>]
</xsl:when>
<xsl:otherwise>
[<xsl:value-of select=3D"./E=5FLIB=5FFR" disable-output-escaping=3D"yes" =
/>]
</xsl:otherwise>
</xsl:choose>
<xsl:text>
</xsl:text>
<xsl:value-of select=3D"./N=5FTITRE" disable-output-escaping=3D"yes" />
<xsl:text>
</xsl:text>
<xsl:value-of select=3D"./N=5FTEXTE" disable-output-escaping=3D"yes" />
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:if>
</xsl:template>
</xsl:stylesheet>=20
Let's assume the Java source code that performs the XSLT transformation is =
given by the following Java file:
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
/**
* Use the TraX interface to perform a transformation in the simplest=20
manner possible
* (3 statements).
*/
public class SimpleTransform
{
public static void main(String[] args)
throws TransformerException, TransformerConfigurationException,=20
FileNotFoundException, IOException
{=20
// Use the static TransformerFactory.newInstance() method to instantiate =
// a TransformerFactory. The javax.xml.transform.TransformerFactory=20
// system property setting determines the actual class to instantiate --
// org.apache.xalan.transformer.TransformerImpl.
TransformerFactory tFactory =3D TransformerFactory.newInstance();
=20
// Use the TransformerFactory to instantiate a Transformer that will work =
with=20
// the stylesheet you specify. This method call also processes the=20
stylesheet
// into a compiled Templates object.
Transformer transformer =3D tFactory.newTransformer(new=20
StreamSource("birds.xsl"));
// Use the Transformer to apply the associated Templates object to an XML =
document
// (foo.xml) and write the output to a file (foo.out).
transformer.transform(new StreamSource("birds.xml"), new StreamResult(new =
FileOutputStream("birds.out")));
=20
System.out.println("************* The result is in birds.out=20
*************");
}
}
Now we perform three transformations:
1) one with the method=3D"text" <xsl: output> attribute and with the=20
original XML and XSL file
2) one with the method=3D"text" <xsl: output> attribute but with an update=
d=20
XML file and the original XSL file
3) one with the method=3D"xml" <xsl: output> attribute and with the=20
original XML and XSL file
The results differ.
1) The first test with
<xsl:output encoding=3D"WINDOWS-1252" method=3D"text"=20
media-type=3D"text/plain; charset=3DWINDOWS-1252" omit-xml-declaration=3D"y=
es"/>
fails with the following Java exception
com.sun.org.apache.xalan.internal.xsltc.TransletException:=20
org.xml.sax.SAXException: Attempt to output character of integral value=20
8364 that is not represented in specified output encoding of WINDOWS-1252. =
2) The 2th test succeeds.
3) The 3rd test succeeds.
What happens according to you? How to solve this problem?
Thank you.
Philippe
|