[prev in list] [next in list] [prev in thread] [next in thread]
List: xalan-j-users
Subject: Re: Question about <xsl:output>
From: Yash Talwar <ytalwar () ca ! ibm ! com>
Date: 2005-11-30 16:21:30
Message-ID: OF91FFBEB1.AFDBC267-ON852570C9.00597B2D-852570C9.0059DA7F () ca ! ibm ! com
[Download RAW message or body]
This is a multipart message in MIME format.
--=_alternative 0059DA7B852570C9_Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi Phillippe,
I have tried your sample with latest from apache. I don't see any
problem. The package name
com.sun.org.apache.xalan.internal.xsltc.TransletException suggests that
you may not be using apache version of Xalan.
Thanks!
Yash Talwar
Philippe Waltregny-Dengis <philippe.waltregny@nrb.be>
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
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:
<?xml version='1.0' encoding='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_TITRE>?
</L_TITRE>
<L_TEXTE>test
</L_TEXTE>
<L_LANGUE>N
</L_LANGUE>
<N_TITRE>Zuid musiek aan Luik
</N_TITRE>
<N_TEXTE>Lacuna Coil aan Dalhem (men kan droomen)
</N_TEXTE>
<N_ID>2
</N_ID>
<E_CODE>mu
</E_CODE>
<E_LIB_FR>Musique
</E_LIB_FR>
<E_LIB_NL>Musiek
</E_LIB_NL>
<E_LIB_EN>
</E_LIB_EN>
<E_LIB_AL>
</E_LIB_AL>
</data>
</query>
</db>
</action>
Let's assume some other input data are given by the following alternate
XML file:
<?xml version='1.0' encoding='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_TITRE>?
</L_TITRE>
<L_TEXTE>test
</L_TEXTE>
<L_LANGUE>N
</L_LANGUE>
<N_TITRE>Zuid musiek aan Luik
</N_TITRE>
<N_TEXTE>Lacuna Coil aan Dalhem (men kan droomen)
</N_TEXTE>
<N_ID>2
</N_ID>
<E_CODE>mu
</E_CODE>
<E_LIB_FR>Musique
</E_LIB_FR>
<E_LIB_NL>Musiek
</E_LIB_NL>
<E_LIB_EN>
</E_LIB_EN>
<E_LIB_AL>
</E_LIB_AL>
</data>
</query>
</db>
</action>
Let's assume the presentation is given by the following XSL file:
<?xml version="1.0" encoding="WINDOWS-1252"?>
<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="WINDOWS-1252" method="text" media-type="text/plain;
charset=WINDOWS-1252" omit-xml-declaration="yes"/>
<!--<xsl:output encoding="WINDOWS-1252" media-type="text/plain;
charset=WINDOWS-1252" omit-xml-declaration="yes" />-->
<xsl:template match="/">
<xsl:if
test="count(//action/db[position()=1]/query[position()=3]/data/E_CODE)">
<xsl:value-of
select="/action/db[position()=1]/query[position()=3]/data/L_TITRE"
disable-output-escaping="yes" />
<xsl:text>
</xsl:text>
<xsl:value-of
select="/action/db[position()=1]/query[position()=3]/data/L_TEXTE"
disable-output-escaping="yes" />
<xsl:text>
</xsl:text>
<xsl:for-each
select="/action/db[position()=1]/query[position()=3]/data">
<xsl:choose>
<xsl:when test="./L_LANGUE = 'N'">
[<xsl:value-of select="./E_LIB_NL" disable-output-escaping="yes" />]
</xsl:when>
<xsl:when test="./N_LANGUE = 'A'">
[<xsl:value-of select="./E_LIB_AL" disable-output-escaping="yes" />]
</xsl:when>
<xsl:when test="./N_LANGUE = 'E'">
[<xsl:value-of select="./E_LIB_EN" disable-output-escaping="yes" />]
</xsl:when>
<xsl:otherwise>
[<xsl:value-of select="./E_LIB_FR" disable-output-escaping="yes" />]
</xsl:otherwise>
</xsl:choose>
<xsl:text>
</xsl:text>
<xsl:value-of select="./N_TITRE" disable-output-escaping="yes" />
<xsl:text>
</xsl:text>
<xsl:value-of select="./N_TEXTE" disable-output-escaping="yes" />
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
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
manner possible
* (3 statements).
*/
public class SimpleTransform
{
public static void main(String[] args)
throws TransformerException, TransformerConfigurationException,
FileNotFoundException, IOException
{
// Use the static TransformerFactory.newInstance() method to instantiate
// a TransformerFactory. The javax.xml.transform.TransformerFactory
// system property setting determines the actual class to instantiate --
// org.apache.xalan.transformer.TransformerImpl.
TransformerFactory tFactory = TransformerFactory.newInstance();
// Use the TransformerFactory to instantiate a Transformer that will work
with
// the stylesheet you specify. This method call also processes the
stylesheet
// into a compiled Templates object.
Transformer transformer = tFactory.newTransformer(new
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")));
System.out.println("************* The result is in birds.out
*************");
}
}
Now we perform three transformations:
1) one with the method="text" <xsl: output> attribute and with the
original XML and XSL file
2) one with the method="text" <xsl: output> attribute but with an updated
XML file and the original XSL file
3) one with the method="xml" <xsl: output> attribute and with the
original XML and XSL file
The results differ.
1) The first test with
<xsl:output encoding="WINDOWS-1252" method="text"
media-type="text/plain; charset=WINDOWS-1252" omit-xml-declaration="yes"/>
fails with the following Java exception
com.sun.org.apache.xalan.internal.xsltc.TransletException:
org.xml.sax.SAXException: Attempt to output character of integral value
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
--=_alternative 0059DA7B852570C9_Content-Type: text/html; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
<br><font size=2 face="sans-serif">Hi Phillippe,</font>
<br><font size=2 face="sans-serif">I have tried your sample with latest
from apache. I don't see any problem. The package name </font><font \
size=2><tt>com.sun.org.apache.xalan.internal.xsltc.TransletException suggests \
that you may not be using apache version of Xalan.</tt></font> <br>
<br>
<br><font size=2><tt>Thanks!</tt></font>
<br><font size=2 face="sans-serif"><br>
Yash Talwar<br>
</font>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>Philippe Waltregny-Dengis
<philippe.waltregny@nrb.be></b> </font>
<p><font size=1 face="sans-serif">11/30/2005 08:14 AM</font>
<td width=59%>
<table width=100%>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td valign=top><font size=1 face="sans-serif">xalan-j-users@xml.apache.org</font>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td valign=top><font size=1 face="sans-serif">"'Laurent Foramitti'"
<laurent.foramitti@nrb.be></font>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td valign=top><font size=1 face="sans-serif">Question about \
<xsl:output></font></table> <br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><font size=2><tt>Hello,<br>
<br>
I would like to report you the following problem in order to receive any
suggestion to understand and solve this issue.<br>
<br>
<br>
I use Xalan-Java Version 2.7.0.<br>
<br>
<br>
Let's assume the input data are given by the following original XML file:<br>
<br>
<?xml version='1.0' encoding='WINDOWS-1252'?><br>
<action><br>
<info><br>
<querystring><br>
<langue>N<br>
</langue><br>
<idnewsletter>10<br>
</idnewsletter><br>
<titreref>€<br>
</titreref><br>
<idcategorie>3<br>
</idcategorie><br>
<intro>test<br>
</intro><br>
</querystring><br>
</info><br>
<db><br>
<query><br>
<status>1<br>
</status><br>
<data><br>
</data><br>
</query><br>
<query><br>
<status>0<br>
</status><br>
<data><br>
</data><br>
</query><br>
<query><br>
<status><br>
</status><br>
<data><br>
<L_TITRE>€<br>
</L_TITRE><br>
<L_TEXTE>test<br>
</L_TEXTE><br>
<L_LANGUE>N<br>
</L_LANGUE><br>
<N_TITRE>Zuid
musiek aan Luik<br>
</N_TITRE><br>
<N_TEXTE>Lacuna
Coil aan Dalhem (men kan droomen)<br>
</N_TEXTE><br>
<N_ID>2<br>
</N_ID><br>
<E_CODE>mu<br>
</E_CODE><br>
<E_LIB_FR>Musique<br>
</E_LIB_FR><br>
<E_LIB_NL>Musiek<br>
</E_LIB_NL><br>
<E_LIB_EN><br>
</E_LIB_EN><br>
<E_LIB_AL><br>
</E_LIB_AL><br>
</data><br>
</query><br>
</db><br>
</action><br>
<br>
<br>
Let's assume some other input data are given by the following alternate
XML file:<br>
<br>
<?xml version='1.0' encoding='WINDOWS-1252'?><br>
<action><br>
<info><br>
<querystring><br>
<langue>N<br>
</langue><br>
<idnewsletter>10<br>
</idnewsletter><br>
<titreref>€<br>
</titreref><br>
<idcategorie>3<br>
</idcategorie><br>
<intro>test<br>
</intro><br>
</querystring><br>
</info><br>
<db><br>
<query><br>
<status><br>
</status><br>
<data><br>
<L_TITRE>€<br>
</L_TITRE><br>
<L_TEXTE>test<br>
</L_TEXTE><br>
<L_LANGUE>N<br>
</L_LANGUE><br>
<N_TITRE>Zuid
musiek aan Luik<br>
</N_TITRE><br>
<N_TEXTE>Lacuna
Coil aan Dalhem (men kan droomen)<br>
</N_TEXTE><br>
<N_ID>2<br>
</N_ID><br>
<E_CODE>mu<br>
</E_CODE><br>
<E_LIB_FR>Musique<br>
</E_LIB_FR><br>
<E_LIB_NL>Musiek<br>
</E_LIB_NL><br>
<E_LIB_EN><br>
</E_LIB_EN><br>
<E_LIB_AL><br>
</E_LIB_AL><br>
</data><br>
</query><br>
</db><br>
</action><br>
<br>
<br>
Let's assume the presentation is given by the following XSL file:<br>
<br>
<?xml version="1.0" encoding="WINDOWS-1252"?><br>
<xsl:stylesheet version="1.0" \
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><br> <xsl:output \
encoding="WINDOWS-1252" method="text" \
media-type="text/plain; charset=WINDOWS-1252" \
omit-xml-declaration="yes"/><br> <br>
<!--<xsl:output encoding="WINDOWS-1252" media-type="text/plain;
charset=WINDOWS-1252" omit-xml-declaration="yes" />--><br>
<xsl:template match="/"><br>
<xsl:if test="count(//action/db[position()=1]/query[position()=3]/data/E_CODE)"><br>
<br>
<xsl:value-of select="/action/db[position()=1]/query[position()=3]/data/L_TITRE"
disable-output-escaping="yes" /><br>
<br>
<xsl:text><br>
<br>
</xsl:text><br>
<br>
<xsl:value-of select="/action/db[position()=1]/query[position()=3]/data/L_TEXTE"
disable-output-escaping="yes" /><br>
<br>
<xsl:text><br>
<br>
<br>
</xsl:text><br>
<br>
<xsl:for-each \
select="/action/db[position()=1]/query[position()=3]/data"><br> \
<xsl:choose><br> <xsl:when \
test="./L_LANGUE = 'N'"><br> [<xsl:value-of \
select="./E_LIB_NL" disable-output-escaping="yes" />]<br>
</xsl:when><br>
<br>
<xsl:when test="./N_LANGUE = 'A'"><br>
[<xsl:value-of select="./E_LIB_AL" \
disable-output-escaping="yes" />]<br>
</xsl:when><br>
<br>
<xsl:when test="./N_LANGUE = 'E'"><br>
[<xsl:value-of select="./E_LIB_EN" \
disable-output-escaping="yes" />]<br>
</xsl:when><br>
<br>
<xsl:otherwise><br>
[<xsl:value-of select="./E_LIB_FR" \
disable-output-escaping="yes" />]<br>
</xsl:otherwise><br>
</xsl:choose><br>
<br>
<xsl:text><br>
<br>
</xsl:text><br>
<br>
<xsl:value-of select="./N_TITRE" \
disable-output-escaping="yes" /><br>
<br>
<xsl:text><br>
<br>
</xsl:text><br>
<br>
<xsl:value-of select="./N_TEXTE" \
disable-output-escaping="yes" /><br>
<br>
<xsl:text><br>
<br>
</xsl:text><br>
<br>
</xsl:for-each><br>
</xsl:if><br>
</xsl:template><br>
</xsl:stylesheet> <br>
<br>
<br>
Let's assume the Java source code that performs the XSLT transformation
is given by the following Java file:<br>
<br>
import java.io.FileNotFoundException;<br>
import java.io.FileOutputStream;<br>
import java.io.IOException;<br>
<br>
import javax.xml.transform.Transformer;<br>
import javax.xml.transform.TransformerConfigurationException;<br>
import javax.xml.transform.TransformerException;<br>
import javax.xml.transform.TransformerFactory;<br>
import javax.xml.transform.stream.StreamResult;<br>
import javax.xml.transform.stream.StreamSource;<br>
<br>
/**<br>
* Use the TraX interface to perform a transformation in the simplest
manner possible<br>
* (3 statements).<br>
*/<br>
public class SimpleTransform<br>
{<br>
public static void main(String[] args)<br>
throws TransformerException, TransformerConfigurationException,
<br>
FileNotFoundException, IOException<br>
{ <br>
// Use the static TransformerFactory.newInstance() method to instantiate
<br>
// a TransformerFactory. The javax.xml.transform.TransformerFactory
<br>
// system property setting determines the actual class to instantiate
--<br>
// org.apache.xalan.transformer.TransformerImpl.<br>
TransformerFactory tFactory = TransformerFactory.newInstance();<br>
<br>
// Use the TransformerFactory to instantiate a Transformer that will work
with <br>
// the stylesheet you specify. This method call also processes the stylesheet<br>
// into a compiled Templates object.<br>
Transformer transformer = tFactory.newTransformer(new \
StreamSource("birds.xsl"));<br> <br>
// Use the Transformer to apply the associated Templates object to an
XML document<br>
// (foo.xml) and write the output to a file (foo.out).<br>
transformer.transform(new StreamSource("birds.xml"), new StreamResult(new
FileOutputStream("birds.out")));<br>
<br>
System.out.println("************* The result is in birds.out \
*************");<br> }<br>
}<br>
<br>
<br>
Now we perform three transformations:<br>
<br>
1) one with the method="text" <xsl: output> attribute
and with the original XML and XSL file<br>
2) one with the method="text" <xsl: output> attribute
but with an updated XML file and the original XSL file<br>
3) one with the method="xml" <xsl: output> attribute
and with the original XML and XSL file<br>
<br>
<br>
The results differ.<br>
<br>
1) The first test with<br>
<xsl:output encoding="WINDOWS-1252" \
method="text" media-type="text/plain; charset=WINDOWS-1252" \
omit-xml-declaration="yes"/><br> fails with the following Java \
exception<br> \
com.sun.org.apache.xalan.internal.xsltc.TransletException:
org.xml.sax.SAXException: Attempt to output character of integral value
8364 that is not represented in specified output encoding of WINDOWS-1252.
<br>
<br>
2) The 2th test succeeds.<br>
<br>
3) The 3rd test succeeds.<br>
<br>
<br>
What happens according to you? How to solve this problem?<br>
<br>
Thank you.<br>
<br>
Philippe<br>
<br>
</tt></font>
<br>
--=_alternative 0059DA7B852570C9_=--
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic