# Parsing Office Open (OOXML) files

**URL:** <https://the.fmsoup.org/t/parsing-office-open-ooxml-files/362>\
**Category:** Lounge (Discussions)\
**Tags:** parse, ooxml, extract, import\
**Created:** [October 7, 2019, 4:58pm UTC](https://the.fmsoup.org/t/parsing-office-open-ooxml-files/362 "2019-10-07T16:58:03Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Torsten](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/torsten/32/1574_2.png) [@Torsten](https://the.fmsoup.org/u/Torsten)\
**Post date:** [October 7, 2019, 4:58pm UTC](https://the.fmsoup.org/t/parsing-office-open-ooxml-files/362/1 "2019-10-07T16:58:03Z")

</div>

Started working on a parser for [Office Open (OOXML)](https://www.ecma-international.org/publications/standards/Ecma-376.htm). Specifically I am working on a docx import.  
The job is getting the payload (a regulatory text) extracted, shedding the entire word processor formatting informatiomation.  
The ooxml format is slightly unwieldy: the spec has some 5000 pages (plus annexes).  
Towards the end of this week I should have something to tell about taming the beast.

Has anyone worked on a similar FM/ooxml project?

---

<div class="post-metadata">

**Author:** ![steve\_ssh](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/steve_ssh/32/160_2.png) [@steve\_ssh](https://the.fmsoup.org/u/steve_ssh)\
**Post date:** [October 25, 2019, 4:22pm UTC](https://the.fmsoup.org/t/parsing-office-open-ooxml-files/362/2 "2019-10-25T16:22:55Z")

</div>

Hi Torsten,

I have a buddy who may have worked on something similar, but I am not certain.

I have pinged him with a link to this thread, so that he can take a look and see if he has anything to share.

I also kind of recall that @anon45965781 might have once posted about using a micro-service to extract text content from various document file-formats. I do not recall the details of this, however. If your endeavor involves extracting the text sans formatting, maybe there is some similarity in what @anon45965781 was doing, and the work you are doing.

Kind regards,

-steve

---

<div class="post-metadata">

**Author:** ![anon45965781](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@anon45965781](https://the.fmsoup.org/u/anon45965781)\
**Post date:** [October 25, 2019, 5:15pm UTC](https://the.fmsoup.org/t/parsing-office-open-ooxml-files/362/3 "2019-10-25T17:15:06Z")

</div>

Right. Don’t write a parser. It’s already done and free. It works with just about every binary file format.

Check out the Apache Tika library. Easy to implement in a microservice. Then just drag any binary file to container and you can extract the text content to a regular text field.

You don’t have to use container fields. That was just an FMP implementation way I use tika with my clients.

Pls write if you have any questions.

Thanks Steve for thinking of me! 😀

---

<div class="post-metadata">

**Author:** ![Torsten](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/torsten/32/1574_2.png) [@Torsten](https://the.fmsoup.org/u/Torsten)\
**Post date:** [October 27, 2019, 6:30am UTC](https://the.fmsoup.org/t/parsing-office-open-ooxml-files/362/4 "2019-10-27T06:30:05Z")

</div>

@steve_ssh, @anon45965781, thanks for the heads-up. I will look into this a I need to expand my xml toolset.

---

<div class="post-metadata">

**Author:** ![anon45965781](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@anon45965781](https://the.fmsoup.org/u/anon45965781)\
**Post date:** [October 27, 2019, 9:25am UTC](https://the.fmsoup.org/t/parsing-office-open-ooxml-files/362/5 "2019-10-27T09:25:29Z")

</div>

Glad to help. I should have also mentioned that you can run tika code standalone also.

A micro-service would be used if you wanted to directly call the tika code from FMP passing a Base64-encoded binary file of some kind, for example.

Tons of examples online.

Let me know if you have any coding questions.

Enjoy!!🤓

---

<div class="post-metadata">

**Author:** ![Torsten](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/torsten/32/1574_2.png) [@Torsten](https://the.fmsoup.org/u/Torsten)\
**Post date:** [November 10, 2019, 12:49am UTC](https://the.fmsoup.org/t/parsing-office-open-ooxml-files/362/6 "2019-11-10T00:49:40Z")

</div>

After working on 2 iterations of provided xml, I settled on two ways of extracting payload data from OOXML:

1. Jens Teich’s [‘UNIVERSAL XSLT’](https://jensteich.de/?page_id=19)
2. the [MBS plugin XML functions](https://www.mbsplugins.eu/component_XML.shtml)

Universal XSLT provides a structured import with end tags taken off. The import is used for further processing (parsing). All word processor-specific formatting information is skipped, except list information \<w:pStyle\>. OOXML covers the needs of the word processor and is not a business-specific xml. Business-specific xml can be added through injected custom xml. The custom xml section is the only part of the payload that is not ‘diluted’ by a multitude of word formatting tags. For semantic parsing this is the starting point. Content parts of the body section \<w:body\> \<w:sdtContent\> are linked to custom xml nodes through references \<w:id\>.  
After collection of information in the custom xml section, related content in the body section is parsed, skipping over all non-relevant formatting tags. The result is stored in two tables:

customxml 1 \<----\> n content

The process of parsing OOXML with injected custom xml entirely depends on the custom xml. OOXML itself is not a business xml, it is a page description language. Semantic interpretation of content in \<w:body\> also cannot be derived to 100% from custom xml. The missing semantic knowledge has to be incorporated in the parsing routine.

In addition to the above, I am using MBS xml functions for parsing specific nodes and formatted output for development.

The custom xml is work in progress and may warrant exploration of other parsers (MBS or as suggested by @steve_ssh and @anon45965781) .

The attached file shows the node list of a typical MS Word xml.[OOXML node list.txt](https://the.fmsoup.org/uploads/short-url/nYLhMSeyR6YqvbnOWPatbPOVnaN.txt) (3.2 KB)

---

<div class="post-metadata">

**Author:** ![anon45965781](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@anon45965781](https://the.fmsoup.org/u/anon45965781)\
**Post date:** [November 12, 2019, 6:56pm UTC](https://the.fmsoup.org/t/parsing-office-open-ooxml-files/362/7 "2019-11-12T18:56:59Z")

</div>

You can also use the free API by Apache (POI). That’s what I do.

---

<div class="post-metadata">

**Author:** ![Torsten](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/torsten/32/1574_2.png) [@Torsten](https://the.fmsoup.org/u/Torsten)\
**Post date:** [November 12, 2019, 7:05pm UTC](https://the.fmsoup.org/t/parsing-office-open-ooxml-files/362/8 "2019-11-12T19:05:37Z")

</div>

Did you parse a ooxml with it? Would be interested in the outcome. Ooxml has the potential of thwarting a regular parser with its formatting gibberish.

---

<div class="post-metadata">

**Author:** ![anon45965781](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@anon45965781](https://the.fmsoup.org/u/anon45965781)\
**Post date:** [November 12, 2019, 7:17pm UTC](https://the.fmsoup.org/t/parsing-office-open-ooxml-files/362/9 "2019-11-12T19:17:45Z")

</div>

Sure, that’s why you use an API like this one from Apache.

[https://poi.apache.org/apidocs/dev/org/apache/poi/ooxml/package-summary.html](https://poi.apache.org/apidocs/dev/org/apache/poi/ooxml/package-summary.html)

Lots of examples online.

–

Also, check out Tika from Apache, it will extract text from just about any binary data format – hundreds of them – all for free.

---

<div class="post-metadata">

**Author:** ![Torsten](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/torsten/32/1574_2.png) [@Torsten](https://the.fmsoup.org/u/Torsten)\
**Post date:** [November 12, 2019, 7:19pm UTC](https://the.fmsoup.org/t/parsing-office-open-ooxml-files/362/10 "2019-11-12T19:19:12Z")

</div>

Ok, see. That’s definitely interesting. Thanks!

---

<div class="post-metadata">

**Author:** ![anon45965781](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@anon45965781](https://the.fmsoup.org/u/anon45965781)\
**Post date:** [November 12, 2019, 7:40pm UTC](https://the.fmsoup.org/t/parsing-office-open-ooxml-files/362/11 "2019-11-12T19:40:22Z")

</div>

Give it a try. Post some code and I’ll try to help. 🤓

---

<div class="post-metadata">

**Author:** ![Torsten](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/torsten/32/1574_2.png) [@Torsten](https://the.fmsoup.org/u/Torsten)\
**Post date:** [November 12, 2019, 7:45pm UTC](https://the.fmsoup.org/t/parsing-office-open-ooxml-files/362/12 "2019-11-12T19:45:59Z")

</div>

Great, thanks. I think I’ll work on it in December, when things calm down…

---

<div class="post-metadata">

**Author:** ![anon45965781](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@anon45965781](https://the.fmsoup.org/u/anon45965781)\
**Post date:** [November 12, 2019, 8:05pm UTC](https://the.fmsoup.org/t/parsing-office-open-ooxml-files/362/13 "2019-11-12T20:05:17Z")

</div>

Sounds good. The offer stands. ✔
