How can I modify .xfdl files? (Update #1)

2020-08-09 09:42发布

问题:

The .XFDL file extension identifies XFDL Formatted Document files. These belong to the XML-based document and template formatting standard. This format is exactly like the XML file format however, contains a level of encryption for use in secure communications.

I know how to view XFDL files using a file viewer I found here. I can also modify and save these files by doing File:Save/Save As. I'd like, however, to modify these files on the fly. Any suggestions? Is this even possible?

Update #1: I have now successfully decoded and unziped a .xfdl into an XML file which I can then edit. Now, I am looking for a way to re-encode the modified XML file back into base64-gzip (using Ruby or the command line)

回答1:

If the encoding is base64 then this is the solution I've stumbled upon on the web:

"Decoding XDFL files saved with 'encoding=base64'. Files saved with:

application/vnd.xfdl;content-encoding="base64-gzip"

are simple base64-encoded gzip files. They can be easily restored to XML by first decoding and then unzipping them. This can be done as follows on Ubuntu:

sudo apt-get install uudeview
uudeview -i yourform.xfdl
gunzip -S "" < UNKNOWN.001 > yourform-unpacked.xfdl 

The first command will install uudeview, a package that can decode base64, among others. You can skip this step once it is installed.

Assuming your form is saved as 'yourform.xfdl', the uudeview command will decode the contents as 'UNKNOWN.001', since the xfdl file doesn't contain a file name. The '-i' option makes uudeview uninteractive, remove that option for more control.

The last command gunzips the decoded file into a file named 'yourform-unpacked.xfdl'.

Another possible solution - here

Side Note: Block quoted < code > doesn't work for long strings of code



回答2:

The only answer I can think of right now is - read the manual for uudeview.

As much as I would like to help you, I am not an expert in this area, so you'll have to wait for someone more knowledgable to come down here and help you.

Meanwhile I can give you links to some documents that might help you:

  • UUDeview Home Page
  • Using XDFLengine
  • Gettting started with the XDFL Engine

Sorry if this doesn't help you.



回答3:

You don't have to get out of Ruby to do this, can use the Base64 module in Ruby to encode the document like this:

irb(main):005:0> require 'base64'
=> true

irb(main):007:0> Base64.encode64("Hello World")
=> "SGVsbG8gV29ybGQ=\n"

irb(main):008:0> Base64.decode64("SGVsbG8gV29ybGQ=\n")
=> "Hello World"

And you can call gzip/gunzip using Kernel#system:

system("gzip foo.something")
system("gunzip foo.something.gz")