Uploaded image for project: 'ODF Toolkit'
  1. ODF Toolkit
  2. ODFTOOLKIT-455

Text document with "style:style" attribute cannot be parsed by odfdom

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 0.6.2-incubating
    • odfdom
    • None

    Description

      A text document containing a "style:style" attribute for the element style:column-sep, cannot be parsed/loaded by OdfDom.

      <style:column-sep style:width="0.009cm" style:color="#000000" style:height="100%" style:style="solid"/>

      This is the Excpetion thrown by odfdom-0.8.10:

      java.lang.ClassCastException: org.odftoolkit.odfdom.incubator.doc.style.OdfStyle cannot be cast to org.odftoolkit.odfdom.pkg.OdfAttribute
      at org.odftoolkit.odfdom.pkg.OdfXMLFactory.newOdfAttribute(OdfXMLFactory.java:256)
      at org.odftoolkit.odfdom.pkg.OdfFileDom.createAttributeNS(OdfFileDom.java:332)
      at org.odftoolkit.odfdom.pkg.OdfFileDom.createAttributeNS(OdfFileDom.java:322)
      at org.odftoolkit.odfdom.pkg.OdfFileSaxHandler.startElement(OdfFileSaxHandler.java:104)
      at org.odftoolkit.odfdom.pkg.rdfa.MultiContentHandler.startElement(MultiContentHandler.java:83)
      at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
      at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
      at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
      at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
      at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
      at org.odftoolkit.odfdom.pkg.OdfFileDom.initialize(OdfFileDom.java:223)
      at org.odftoolkit.odfdom.dom.OdfContentDom.initialize(OdfContentDom.java:60)
      at org.odftoolkit.odfdom.pkg.OdfFileDom.<init>(OdfFileDom.java:105)
      at org.odftoolkit.odfdom.dom.OdfContentDom.<init>(OdfContentDom.java:50)
      at org.odftoolkit.odfdom.pkg.OdfFileDom.newFileDom(OdfFileDom.java:157)
      at org.odftoolkit.odfdom.pkg.OdfPackageDocument.getFileDom(OdfPackageDocument.java:323)
      at org.odftoolkit.odfdom.dom.OdfSchemaDocument.getFileDom(OdfSchemaDocument.java:405)
      at org.odftoolkit.odfdom.dom.OdfSchemaDocument.getContentDom(OdfSchemaDocument.java:206)
      at org.odftoolkit.simple.Document.getContentRoot(Document.java:870)
      at org.odftoolkit.simple.TextDocument.getContentRoot(TextDocument.java:327)
      at org.odftoolkit.simple.TextDocument.getContentRoot(TextDocument.java:114)
      at de.eeconsultants.escriba.common.officecomponent.blockeditmode.TextBlockVariantUtil.main(TextBlockVariantUtil.java:593)

      The reason for this is, that OdfDom treats this attribute as an element inside the class OdfXMLFactory in the method called getOdfNodeClass.

      The line:

      if (mIncubatorElements.contains(qName))

      should look like this:

      if ( mIncubatorElements.contains(qName) && nodeType.equals(ELEMENT_PACKAGE_NAME) )

      I will provide a patch and a testcase for that.

      Attachments

        1. Example.odt
          9 kB
          Bjoern Kirchhoff
        2. ODFTOOLKIT-455-Fix.patch
          1 kB
          Bjoern Kirchhoff
        3. Test_document_with_stylestyle_attribute.patch
          3 kB
          Bjoern Kirchhoff

        Issue Links

          Activity

            People

              svanteschubert Svante Schubert
              Kirchhoff Bjoern Kirchhoff
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: