html - XSL Displaying a message to the user if an element's count is 0 -
I have a channel that has value in XML files. What I want to do is that when there is no channel in the XML file, display the message to the user. Here is my code
& lt; H2 & gt; Channel Subscription: & lt; / H2 & gt; & Lt; XSL: Templates & gt; & Lt; Xsl: if test = "& lt; xsl: select value =" count (subscription / channel) "/> == 0)" & gt; & Lt; P & gt; You have no channels & lt; / P & gt; & Lt; / XSL: If & gt; & Lt; / XSL: Templates & gt; The above code does not work, then the second part is in the table. When a user has a channel or above it is displayed & lt; Xsl: each selection = "subscription / channel" & gt; & Lt; XSL: Select & gt; & Lt; Xsl: when test = "@ favorites = 'true'" & gt; & Lt; H3 & gt; Channel name: & lt; / H3 & gt; & Lt; H3 style = "color: green;" & Gt; & Lt; Xsl: Select the value = "@ name" /> & Lt; / H3 & gt; & Lt; / XSL: When & gt; & Lt; XSL: otherwise & gt; & Lt; H3 & gt; Channel name: & lt; / H3 & gt; & Lt; H3 style = "color: black;" & Gt; & Lt; Xsl: Select the value = "@ name" /> gt; & Lt; / H3 & gt; & Lt; / XSL: otherwise & gt; & Lt; / XSL: Select & gt; & Lt; P & gt; ID: & lt; Xsl: select value = "@ id" /> & Lt; / P & gt; & Lt; H3 & gt; Events: & lt; / H3 & gt; & Lt; Xsl: each selection = "program" & gt; & Lt; Table id = "shield-style" & gt; & Lt; Tbody & gt; & Lt; TR & gt; & Lt; Th & gt; Program name: & lt; / Th & gt; & Lt; Td> & Lt; Xsl: Select the value = "name" /> gt; & Lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; Th & gt; Broadcast time: & lt; / Th & gt; & Lt; TD & gt; & Lt; Xsl: Select Value = "@ broadcast frequency" /> On & lt; Xsl: Select Value = "@ Broadcast Time" /> & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; Th & gt; Details: & lt; / Th & gt; & Lt; Td> & Lt; Xsl: value selection = "description" /> & Lt; / Td> & Lt; / TR & gt; & Lt; / Tbody & gt; & Lt; / Table & gt; & Lt; / XSL: for-each & gt;
And it works
Your xsl : If
is incorrect, should be
& lt; Xsl: if test = "count (membership / channel) = 0" & gt; & Lt; P & gt; You have no channels & lt; / P & gt; & Lt; / XSL: If & gt;
For reference:
Comments
Post a Comment