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 <[EMAIL PROTECTED]>

11/30/2005 08:14 AM

To
xalan-j-users@xml.apache.org
cc
"'Laurent Foramitti'" <[EMAIL PROTECTED]>
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


Reply via email to