Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsForm and ListForm and Listxsl:ifxsl:if
Previous
 
Next
New Post
3/24/2008 5:02 PM
 
xsl:if 

I'm working on a custom XSLT and have hit a snag.  I have a Title column but want to completely hide the title (and line break) when a record has no Title.

 Here's a code snippet:

  <xsl:template match="udt:Data" mode="list">
    <div class="normal">
      <xsl:call-template name="EditLink" />
      <b>
        <xsl:value-of select="udt:Name" disable-output-escaping="yes" />
      </b>
      <br />
      <xsl:if test="@udt:Title">
        <xsl:value-of select="udt:Title" disable-output-escaping="yes" />
        <br />
      </xsl:if>
    </div>
    <br />
  </xsl:template>

The problem I'm having is that it'd completely hiding the Title, whether or not there's a value for Title.  I'm guessing it's probably going to be something real simple.

 
New Post
3/25/2008 2:38 PM
 

Hi Mike,

I have zero experience working with the source UDT XML, but you do have one suspicious issue with your transform: you are looking for the title as an attribute and not an element (you reference Data and Name as an element).  Is it possible that you have an erroneous @ on your xsl:if clause, and it should instead read ... xsl:if test="udt:Title"...?

Brandon


Brandon Haynes
BrandonHaynes.org
 
New Post
3/27/2008 3:57 PM
 

I finally got it working.  I had to use test="udt:Field!='  ' "  (spacing added between quotes to clarify this on the forums...no spacing between the single quotes).

 

  <xsl:template match="udt:Data" mode="list">
    <div class="normal">
      <xsl:call-template name="EditLink" />
      <b>
        <xsl:value-of select="udt:Name" disable-output-escaping="yes" />
      </b>
      <br />
      <xsl:if test="udt:Title!=''">
        <xsl:value-of select="udt:Title" disable-output-escaping="yes" />
        <br />
      </xsl:if>

      <xsl:if test="udt:Fax!=''">
        Fax: <xsl:value-of select="udt:Fax" disable-output-escaping="yes" />
        <br />
      </xsl:if>
    </div>
    <br />
  </xsl:template>

 
New Post
3/27/2008 6:57 PM
 

Yeah, that was going to be my second suggestion.  Existance of an element (test="element") is different than testing if an element is equal to the empty string (test="element = ''").  Glad you got it working!


Brandon Haynes
BrandonHaynes.org
 
New Post
3/28/2008 3:00 PM
 

I was just the syntax for "not equals" that was causing the problem.  I'm surprised that syntax isn't listed on more sites/examples of xsl:if.

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsForm and ListForm and Listxsl:ifxsl:if


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out