#906 Empty properties from template.getOutputProperties()

v9.1
closed
Michael Kay
5
2012-10-08
2008-12-15
vab
No

Empty properties from template.getOutputProperties() from XSLT 1.0 template
(<xsl:output method="html" encoding="UTF-8" media-type="application/vnd.ms-excel"/>)

Discussion

  • Michael Kay
    Michael Kay
    2008-12-15

    I can't reproduce this. I suspect you used props.get("method") to read the property value, rather than props.getProperty("method").

    Please also note, I ask people not to report problems on this tracker, but in the first place via the saxon-help mailing list or forum. This makes it easier for users to search the tracker for real bugs. Otherwise this tracker would be cluttered up with requests for programming help.

    Also, wherever you submit the problem, it helps to show your code. Then I can tell you where you actually went wrong, rather than guessing.

     
  • vab
    vab
    2008-12-15

    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.PrintWriter;

    import javax.xml.transform.Templates;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.stream.StreamSource;

    /
    * Created on Dec 15, 2008

    */

    public class bugDemo {
    public static void main(String[] args) {
    try{
    File templatesURL = new File("bugDemo.xsl");
    PrintWriter pw = new PrintWriter(new FileOutputStream(templatesURL,false));
    pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    pw.println("<xsl:stylesheet version="\\"1.0\\"" xmlns:xsl="\\"http://www.w3.org/1999/XSL/Transform\\"">");
    pw.println("<xsl:output method="\\"html\\"" encoding="\\"UTF-8\\"" media-type="\\"application/vnd.ms-excel\\"/">");
    pw.println("<xsl:template match="\\"/statements\\"">");
    pw.println("</xsl:template>");
    pw.println("</xsl:stylesheet>");
    pw.flush();
    pw.close();

            TransformerFactory tFactory = (TransformerFactory)Class.forName(OLD_SAXON_TRAN_FACT_CLASS).newInstance();
            StreamSource source = new StreamSource(templatesURL);
            Templates template = tFactory.newTemplates(source);
            System.out.println("SAXON 6 template.getOutputProperties():"+template.getOutputProperties());
    
            tFactory = (TransformerFactory)Class.forName(SAXON_TRAN_FACT_CLASS).newInstance();
            source = new StreamSource(templatesURL);
            template = tFactory.newTemplates(source);
            System.out.println("SAXON 8 template.getOutputProperties():"+template.getOutputProperties());
        }catch (Exception e) {
            e.printStackTrace();
        }
    
    }
    public static final String OLD_SAXON_TRAN_FACT_CLASS = "com.icl.saxon.TransformerFactoryImpl"; 
    public static final String SAXON_TRAN_FACT_CLASS = "net.sf.saxon.TransformerFactoryImpl";
    

    }

     
  • vab
    vab
    2008-12-15

    SAXON 6 template.getOutputProperties():{encoding=UTF-8, media-type=application/vnd.ms-excel, method=html}
    Warning: at xsl:stylesheet on line 2 of file.../bugDemo.xsl:
    Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor
    SAXON 8 template.getOutputProperties():{}

     
  • Michael Kay
    Michael Kay
    2008-12-15

    Displaying a Java properties object as a string doesn't give you an accurate picture of what's in the object. Use getProperty() to access specific properties.

     
  • vab
    vab
    2008-12-15

    Sorry, you were right in my actual code used properties.containsKey()