lundi 5 juillet 2021

XSL template, show table column if at least one value in node has an entry

I haven XSL template, and depending on the content of the data, I call a different template to draw my table.

What I would like to achieve is that before calling the template, I check all child nodes to see if there is a value for a specific node. If there is, then I would like to draw an additional column in my table to display this. If there is not, then I do not want to draw this column.

I am stuck on the methodology, as initially I started with:

<xsl:for-each select="element"> 
    <xsl:if test=". != null">
        <xsl:variable name="showColumn" select="'TRUE'">
    </xsl:if>
</xsl:for-each>

However I then realised that variables are constant values, and cannot be redefined. I am now stuck on how to implement this. Also, doing this with a parameter, it would get overwritten for each call in 'for-each'. I was initially going to do this, and then afterwards simply test if the value is true, to call one template, if false to call another.

Looking into parameters, my understanding is that I can declare a default value, or this can be overwritten at runtime with the value of a node, but I cannot update this myself.

Again, the goal is to just check if at least one value exists for element.

Aucun commentaire:

Enregistrer un commentaire