I want to conditionally format URL's in Apache FOP, for this, I want to check if the property
is of type HYPERLINK
then apply conditional formatting and convert it into an URL.
Below is my XML
<properties>
<property type="CUSTOM" id="150" key="localizedfield">
<name>Localized Text</name>
<value>Test</value>
</property>
<property type="CUSTOM" id="149" key="textareafield">
<name>Textarea</name>
<value>My longer default text.</value>
</property>
<property type="HYPERLINK" key="ASSET_LINK">
<name>Asset Link</name>
<value>Test=https://test.com</value>
</property>
<property type="CUSTOM" key="VALIDITY">
<name>Asset Availability</name>
<value>Available</value>
</property>
</properties>
The XSL which I am using for transformation looks something like below
<xsl:template name="table-row">
<xsl:for-each select="properties/property">
<xsl:apply-templates select="."/>
</xsl:for-each>
</xsl:template>
<xsl:template match="property">
<fo:table-cell >
<fo:block >
<xsl:choose>
<xsl:when test="<check if type is HYPERLINK>">
<!-- Format as hyperlink -->
</xsl:when>
<xsl:otherwise>
<!-- format as normal text -->
</xsl:otherwise>
</xsl:choose>
</fo:block>
</fo:table-cell>
</xsl:template>
in the xsl:when
condition I only get the name
and value
, how can I get the complete property
node here so I can check if the type attribute is HYPERLINK
and then format accordingly?
I think you want
<xsl:when test="@type='HYPERLINK'">