xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ted X. Toth" <t...@elegiant.com>
Subject Crimson/Xalan2 and ENTITY elements
Date Tue, 19 Jun 2001 20:14:16 GMT
I'm creating a document using the DOM API. Part of the data I'm building into the document
is HTML which contains entity references. ( I parse the HTML and create nodes of the appropriate
type in the document.) One question is how do I get ENTITY elements into the document? I tried
the following:
    Document doc = null;
    DocumentBuilderFactoryImpl docBuilderFactoryImpl = new DocumentBuilderFactoryImpl();

    StringBufferInputStream sbis = new StringBufferInputStream("<?xml version=\"1.0\"?>
<!DOCTYPE TEST_DOC [ <!ENTITY nbsp \"&#160;\" > ]> <TEST_DOC></TEST_DOC>");

    try {
      doc = docBuilderFactoryImpl.newDocumentBuilder().parse(sbis);
    catch (Exception ex) {

    Node rootElement = doc.getLastChild();

After adding other element to the document I can dump it:
        StringWriter docWriter = new StringWriter();
    try {
    catch (Exception ex) {

and the entity references appear in the output. However, when I transform the document:

        // Use the DOM Document to define a DOMSource object.
        DOMSource domSource = new DOMSource(doc);
        XmlDocument xmlDoc = (XmlDocument)doc;
        // Perform the transformation, placing the output in the DOMResult.
        TransformerFactory tFactory = TransformerFactory.newInstance();

         if(tFactory.getFeature(DOMSource.FEATURE) && tFactory.getFeature(DOMResult.FEATURE))
            File file = new File(i_xsltDocPath);
            transformer = tFactory.newTransformer(new StreamSource(file));

            transformer.transform(domSource, new javax.xml.transform.stream.StreamResult(stringWriter));


to HTML the entity references don't showup in the output. Any ideas who isn't processing them?
It seem like it could be Xerces or Xalan that is neglecting them. Right now it doesn't seem
that the DOM API is complete enough to create documents with.

Ted X. Toth 
Elegiant, Inc.
8705 Shoal Creek Blvd., Suite 202
Austin, TX 78757
Phone: 512.206.0660  
Fax: 512.206.0003

View raw message