Skip to content

Commit d373931

Browse files
committed
Account for image references in XSLT
1 parent c195753 commit d373931

File tree

1 file changed

+34
-28
lines changed

1 file changed

+34
-28
lines changed

airflow/dags/dailymed/template.xsl

+34-28
Original file line numberDiff line numberDiff line change
@@ -74,34 +74,40 @@
7474
<!-- PackageLabels -->
7575
<xsl:template match="//v3:section[v3:code[@code='51945-4']]">
7676
<PackageLabel> <!-- there can be multiple PRINCIPAL DISPLAY PANEL sections in a SPL -->
77-
<MediaList> <!-- there can be multiple images within a PRINCIPAL DISPLAY PANEL section -->
78-
<xsl:for-each select=".//v3:observationMedia">
79-
<Media>
80-
<ID>
81-
<xsl:value-of select="./@ID"/>
82-
</ID>
83-
<Image>
84-
<xsl:value-of select="v3:value/v3:reference/@value"/>
85-
</Image>
86-
</Media>
87-
</xsl:for-each>
88-
89-
<!-- then, handle renderMultiMedia tags by resolving their referenced observationMedia -->
90-
<xsl:for-each select=".//v3:renderMultiMedia">
91-
<xsl:variable name="refID" select="@referencedObject"/>
92-
93-
<!-- look for the corresponding observationMedia with the same ID -->
94-
<xsl:for-each select="//v3:observationMedia[@ID=$refID]">
95-
<Media>
96-
<ID>
97-
<xsl:value-of select="./@ID"/>
98-
</ID>
99-
<Image>
100-
<xsl:value-of select="v3:value/v3:reference/@value"/>
101-
</Image>
102-
</Media>
103-
</xsl:for-each>
104-
</xsl:for-each>
77+
<MediaList>
78+
<!-- If v3:observationMedia exists, process only those -->
79+
<xsl:choose>
80+
<xsl:when test=".//v3:observationMedia">
81+
<xsl:for-each select=".//v3:observationMedia">
82+
<Media>
83+
<ID>
84+
<xsl:value-of select="./@ID"/>
85+
</ID>
86+
<Image>
87+
<xsl:value-of select="v3:value/v3:reference/@value"/>
88+
</Image>
89+
</Media>
90+
</xsl:for-each>
91+
</xsl:when>
92+
<!-- Else, process v3:renderMultiMedia -->
93+
<xsl:otherwise>
94+
<xsl:for-each select=".//v3:renderMultiMedia">
95+
<xsl:variable name="refID" select="@referencedObject"/>
96+
97+
<!-- look for the corresponding observationMedia with the same ID -->
98+
<xsl:for-each select="//v3:observationMedia[@ID=$refID]">
99+
<Media>
100+
<ID>
101+
<xsl:value-of select="./@ID"/>
102+
</ID>
103+
<Image>
104+
<xsl:value-of select="v3:value/v3:reference/@value"/>
105+
</Image>
106+
</Media>
107+
</xsl:for-each>
108+
</xsl:for-each>
109+
</xsl:otherwise>
110+
</xsl:choose>
105111
</MediaList>
106112
<ID><xsl:value-of select=".//@root"/></ID>
107113
<Text><xsl:value-of select="."/></Text>

0 commit comments

Comments
 (0)