jackjop jackjop - 3 months ago 19x
Vb.net Question

How to Make an XSL Row Invisible?

We have following XSL row

<w:tr wsp:rsidR="00EC796A" wsp:rsidRPr="00E83E5E" wsp:rsidTr="00CA49A2">
<w:p wsp:rsidR="00EC796A" wsp:rsidRPr="00E83E5E" wsp:rsidRDefault="007D26AB" wsp:rsidP="00CA49A2">
<w:r wsp:rsidRPr="00E83E5E">
<xsl:text>EXPORT PRODUCTS</xsl:text>
<xsl:apply-templates select="ns0:Export_Products" />

But if Export Products is null or count is 0, I want to make this row's visibility false. How can I achieve this?
By the way the template is like following if needed:

<xsl:template match="/ns0:ReportWordData/ns0:Export_Report/ns0:Export_Products">
<xsl:for-each select="@ns0:*|@*[namespace-uri()='']">
<xsl:attribute name="{name()}" namespace="{namespace-uri()}">
<xsl:value-of select="." />
<xsl:apply-templates select="ns0:Product" />

Code behind:

Dim myXslTransform As New XslCompiledTransform(False)
myXslTransform.Transform(xmlFilePath, wordFilePath)

So making it invisible should be at runtime I think. Or there can be another solution.

Normally the word file is like this:

enter image description here

And we like these rows to not appear if they have no value.

Actually we can achieve this with changing templates but this way we have to create thousands of templates as there are many possibilities.


You can use xsl:if, e.g.

<xsl:if test="ns0:Product">
    <xsl:text>EXPORT PRODUCTS</xsl:text>