Because Snowball Was Taken

To display base64-encoded PDF/A as well as plain text (perhaps scanned) content in a CDA clinical document that looks like:

  <component>
    <nonXMLBody>
      <text representation="B64" mediaType="application/pdf">JVBERi0x...==</text>
    </nonXMLBody>
  </component>

or

  <component>
    <nonXMLBody>
      <text representation="B64" mediaType="text/plain">JVBERi0x...==</text>
    </nonXMLBody>
  </component>

you can use the <object> tag in Chrome.

Here’s the code you would add to your cda.xsl file:

<xsl:when test='n1:text[@representation="B64"] and n1:text[@mediaType="application/pdf"]'>
  <object data='data:application/pdf;base64,{.}' type='application/pdf' width='80%' height='500px'></object>
</xsl:when>
<xsl:when test='n1:text[@representation="B64"] and n1:text[@mediaType="text/plain"]'>
 <object data='data:text/plain;base64,{.}' type='text/plain' width='80%' height='500px'></object>
</xsl:when>

For instance, in my cda.xsl file it looks like:

 <xsl:template match='n1:component/n1:nonXMLBody'>
      <xsl:choose>
 
            <xsl:when test='n1:text[@representation="B64"] and n1:text[@mediaType="application/pdf"]'>
             <object data='data:application/pdf;base64,{.}' type='application/pdf' width='80%' height='500px'></object>
         </xsl:when>
          <xsl:when test='n1:text[@representation="B64"] and n1:text[@mediaType="text/plain"]'>
              <object data='data:text/plain;base64,{.}' type='text/plain' width='80%' height='500px'></object>
           </xsl:when>
 
         <!-- if there is a reference, use that in an IFRAME -->
          <xsl:when test='n1:text/n1:reference'>
             <IFRAME name='nonXMLBody' id='nonXMLBody' WIDTH='80%' HEIGHT='66%' src='{n1:text/n1:reference/@value}'/>
           </xsl:when>
          <xsl:when test='n1:text/@mediaType="text/plain"'>
                <pre>
                    <xsl:value-of select='n1:text/text()'/>
                </pre>
           </xsl:when>
          <xsl:otherwise>
              <CENTER>Cannot display the text</CENTER>
           </xsl:otherwise>
     </xsl:choose>
    </xsl:template>

Note that to get Chrome to transform xml locally, you need to use the --allow-file-access-from-files flag.

I was unable to get this to work in FireFox and I did not try to discover the proper flag for IE.

The cda.xsl file I’m using is here.