Hi Svante/Ralf, Please continue discussions on dev@. Ralf will need to submit PRs to the new Git base. Once you like the way he does it then we can discuss making Ralf a committer so that he can do it himself.
Assuming he is interested. Regards, Dave > On May 10, 2018, at 3:12 PM, Svante Schubert <[email protected]> > wrote: > > You hear it, Ralf! > No reason to fork and throw at some later time your work over the digital > fence. > Instead become the new ruler of the Simple API :) > Make it your work base! > > Have a nice evening (at least hear it is night), > Svante > ᐧ > > 2018-05-10 23:27 GMT+02:00 Dave Fisher <[email protected]>: > >> Hi Svante - >> >> Just a note, but ODFToolkit desperately needs active developers who are >> enabled to work on the code directly. >> >> Regards, >> Dave >> >>> On May 10, 2018, at 2:02 PM, Ralf Heydenreich <[email protected]> >> wrote: >>> >>> Hi David, >>> I've solved this problem with creation of a separate node. You can find >>> an example here: >>> https://bitbucket.org/fakturamadev/fakturama-2/src/ >> 0b8ffae87c445ddd7e0618ecf643591ee933ba15/Fakturama-Parent/ >> org.fakturama.print.openoffice/src/main/java/org/odftoolkit/simple/common/ >> navigation/PlaceholderNode.java?at=develop&fileviewer=file-view-default >>> >>> >>> Look at the "replaceWith(...)"-methods. This is a class from my own >>> OpenSource project, extending the ODFToolkit with a placeholder >>> replacement functionality. In short, it replaces a placeholder with the >>> according String. Unfortunately, I didn't have the time to build a >>> sample project and contribute it to this project (sorry, Svante ;-) ). >>> But it's a point at my agenda... >>> >>> Regards, >>> Ralf. >>> >>> >>> Am 10.05.2018 um 22:34 schrieb Svante Schubert: >>>> Hello David, >>>> >>>> to reproduce your problem, I have added a test case in one of the >> existing >>>> tests of the Simple API. >>>> >>>> @Test >>>> public void testXMLasString() { >>>> try { >>>> TextDocument resDoc = (TextDocument) >>>> TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream(" >> section.odt")); >>>> Section section = resDoc.getSectionByName( "Section1" ); // >>>> this section does exist in the document >>>> >>>> // create new node form String >>>> String fragment = "<text:p text:style-name=\"P13\"><text: >> span >>>> text:style-name=\"T1\">Test</text:span></text:p>"; >>>> Node node = >>>> DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new >>>> InputSource(new StringReader(fragment ))).getDocumentElement(); >>>> node = section.getOdfElement(). >> getOwnerDocument().importNode( >>>> node, true ); >>>> // append new node into section >>>> section.getOdfElement().appendChild( node ); >>>> >>>> resDoc.save(ResourceUtilities.newTestOutputFile(" >> sectionWithText.odt")); >>>> } catch (Exception e) { >>>> Logger.getLogger(ListItemTest.class.getName()).log(Level.SEVERE, null, >> e); >>>> Assert.fail(e.getMessage()); >>>> } >>>> } >>>> >>>> It is not REALLY a test as it always succeeds, but by this, I am able to >>>> debug in the IDE and first of all get a document from your procedure. >>>> You might want to do the same. >>>> >>>> An OpenDocument File is a ZIP with XML files within. You can unzip it >> and >>>> take a look into the content.xml >>>> I usually use the JEdit editor with the "archive" and "XML" plugin to >> open >>>> the content.xml file without unpacking and make an indent for the XML. >>>> >>>> If you do so it reveals the following: >>>> <text:section text:name="Section1" text:style-name="Sect1"> >>>> <text:p text:style-name="Standard"/> >>>> <p style-name="P13"><span style-name="T1">Test</span></ >> p></text:section> >>>> >>>> The string is inserted, but the prefix, the namespace was not found. You >>>> might get the DOM element and insert the elements one by one with DOM >>>> functions or search for a solution. >>>> Uncertain how it works by String insertion. If you find a way, please >> come >>>> back and tell :) >>>> >>>> Good luck! >>>> Svante >>>> >>>> 2018-05-10 12:08 GMT+02:00 David Michal <[email protected]>: >>>> >>>>> Hi, >>>>> >>>>> I have a code: >>>>> >>>>> // ----------------------------------------------------------------- >>>>> >>>>> TextDocument resDoc = TextDocument.loadDocument( someInputStream ); >>>>> >>>>> Section section = resDoc.getSectionByName( "Section1" ); // this >> section >>>>> does exist in the document >>>>> >>>>> // create new node form String >>>>> >>>>> String fragment = "<text:p text:style-name=\"P13\"><text:span >>>>> text:style-name=\"T1\">Test</text:span></text:p>"; >>>>> >>>>> Node node = DocumentBuilderFactory.newInstance(). >> newDocumentBuilder().parse( >>>>> new InputSource( new StringReader( fragment ) ) ).getDocumentElement(); >>>>> node = section.getOdfElement().getOwnerDocument().importNode( node, >> true >>>>> ); >>>>> >>>>> // append new node into section >>>>> >>>>> section.getOdfElement().appendChild( node ); >>>>> >>>>> // ----------------------------------------------------------------- >>>>> >>>>> The code runs without a problem. But nothing does appear in the >> section in >>>>> the result document. Please any idea how can I add new nodes created >> from >>>>> string into the odf document? >>>>> >>>>> Thanks, >>>>> >>>>> David >>>>> >>>>> >>>> ᐧ >>>> >>> >> >>
signature.asc
Description: Message signed with OpenPGP
