user736893
user736893

Reputation:

Embedding complex XSL into complex XML (CDA)

I'm trying to embed this XSL into a CDA Document. This particular document begins something like this:

<?xml version="1.0" encoding="UTF-8"?>
<ClinicalDocument xmlns="urn:hl7-org:v3">
    <realmCode code="US"/>
    <typeId .../>
    ...
    <recordTarget>
        <patientRole>
        ...

Based on this SO question I have tried a couple things, including pasting the XSL within the <ClinicalDocument> element and creating a new root element that contained both the <ClinicalDocument> and the <xsl:stylesheet>. Neither of these worked. From doing some research it looks like I need to modify the XSL to exclude itself perhaps? I haven't had any luck doing this, or modifying the XSL at all as I'm not that familiar with the technology and it's test patterns.

Update Martin's answer is working in Chrome but I'm getting this in IE:

enter image description here

Upvotes: 0

Views: 853

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167516

If you want to embed an xsl:stylesheet and reference it using <?xml-stylesheet type="text/xsl" href="#sheetId"?> then you need

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="#mySheet"?>
<!DOCTYPE ClinicalDocument [
<!ATTLIST xsl:stylesheet
  id    ID  #REQUIRED>
]>
<ClinicalDocument xmlns="urn:hl7-org:v3">
    <xsl:stylesheet id="mySheet" ...>...</xsl:stylesheet>
    <realmCode code="US"/>
    <typeId .../>
    ...
    <recordTarget>
        <patientRole>
    ...
</ClinicalDocument>

The stylesheet is too long for me to check all code but at least the first templates don't make use of any generic path like * which could result in processing the stylesheet elements themselves so the above might suffice.

Upvotes: 1

Related Questions