[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. &nbsp;I don't see any problem. &nbsp;The package name </font><font \
size=2><tt>com.sun.org.apache.xalan.internal.xsltc.TransletException &nbsp;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
&lt;philippe.waltregny@nrb.be&gt;</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">&quot;'Laurent Foramitti'&quot;
&lt;laurent.foramitti@nrb.be&gt;</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 \
&lt;xsl:output&gt;</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>
&lt;?xml version='1.0' encoding='WINDOWS-1252'?&gt;<br>
&lt;action&gt;<br>
 &nbsp; &nbsp;&lt;info&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;querystring&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;langue&gt;N<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/langue&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;idnewsletter&gt;10<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/idnewsletter&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;titreref&gt;&#8364;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/titreref&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;idcategorie&gt;3<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/idcategorie&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;intro&gt;test<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/intro&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;/querystring&gt;<br>
 &nbsp; &nbsp;&lt;/info&gt;<br>
 &nbsp; &nbsp;&lt;db&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;query&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;status&gt;1<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/status&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;data&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/data&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;/query&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;query&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;status&gt;0<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/status&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;data&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/data&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;/query&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;query&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;status&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/status&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;data&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;L_TITRE&gt;&#8364;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/L_TITRE&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;L_TEXTE&gt;test<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/L_TEXTE&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;L_LANGUE&gt;N<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/L_LANGUE&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;N_TITRE&gt;Zuid
musiek aan Luik<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/N_TITRE&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;N_TEXTE&gt;Lacuna
Coil aan Dalhem (men kan droomen)<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/N_TEXTE&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;N_ID&gt;2<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/N_ID&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;E_CODE&gt;mu<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/E_CODE&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;E_LIB_FR&gt;Musique<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/E_LIB_FR&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;E_LIB_NL&gt;Musiek<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/E_LIB_NL&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;E_LIB_EN&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/E_LIB_EN&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;E_LIB_AL&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/E_LIB_AL&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/data&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;/query&gt;<br>
 &nbsp; &nbsp;&lt;/db&gt;<br>
&lt;/action&gt;<br>
 <br>
<br>
Let's assume some other input data are given by the following alternate
XML file:<br>
<br>
&lt;?xml version='1.0' encoding='WINDOWS-1252'?&gt;<br>
&lt;action&gt;<br>
 &nbsp; &nbsp;&lt;info&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;querystring&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;langue&gt;N<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/langue&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;idnewsletter&gt;10<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/idnewsletter&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;titreref&gt;&#8364;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/titreref&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;idcategorie&gt;3<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/idcategorie&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;intro&gt;test<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/intro&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;/querystring&gt;<br>
 &nbsp; &nbsp;&lt;/info&gt;<br>
 &nbsp; &nbsp;&lt;db&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;query&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;status&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/status&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;data&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;L_TITRE&gt;&#8364;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/L_TITRE&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;L_TEXTE&gt;test<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/L_TEXTE&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;L_LANGUE&gt;N<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/L_LANGUE&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;N_TITRE&gt;Zuid
musiek aan Luik<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/N_TITRE&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;N_TEXTE&gt;Lacuna
Coil aan Dalhem (men kan droomen)<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/N_TEXTE&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;N_ID&gt;2<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/N_ID&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;E_CODE&gt;mu<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/E_CODE&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;E_LIB_FR&gt;Musique<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/E_LIB_FR&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;E_LIB_NL&gt;Musiek<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/E_LIB_NL&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;E_LIB_EN&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/E_LIB_EN&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;E_LIB_AL&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/E_LIB_AL&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/data&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;/query&gt;<br>
 &nbsp; &nbsp;&lt;/db&gt;<br>
&lt;/action&gt;<br>
 &nbsp; <br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>
Let's assume the presentation is given by the following XSL file:<br>
 <br>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;WINDOWS-1252&quot;?&gt;<br>
&lt;xsl:stylesheet version=&quot;1.0&quot; \
xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;&gt;<br> &lt;xsl:output \
encoding=&quot;WINDOWS-1252&quot; method=&quot;text&quot; \
media-type=&quot;text/plain; charset=WINDOWS-1252&quot; \
omit-xml-declaration=&quot;yes&quot;/&gt;<br> <br>
&lt;!--&lt;xsl:output encoding=&quot;WINDOWS-1252&quot; media-type=&quot;text/plain;
charset=WINDOWS-1252&quot; omit-xml-declaration=&quot;yes&quot; /&gt;--&gt;<br>
&lt;xsl:template match=&quot;/&quot;&gt;<br>
&lt;xsl:if test=&quot;count(//action/db[position()=1]/query[position()=3]/data/E_CODE)&quot;&gt;<br>
 <br>
&lt;xsl:value-of select=&quot;/action/db[position()=1]/query[position()=3]/data/L_TITRE&quot;
 disable-output-escaping=&quot;yes&quot; /&gt;<br>
<br>
&lt;xsl:text&gt;<br>
<br>
&lt;/xsl:text&gt;<br>
<br>
&lt;xsl:value-of select=&quot;/action/db[position()=1]/query[position()=3]/data/L_TEXTE&quot;
 disable-output-escaping=&quot;yes&quot; /&gt;<br>
<br>
 &nbsp; &lt;xsl:text&gt;<br>
<br>
<br>
 &nbsp; &lt;/xsl:text&gt;<br>
<br>
 &nbsp; &lt;xsl:for-each \
select=&quot;/action/db[position()=1]/query[position()=3]/data&quot;&gt;<br>  &nbsp; \
&nbsp; &lt;xsl:choose&gt;<br>  &nbsp; &nbsp; &nbsp; &nbsp;&lt;xsl:when \
test=&quot;./L_LANGUE = 'N'&quot;&gt;<br>  &nbsp;[&lt;xsl:value-of \
select=&quot;./E_LIB_NL&quot; disable-output-escaping=&quot;yes&quot; /&gt;]<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;/xsl:when&gt;<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;xsl:when test=&quot;./N_LANGUE = 'A'&quot;&gt;<br>
 &nbsp;[&lt;xsl:value-of select=&quot;./E_LIB_AL&quot; \
disable-output-escaping=&quot;yes&quot; /&gt;]<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;/xsl:when&gt;<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;xsl:when test=&quot;./N_LANGUE = 'E'&quot;&gt;<br>
 &nbsp;[&lt;xsl:value-of select=&quot;./E_LIB_EN&quot; \
disable-output-escaping=&quot;yes&quot; /&gt;]<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;/xsl:when&gt;<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;xsl:otherwise&gt;<br>
 &nbsp;[&lt;xsl:value-of select=&quot;./E_LIB_FR&quot; \
disable-output-escaping=&quot;yes&quot; /&gt;]<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;/xsl:otherwise&gt;<br>
 &nbsp; &nbsp; &lt;/xsl:choose&gt;<br>
<br>
 &nbsp; &nbsp; &lt;xsl:text&gt;<br>
<br>
 &nbsp; &nbsp; &lt;/xsl:text&gt;<br>
<br>
 &nbsp; &nbsp;&lt;xsl:value-of select=&quot;./N_TITRE&quot; \
disable-output-escaping=&quot;yes&quot; /&gt;<br>
<br>
 &nbsp; &nbsp; &lt;xsl:text&gt;<br>
<br>
 &nbsp; &nbsp; &lt;/xsl:text&gt;<br>
<br>
 &nbsp; &nbsp;&lt;xsl:value-of select=&quot;./N_TEXTE&quot; \
disable-output-escaping=&quot;yes&quot; /&gt;<br>
<br>
 &nbsp; &nbsp; &lt;xsl:text&gt;<br>
<br>
 &nbsp; &nbsp; &lt;/xsl:text&gt;<br>
<br>
 &nbsp;&lt;/xsl:for-each&gt;<br>
&lt;/xsl:if&gt;<br>
&lt;/xsl:template&gt;<br>
&lt;/xsl:stylesheet&gt; <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>
 * &nbsp;Use the TraX interface to perform a transformation in the simplest
manner possible<br>
 * &nbsp;(3 statements).<br>
 */<br>
public class SimpleTransform<br>
{<br>
 public static void main(String[] args)<br>
 &nbsp; &nbsp;throws TransformerException, TransformerConfigurationException,
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FileNotFoundException, IOException<br>
 &nbsp;{ &nbsp;<br>
 &nbsp;// Use the static TransformerFactory.newInstance() method to instantiate
<br>
 &nbsp;// a TransformerFactory. The javax.xml.transform.TransformerFactory
<br>
 &nbsp;// system property setting determines the actual class to instantiate
--<br>
 &nbsp;// org.apache.xalan.transformer.TransformerImpl.<br>
 TransformerFactory tFactory = TransformerFactory.newInstance();<br>
 <br>
 // Use the TransformerFactory to instantiate a Transformer that will work
with &nbsp;<br>
 // the stylesheet you specify. This method call also processes the stylesheet<br>
 &nbsp;// into a compiled Templates object.<br>
 Transformer transformer = tFactory.newTransformer(new \
StreamSource(&quot;birds.xsl&quot;));<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(&quot;birds.xml&quot;), new StreamResult(new
FileOutputStream(&quot;birds.out&quot;)));<br>
 <br>
 System.out.println(&quot;************* The result is in birds.out \
*************&quot;);<br>  &nbsp;}<br>
}<br>
<br>
<br>
Now we perform three transformations:<br>
<br>
 1) one with the method=&quot;text&quot; &lt;xsl: output&gt; attribute
and with the original XML and XSL file<br>
 2) one with the method=&quot;text&quot; &lt;xsl: output&gt; attribute
but with an updated XML file and the original XSL file<br>
 3) one with the method=&quot;xml&quot; &nbsp;&lt;xsl: output&gt; attribute
and with the original XML and XSL file<br>
<br>
<br>
The results differ.<br>
<br>
1) The first test with<br>
 &nbsp; &nbsp; &nbsp;&lt;xsl:output encoding=&quot;WINDOWS-1252&quot; \
method=&quot;text&quot; media-type=&quot;text/plain; charset=WINDOWS-1252&quot; \
omit-xml-declaration=&quot;yes&quot;/&gt;<br> fails with the following Java \
exception<br>  &nbsp; &nbsp; \
                &nbsp;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