Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FAQ - How to access a specific ODT file and to do the required manipulation. #93

Open
Muhammedismail opened this issue Jun 9, 2021 · 1 comment
Labels
documentation documentation is missing or needs to be extended

Comments

@Muhammedismail
Copy link

I have loaded an ODT file and trying to access the specific elements for the desired manipulation (editing and adding some data content)

But I am unable to get that

this is how I am trying to access the specific element: but I do have an issue with the OdfNamespace(), can anyone please give me any guide or a sample code for how to access a specific element to do the manipulation, if not this way or any other way please, basically I need to access the table content.

and I got the below from the Odf document.

OdfPackage pkg = OdfPackage.loadPackage(documentPath);
	OdfTextDocument odt = (OdfTextDocument) OdfDocument.loadDocument(documentPath);
	



	  XPath xpath = XPathFactory.newInstance().newXPath();
	  xpath.setNamespaceContext(new  OdfNamespace());
	  OdfFileDom dom = odt.getContentDom();
	  firstParagraph = (TextPElement) xpath.evaluate("//text:p[1]", dom, XPathConstants.NODE);

it would be really great if anybody can give me any hint or guidance, thanks.

@Muhammedismail Muhammedismail changed the title Need help - How to access the specific odt file and do the required manipuation. Need help - How to access a specific ODT file and to do the required manipulation. Jun 9, 2021
@svanteschubert
Copy link
Contributor

@Muhammedismail Hej, I take this as a documentation issue.
I usually start to look in existing tests to copy/paste existing code and you might want to take a look at least into the following three:

  1. https://github.com/tdf/odftoolkit/blob/master/odfdom/src/test/java/org/odftoolkit/odfdom/dom/XPathTest.java
  2. https://github.com/tdf/odftoolkit/blob/master/odfdom/src/test/java/org/odftoolkit/odfdom/doc/text/OdfParagraphTest.java
  3. https://github.com/tdf/odftoolkit/blob/master/odfdom/src/test/java/org/odftoolkit/odfdom/doc/text/OdfSpanTest.java

An easy consistent high-level API is the next big thing for the 1.0.0

@svanteschubert svanteschubert added this to the 0.10.0 milestone Jul 1, 2021
@svanteschubert svanteschubert added the documentation documentation is missing or needs to be extended label Jul 1, 2021
@svanteschubert svanteschubert changed the title Need help - How to access a specific ODT file and to do the required manipulation. Add FAQ - How to access a specific ODT file and to do the required manipulation. Nov 16, 2021
@mistmist mistmist removed this from the 0.10.0 milestone Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation documentation is missing or needs to be extended
Projects
None yet
Development

No branches or pull requests

3 participants