Mantis - Quercus
Viewing Issue Advanced Details
5586 minor always 11-12-13 13:44 11-12-13 13:44
JFM  
 
normal  
new 4.0.36  
open  
none    
none  
0005586: DomDocument UTF-8 Encoding problem

Quercus War 4.0.37
java version "1.7.0_40"
import java.io.IOException;

import javax.script.ScriptEngine;
import javax.script.ScriptException;

import org.w3c.dom.Document;
import org.w3c.dom.ProcessingInstruction;
import org.xml.sax.SAXException;

import com.caucho.quercus.QuercusEngine;
import com.caucho.xml.AbstractParser;
import com.caucho.xml.Xml;

public class QuercusTest {

    private static ScriptEngine engine;

    public static void main(String[] args) throws ScriptException, IOException {
        
         String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>

&0000937;

";
                  
         Document doc;
        try {
            doc = new Xml().parseDocumentString(xml);
             System.out.println(doc.getTextContent());
        } catch (SAXException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
        
        
        
        QuercusEngine engine = new QuercusEngine();
        
        //NOTE: add WEB-INF/classes/META-INF/services/com.caucho.quercus.QuercusModule to classpath
        engine.getQuercus().init();
        engine.execute("<?php "

                + "$dom = new DOMDocument();"
                + "$dom->loadXML('<?xml version=\"1.0\" encoding=\"UTF-8\"?>

&0000937;

');"
                + "output($dom);"

                + "$dom->loadXML('

&0000937;

');"
                + "output($dom);"

                + "$dom->loadXML('

&0000937;

');"
                + "$dom->encoding = \"UTF-8\";"
                + "output($dom);"

                + "$dom = new DOMDocument();"
                + "$dom->appendChild($dom->createTextNode('&0000937;'));"
                + "output($dom);"

                + "$dom = new DOMDocument('1.0', 'UTF-8');"
                + "$dom->appendChild($dom->createTextNode('&0000937;'));"
                + "output($dom);"

                + "$dom = new DOMDocument('1.0', 'ISO-8859-1');"
                + "$dom->appendChild($dom->createTextNode('&0000937;'));"
                + "output($dom);"

                + "$dom = new DOMDocument('1.0', 'ISO-8859-1');"
                + "$dom->loadXML('<?xml version=\"1.0\" encoding=\"UTF-8\"?>

&0000937;

');"
                + "output($dom);"

                + "function output($dom){"
                + " print 'encoding: ' . $dom->encoding . \"\n\";"
                + " print $dom->saveXML() . \"\n\";"
                + "}" );
        
        /*
        engine.execute("<?php "
                + "$xml = new DOMDocument;"
                + "$xml->load($file);"
                + "$xsl = new DOMDocument;"
                + "$xsl->load($xslfile);"
                + "$proc = new XSLTProcessor;"
                + "$proc->importStyleSheet($xsl); "
                + "echo $proc->transformToXML($xml);" );
                */

    }

}

There are no notes attached to this issue.