I have an XML structure like the following:
<Root>
<!-- ...other stuff -->
<Events>
<Event date="0000-00-00">Event Description etc...</Event>
<Event date="0000-00-00">Event Description etc...</Event>
<Event date="0000-00-00">Event Description etc...</Event>
</Events>
<!-- ...other stuff -->
</Root>
Then I have XSLT in the Stylesheet like so:
<xsl:variable name="Events" select="/Root/Events/Event" />
<xsl:template match="/">
<!-- Stuff -->
<xsl:apply-templates select="$Events" />
<!-- Stuff -->
</xsl:template>
<xsl:template match="Event">
<!-- Regular Event Template Transformation here -->
</xsl:template>
<!-- ERROR HAPPENS HERE -->
<xsl:template match="not(node())">
<p class="message">There are currently no upcoming events</p>
</xsl:template>
What I WANT to do is have two templates, one which only shows when there are no events. I KNOW i can use XSLT with <xsl:choose>
and <xsl:when>
tests to do a count of elements and just call the right template like I would do in procedural languages, but I'm trying to learn how to do this with template processing.
The error I'm getting is : Expected end of the expression, found '('. not -->(<-- node())
not(node())
is not a valid XSLT pattern, try this:
<xsl:template match="Event">
<!-- Regular Event Template Transformation here -->
</xsl:template>
<xsl:template match="Events[not(Event)]">
<p class="message">There are currently no upcoming events</p>
</xsl:template>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With