2

Apologies for the hyper-specificity of my requirements, but they are what they are ...

summary

The box I'm using runs Debian. I want to render a Clinical Document Architecture (CDA) document to PDF to send as an attachment. Chrome fails utterly, Firefox almost succeeds, and xmlto wants TeX (which has in past been a problem install on this box). Got an alternative?

details

A CDA document is basically a ziped filetree containing XML, styling, and images. In my case, the filetree is like

$ find | sort # edited for brevity and PII
.
./MachineReadable_XDMFormat
./MachineReadable_XDMFormat/HTML
./MachineReadable_XDMFormat/HTML/IMAGES
# list of PNGs omitted
./MachineReadable_XDMFormat/HTML/STYLE
./MachineReadable_XDMFormat/HTML/STYLE/colors.css
./MachineReadable_XDMFormat/HTML/STYLE/main.css
./MachineReadable_XDMFormat/IHE_XDM
./MachineReadable_XDMFormat/IHE_XDM/my_ID
./MachineReadable_XDMFormat/IHE_XDM/my_ID/DOC0001.XML   # see note#=1
./MachineReadable_XDMFormat/IHE_XDM/my_ID/METADATA.XML
./MachineReadable_XDMFormat/IHE_XDM/my_ID/STYLE.XSL
./MachineReadable_XDMFormat/INDEX.HTM                   # see note#=2
./MachineReadable_XDMFormat/README.TXT                  # see note#=3
./MachineReadable_XDMFormat/Summary.pdf                 # see note#=4

Notes:

  1. DOC0001.XML is the data payload: all other files are just decoration.
  2. INDEX.HTM is not a rendering of DOC0001.XML; it's an entirely separate page with a link to DOC0001.XML (et al) plus some explanatory text.
  3. README.TXT is not much: just the information above, plus how to unzip a file.
  4. So why doesn't Summary.pdf solve my problem? Unfortunately, this PDF contains a lot of extraneous information, because .../DOC0001.XML (which contains the actual data) contains lots items that aren't relevant to the consumer. I can edit that XML without difficulty, and even render the edited XML (see section=Firefox below), but I can't convert that edited XML into a PDF ... hence my question.

tried and failed

Chrome

I have Chrome (aka google-chrome-stable) version=60.0.3112.90 (which I believe is currently-up-to-date for Debian version=8.9, which I believe is current Debian stable). When I'm in that and do

  1. Ctrl-o
  2. give the fully-qualified path to .../MachineReadable_XDMFormat/IHE_XDM/my_ID/DOC0001.XML

Chrome does absolutely nothing: no error, but also a completely blank page/tab. Similarly if I

  1. Ctrl-o
  2. give the fully-qualified path to .../MachineReadable_XDMFormat/INDEX.HTM
  3. follow the link to DOC0001.XML

Chrome renders INDEX.HTM appropriately, but fails as previously on DOC0001.XML.

Firefox

I have Firefox version=54.0 (which I believe is currently-up-to-date for Debian version=8.9, which I believe is current Debian stable). When I'm in that and do

  1. Ctrl-o
  2. give the fully-qualified path to .../MachineReadable_XDMFormat/IHE_XDM/my_ID/DOC0001.XML

