Formats

elsimpson's Avatar

elsimpson

29 Apr, 2016 05:34 PM

Hi!

I'm adapting the Faculty Profile in example.edu for our website for a job board. I'm all set except that I can't exactly get my format to show the "for each" on both part-time and full-time groups. Can you take a look and let me know what I'm doing wrong?

Thanks!

  1. 1 Posted by Ryan Griffith on 02 May, 2016 01:23 PM

    Ryan Griffith's Avatar

    Hi,

    The issue is that you are not looping over each of the full time, or part time, elements. I am guessing you only see one of each? Try the following adjustment and let me know how it works out:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
        xmlns:fo="http://www.w3.org/1999/XSL/Format">
        <xsl:template match="system-index-block">
            <xsl:apply-templates select="calling-page/system-page"/>
        </xsl:template>
        
        <xsl:template match="system-page">
            <!--<xsl:if test="system-data-structure/image/path!='/'"><img align="right" alt="{system-data-structure/image/name}" src="{system-data-structure/image/path}"/></xsl:if>-->
            <h1 style="text-align: center;">
                <xsl:value-of select="display-name"/>
            </h1>
            <br/>
            <xsl:apply-templates select="system-data-structure"/>
        </xsl:template>
        
        <xsl:template match="system-data-structure">
            <h2 style="background-color:#e6e6e6;">Full-Time Positions</h2>
            <xsl:apply-templates select="full-time"/>
            <br/>
            <hr/>
            <br/>
            <h2 style="background-color:#e6e6e6;">Part-Time Positions</h2>
            <xsl:apply-templates select="part-time"/>
            <br/>
            <hr/>
            <!-- <p><b>Education:</b><br/><xsl:for-each select="education/degree"><xsl:value-of select="."/><br/></xsl:for-each></p><xsl:if test="research/topic!=''"><p><b>Research:</b><br/><xsl:for-each select="research/topic"><xsl:value-of select="."/><br/></xsl:for-each></p></xsl:if><xsl:if test="publications!=''"><p><b>Publications:</b><br/><i><xsl:value-of select="publications"/></i></p></xsl:if><xsl:if test="affiliations!=''"><p><b>Affiliations:</b><br/><xsl:value-of select="affiliations"/></p></xsl:if><xsl:if test="awards!=''"><p><b>Awards:</b><br/><xsl:value-of select="awards"/></p></xsl:if><br/><xsl:copy-of select="biography/node()"/>-->
        </xsl:template>
    
        <xsl:template match="full-time">
          <p>
              <xsl:if test="title != ''">
                  <b>Job Title:</b>&#160;
                  <xsl:value-of select="title"/>
              </xsl:if>
          </p>
          <p>
              <xsl:if test="company != ''">
                  <b>Company:</b>&#160;
                  <xsl:value-of select="company"/>
              </xsl:if>
          </p>
          <p>
              <xsl:if test="job-desc != ''">
                  <b>Job Description:</b>&#160;
                  <xsl:value-of select="job-desc"/>
              </xsl:if>
          </p>
          <p>
              <xsl:if test="attach/path != '/'">
                  <b>Document/Flier:</b>&#160;
                  <a href="{attach/path}">
                      <xsl:value-of select="attach/path"/>
                  </a>
              </xsl:if>
          </p>
          <br/>
          <br/>
          <h3>Employer Contact:</h3>
          <br/>
          <p>
              <xsl:if test="contact/name != ''">
                  <b>Name:</b>&#160;
                  <xsl:value-of select="contact/name"/>
                  <br/>
              </xsl:if>
              <xsl:if test="contact/phone != ''">
                  <b>Phone:</b>&#160;
                  <xsl:value-of select="contact/phone"/>
                  <br/>
              </xsl:if>
              <xsl:if test="contact/email != ''">
                  <b>Email:</b>&#160;
                  <a href="mailto:{contact/email}">
                      <xsl:value-of select="contact/email"/>
                  </a>
                  <br/>
              </xsl:if>
              <xsl:if test="contact/website != ''">
                  <b>Website:</b>&#160;
                  <a href="{contact/website}">
                      <xsl:value-of select="contact/website"/>
                  </a>
              </xsl:if>
          </p>
        </xsl:template>
    
        <xsl:template match="part-time">
          <p>
              <xsl:if test="ptitle != ''">
                  <b>Job Title:</b>&#160;
                  <xsl:value-of select="ptitle"/>
              </xsl:if>
          </p>
          <p>
              <xsl:if test="pcompany!=''">
                  <b>Company:</b>&#160;
                  <xsl:value-of select="pcompany"/>
              </xsl:if>
          </p>
          <p>
              <xsl:if test="pjob-desc != ''">
                  <b>Job Description:</b>&#160;
                  <xsl:value-of select="pjob-desc"/>
              </xsl:if>
          </p>
          <p>
              <xsl:if test="pattachment/path != '/'">
                  <b>Document/Flier:</b>&#160;
                  <a href="{pattachment/path}">
                      <xsl:value-of select="pattachment/path"/>
                  </a>
              </xsl:if>
          </p>
          <br/>
          <br/>
          <h3>Employer Contact:</h3>
          <br/>
          <p>
              <xsl:if test="pcontact/pname != ''">
                  <b>Name:</b>&#160;
                  <xsl:value-of select="pcontact/pname"/>
                  <br/>
              </xsl:if>
              <xsl:if test="pcontact/pphone != ''">
                  <b>Phone:</b>&#160;
                  <xsl:value-of select="pcontact/pphone"/>
                  <br/>
              </xsl:if>
              <xsl:if test="pcontact/pemail != ''">
                  <b>Email:</b>&#160;
                  <a href="mailto:{pcontact/pemail}">
                      <xsl:value-of select="pcontact/pemail"/>
                  </a>
                  <br/>
              </xsl:if>
              <xsl:if test="pcontact/pwebsite != ''">
                  <b>Website:</b>&#160;
                  <a href="{pcontact/pwebsite}">
                      <xsl:value-of select="pcontact/pwebsite"/>
                  </a>
              </xsl:if>
          </p>
        </xsl:template>
    </xsl:stylesheet>
    

    Also, you may want to move those <xsl:if> tests outside of the <p> tags so you are not outputting empty paragraphs every time an empty field is encountered.

    Please let me know if you have any questions.

    Thanks!

  2. 2 Posted by elsimpson on 02 May, 2016 04:31 PM

    elsimpson's Avatar

    Perfect Ryan! Thank you so much for the help!

    Erin Simpson
    Coordinator of Web Authoring Services
    Pellissippi State Community College
    865-694-6671

  3. 3 Posted by Ryan Griffith on 02 May, 2016 05:28 PM

    Ryan Griffith's Avatar

    Not a problem at all, Eric. I am glad to hear the proposed format did the trick.

    I'm going to go ahead and close this discussion, please feel free to comment or reply to re-open if you have any additional questions.

    Have a great day!

  4. Ryan Griffith closed this discussion on 02 May, 2016 05:28 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac