Uploaded image for project: 'XMLBeans'
  1. XMLBeans
  2. XMLBEANS-538

Unable to parse a Node with a Doctype

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Version 3.0.2
    • Fix Version/s: Version 3.1.0
    • Component/s: None
    • Labels:
      None

      Description

      XmlBeans is unable to handle a org.w3c.dom.Document that uses a Doctype Declaratiion. It works if the xml is passed as a String.

      import org.apache.xmlbeans.XmlObject;
      import org.junit.Test;
      import org.w3c.dom.Document;
      
      import javax.xml.parsers.DocumentBuilder;
      import javax.xml.parsers.DocumentBuilderFactory;
      import java.io.ByteArrayInputStream;
      import java.nio.charset.StandardCharsets;
      
      
      public class SvgGraphicImplTest {
          @Test
          public void parseIT() throws Exception {
              final String svgDocumentString = "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n" +
                      "\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n" +
                      "<svg />";
              XmlObject.Factory.parse(svgDocumentString); //it works as a String
              final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
              final DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
              final Document parse = documentBuilder.parse(new ByteArrayInputStream(svgDocumentString.getBytes(StandardCharsets.US_ASCII)));
              XmlObject.Factory.parse(parse);  //this doesnt'
          }
      }
      

        Attachments

          Activity

            People

            • Assignee:
              pj.fanning PJ Fanning
              Reporter:
              goesen Thorsten Goetzke
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 10m
                10m