Firefox renders the the document appropriately/nicely. Hence I thought I could use the usual Firefox Print to File functionality to print this ... but it fails, since it tries to print the rather long DOC0001.XML as 4 pages:

  1. 1st has buncha short sections
  2. 2nd has just header=Results, and no other text. In the XML, this is the <section> containing all the real data (as <item>s).
  3. 3rd attempts to print all the real data. Unfortunately, there is far more data than can print on 1 page; instead of handling that case, Print to File just truncates the single page :-(
  4. 4th has some metadata, and most of the "information" from INDEX.HTM.

xmlto

xmlto (from Debian package of same name) tries, but

  1. It wants to run FO, for which it wants TeX, which is locally a problem (see section=internal below).
  2. From its error message (below), I'm not even sure xmlto will render this XML appropriately, since this (CDA) document's root ∉ {appendix article bibliography book chapter colophon dedication glossary index part preface qandaset refentry reference sect1 section set setindex}.

What I tried:

me@it:~ $ pushd /path/to/CDA/

me@it:/path/to/CDA $ ls -al
> drwxr-xr-x 4 me      me         4096 Jul 21 10:38 MachineReadable_XDMFormat
> -rw-r--r-- 1 me      me      1075851 Jul 21 13:35 Summary.pdf

me@it:/path/to/CDA $ date ; xmlto pdf ./MachineReadable_XDMFormat/IHE_XDM/my_ID/DOC0001.XML ; date
> Wed Aug  2 15:03:17 MST 2017
> xmlto: /path/to/CDA/MachineReadable_XDMFormat/IHE_XDM/my_ID/DOC0001.XML does not validate (status 3)
> xmlto: Fix document syntax or use --skip-validation option
> validity error : no DTD found!
...

me@it:/path/to/CDA $ date ; find ./ -type f | fgrep -ie 'dtd' | wcl
> Wed Aug  2 15:04:10 MST 2017
> 0

me@it:/path/to/CDA $ date ; xmlto --skip-validation pdf ./MachineReadable_XDMFormat/IHE_XDM/my_ID/DOC0001.XML ; date
> Wed Aug  2 15:04:32 MST 2017
> ERROR: Document root element for FO output must be one of the following elements: appendix article bibliography book chapter colophon dedication glossary index part preface qandaset refentry reference sect1 section set setindex
> PassiveTeX is needed for this format, but it is not installed. Please install the passivetex package.
> Wed Aug  2 15:04:33 MST 2017

# Note PassiveTeX is a *TeX package

me@it:/path/to/CDA $ date ; xmlto --with-fop --skip-validation pdf ./MachineReadable_XDMFormat/IHE_XDM/my_ID/DOC0001.XML ; date
> Wed Aug  2 15:12:39 MST 2017
> ERROR: Document root element for FO output must be one of the following elements: appendix article bibliography book chapter colophon dedication glossary index part preface qandaset refentry reference sect1 section set setindex
> [Fatal Error] :-1:-1: Premature end of file.
> Exception
> org.apache.fop.apps.FOPException: org.xml.sax.SAXParseException; Premature end of file.
> javax.xml.transform.TransformerException: org.xml.sax.SAXParseException; Premature end of file.
>
> /tmp/xmlto.SEzLdk
> Wed Aug  2 15:12:41 MST 2017

constraints

external

  1. The Big Faceless Org with the information encoded in the CDA document provides that, period. Since CDA seems to be a standard format for interchange of information in its domain, this seems not unreasonable.
  2. The folks who want the information encoded in the CDA document can consume faxes, or PDF via email, but nothing more sophisticated.
  3. I don't have ready access to a fax machine.

internal

I.e., constraints on my side:

  1. I'm running Debian version=8.9 ...
  2. ... on a box with not quite enough free disk space, or perhaps not correctly allocated disk space. Probably as a result, ...
  3. ... the last time I attempted to install texlive, (IIRC) it abended due to lack of space. This may simply be due to insufficient space allocated on my / partition, which is actually a partition for everything that is not {/boot, /home, /swap}. Details:

    # I tweak the header, but the data comes from ...
    me@it:~ $ df --human-readable | fgrep -ve 'Filesystem' | sort --key=2 --reverse --sort=human-numeric
    Filesystem                   Size  Used Avail Use% Mounted on
    /dev/mapper/LVM2_crypt-home  322G  304G   19G  95% /home
    /dev/dm-2                     20G   18G  891M  96% /
    tmpfs                        1.6G  1.3M  1.6G   1% /run/shm
    /dev/sda3                    477M   73M  375M  17% /boot
    # ... rest are fake filesystems like `/dev`
    
    # Notes on `lsblk`:
    # `sda1` == pre-installed Windows system drive
    # `sda2` == pre-installed Windows apps drive
    # Both are whackable, but I lack the time to reallocate the space
    # (and possibly reinstall after unforeseen/disastrous failure).
    
    me@it:~ $ lsblk
    NAME                  MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
    sda                     8:0    0 465.8G  0 disk
    ├─sda1                  8:1    0  16.6G  0 part
    ├─sda2                  8:2    0  97.7G  0 part
    ├─sda3                  8:3    0   500M  0 part  /boot
    └─sda5                  8:5    0   351G  0 part
      └─LVM2_crypt        254:0    0   351G  0 crypt
        ├─LVM2_crypt-swap 254:1    0   3.9G  0 lvm
        ├─LVM2_crypt-root 254:2    0    20G  0 lvm   /
        └─LVM2_crypt-home 254:3    0 327.1G  0 lvm   /home
    sr0                    11:0    1  1024M  0 rom
    
  • i was going to ask "why not just install tex?" but you really don't have enough disk space. and your /home is nearly full too so symlink kludgery wont help. can you add more disk to that machine, to extend LVM2_crypt and then LVM2_crypt-home? BTW, it's generally recommended not to let filesystems get to 95+% full - the performance of most filesystems suffer quite badly when they get that close to being full. And it's always bad if the rootfs fills up - especially when /var and /tmp are on it. – cas Aug 3 '17 at 6:08
  • if you don't use the windows partitions at all, you could add sda1 to LVM2_crypt-root and sda2 to LVM2_crypt-home (optionally resizing them first for a more optimal split, say +30G for / and the rest for /home). BTW, if there's a chance you might use them in future or need to restore the system to how it was out-of-the-box for any reason, it might be worthwhile using clonezilla to clone sda1 & sda2 to a USB stick first. – cas Aug 3 '17 at 6:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.