You are viewing a plain text version of this content. The canonical link for it is here.
Posted to odf-dev@incubator.apache.org by "Svante Schubert (JIRA)" <ji...@apache.org> on 2017/06/20 10:49:00 UTC
[jira] [Commented] (ODFTOOLKIT-455) Text document with
"style:style" attribute cannot be parsed by odfdom
[ https://issues.apache.org/jira/browse/ODFTOOLKIT-455?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16055567#comment-16055567 ]
Svante Schubert commented on ODFTOOLKIT-455:
--------------------------------------------
Many thanks for your patch, Bjoern! :D
I have reviewed it and after a while the fix became obvious, do only look for cached element classes from the incubator package, if it is an ODF element :) Before 1.0 we should think about dropping the "incubator" package naming anyway.
Just wanted to be certain that still our typed ODF attribute classes are being used..
During review, I have added a comment
// Ignore looking for XML namespace attributes or ODF elements without prefix, as there are no typed ODF classes
// (NOTE: For any ODF node from the schema the ODF prefix would ALWAYS exist as there is a prefix normalization during previous loading)
and added a parameter for the isAttribute boolean, as it only depends on the two calling methods, I found it more intuitive for myself :)
I had problems with SVN patches adding files previously myself. So I have taken the Example.odt from the JIRA usse and exchanged it with the empty odfdom/src/test/resources/TestStyleStyleAttribute.odt within the test patch.
( I think we should move from Subversion to GIT sooner or later, better sooner)
The test doc - as you know - contained the attribute style:style, which is named like the ODF element <style:style>
<style:column-sep style:width="0.009cm" style:color="#000000" style:height="100%" *style:style*="solid"/>
> Text document with "style:style" attribute cannot be parsed by odfdom
> ----------------------------------------------------------------------
>
> Key: ODFTOOLKIT-455
> URL: https://issues.apache.org/jira/browse/ODFTOOLKIT-455
> Project: ODF Toolkit
> Issue Type: Bug
> Components: odfdom
> Reporter: Bjoern Kirchhoff
> Attachments: Example.odt, ODFTOOLKIT-455-Fix.patch, Test_document_with_stylestyle_attribute.patch
>
>
> 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:
> {quote}
> 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)
> {quote}
> The reason for this is, that OdfDom treats this attribute as an element inside the class OdfXMLFactory in the method called getOdfNodeClass.
> The line:
> {quote}
> if (mIncubatorElements.contains(qName))
> {quote}
> should look like this:
> {quote}
> if ( mIncubatorElements.contains(qName) && nodeType.equals(ELEMENT_PACKAGE_NAME) )
> {quote}
> I will provide a patch and a testcase for that.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)