Okapi xml and its usage

11 views
Skip to first unread message

Eric Berryman

unread,
Jun 17, 2025, 6:48:27 PMJun 17
to okapi...@googlegroups.com
Hello!

I was putting together a simple example of how to translate items in an xml document using an its file to define the translation rules.
In the end, it didn’t look very simple. So I thought I would reach out for advice on this example.


Thank you!
Eric


Chase Tingley

unread,
Jun 17, 2025, 8:02:21 PMJun 17
to Eric Berryman, okapi...@googlegroups.com
Hi Eric,

If I'm reading this correctly, you want to use custom ITS rules to extract XML into an XLIFF 2.0 file.  In that case, it looks like you're doing some extra work -- you're parsing a DOM and passing it to ITSEngine, which is basically reimplementing what net.sf.okapi.filters.its.ITSFilter does.  You can write code that
  • Instantiate an ITSFilter instance and configure it with your configuration using 
filter.getParameters().fromString(...String loaded from your params file)
  • Creates a RawDocument instance (basically a wrapper around a File) and pass it to filter.open()
  • Create a net.sf.okapi.filters.xliff2.XLIFF2FilterWriter that is writing out to a stream/file/whatever.
  • Use the ITSFilter like an iterator to get back a filtered events stream.  These can be passed directly to the handleEvent() method of your XLIFF2FilterWriter.  
This should produce an XLIFF 2.0 file for you.

It's also possible to do this in Rainbow without doing any coding at all, although if you're embedding this in another app, that probably isn't easier.  (Tikal can also do this, except that it only writes to xliff 1.2, not xliff 2.0).

ct


--
You received this message because you are subscribed to the Google Groups "okapi-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to okapi-users...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/okapi-users/CACX7odaYRZfwFvnV4WhnbsQBB0HayHYVbSknpjMPBTUzMFVOjA%40mail.gmail.com.

Eric Berryman

unread,
Jun 18, 2025, 12:39:49 PMJun 18
to Chase Tingley, okapi...@googlegroups.com
I did try your suggestion
But, I don’t see how I can merge this xliff file back into an xml original. And I don’t see where the language information can get loaded from the its langRule definition.

Maybe I’m not understanding the processes correctly.

I’ve updated my originally posted code, I found I could remove the language inspection by adding a langRule to the its file. But, as you can see, I’m adding a note to each xliff unit with the xpath, which I use to help merge the information back.

Chase Tingley

unread,
Jun 18, 2025, 2:11:26 PMJun 18
to Eric Berryman, okapi...@googlegroups.com
Hi Eric,

Just to clarify, you’re trying to extract to XLIFF, replace the translations, and then merge that XLIFF back into the source file?

Eric Berryman

unread,
Jun 18, 2025, 4:25:22 PMJun 18
to Chase Tingley, okapi...@googlegroups.com
Yes, that is correct.
Reply all
Reply to author
Forward
0 new messages