<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY amp   "&#38;">
<!ENTITY copy   "&#169;">
<!ENTITY gt   "&#62;">
<!ENTITY hellip "&#8230;">
<!ENTITY laquo  "&#171;">
<!ENTITY lsaquo   "&#8249;">
<!ENTITY lsquo   "&#8216;">
<!ENTITY lt   "&#60;">
<!ENTITY nbsp   "&#160;">
<!ENTITY quot   "&#34;">
<!ENTITY raquo  "&#187;">
<!ENTITY rsaquo   "&#8250;">
<!ENTITY rsquo   "&#8217;">
]>


<xsl:stylesheet version="3.0" 
				xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
				xmlns:xs="http://www.w3.org/2001/XMLSchema"
				xmlns:ouc="http://omniupdate.com/XSL/Variables"
				xmlns:ou="http://omniupdate.com/XSL/Variables"
				xmlns:fn="http://omniupdate.com/XSL/Functions"
				exclude-result-prefixes="ou xsl xs fn ouc">

	<xsl:import href="../../common.xsl" />

	<!-- matching the document of the props file -->
	<xsl:template match="/document">
		<html lang="en">
			<head>
				<link href="//netdna.bootstrapcdn.com/bootswatch/3.1.0/cerulean/bootstrap.min.css" rel="stylesheet"/>
				<style>
					body{
					font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
					}
					.ox-regioneditbutton {
					display: none;
					}
				</style>
			</head>
			<body id="properties">
				<div class="container" style="max-width: 800px; margin: 20px 0 0 20px;">
					<h1>Data PCF</h1>
					<p>This will publish an XML to: <xsl:value-of select="$dirname || replace($ou:filename, '\..*$', '.xml')" /></p>
					<h2>Properties</h2>
					<dl>
						<xsl:apply-templates select="descendant::parameter"/>
					</dl>
				</div>
				<div style="display:none;">
					<ouc:div label="fake" group="fake" button="hide"/>
				</div>

				<!-- EXTERNAL XML LISTING FEATURE -->
				<!-- ** ALL EXTERNAL XML NODE NAMES MUST BE UPDATED ** -->
				<xsl:variable name="internal-doc" select="ou:get-internal-doc(ou:pcf-param('aggregation-path'))" />
				<xsl:variable name="external-doc" select="ou:get-external-doc(ou:pcf-param('external-xml-url'))" />


				<div class="container" style="max-width: 800px; margin: 20px 0 0 20px;">
					<h2>Faculty members that need a profile page.</h2>
					<h4>Below is a list of faculty members in the XML that do not have a faculty detail page. If no faculty is listed all faculty members have a detail page.</h4>

					<xsl:for-each select="$external-doc/FacultyList/FacultyMember">
						<xsl:variable name="email_ext" select="lower-case(normalize-space(./Email))" />
						<xsl:variable name="first_ext" select="normalize-space(./FirstName)" />
						<xsl:variable name="last_ext" select="normalize-space(./LastName)" />
						<xsl:variable name="internal-item" select="$internal-doc/items/item[lower-case(Email) = $email_ext]" />
						<xsl:if test="not($internal-item)">
							<h6 style="color:red">
								<xsl:value-of select="$email_ext"/>
								<text> </text>
								<xsl:value-of select="$first_ext"/>
								<text> </text>
								<xsl:value-of select="$last_ext"/>
							</h6>
						</xsl:if>
					</xsl:for-each>

					<h2>Faculty members that need their profile page deleted.</h2>
					<h4>Below is a list of faculty members in the CMS that no longer exist in the XML. If no faculty is listed the XML matches the CMS.</h4>

					<xsl:for-each select="$internal-doc/items/item[type = 'External']">
						<xsl:variable name="email_int" select="normalize-space(./email)" />
						<xsl:variable name="email_ext" select="$external-doc/FacultyList/FacultyMember[lower-case(Email) = lower-case($email_int)]" />

						<xsl:if test="not($email_ext) and (./email)">
							<h6 style="color:red">
								<xsl:value-of select="./@href"/>
								<xsl:value-of select="./email"/>
							</h6>
						</xsl:if>
					</xsl:for-each>
				</div>

				<!-- EXTERNAL XML LISTING FEATURE -->
			</body>
		</html>
	</xsl:template>

	<!-- matching a parameter that is not empty -->
	<xsl:template match="parameter[.!='']">
		<xsl:apply-templates select="@section"/>
		<dt><xsl:value-of select="@prompt"/></dt>
		<dd><xsl:value-of select="."/></dd>
	</xsl:template>

	<!-- matching a parameter that is empty -->
	<xsl:template match="parameter[.='']">
		<xsl:apply-templates select="@section"/>
		<dt><xsl:value-of select="@prompt"/></dt>
		<dd>[Empty]</dd>
	</xsl:template>

	<!-- matching a parameter with an option -->
	<xsl:template match="parameter[option]">
		<xsl:apply-templates select="@section"/>
		<dt><xsl:value-of select="@prompt"/></dt>
		<dd><xsl:value-of select="option[@selected='true']"/></dd>
	</xsl:template>

	<!-- matching a parameter with a JPG image -->
	<xsl:template match="parameter[contains(.,'jpg')]">
		<xsl:apply-templates select="@section"/>
		<dt><xsl:value-of select="@prompt"/></dt>
		<dd><img style="width:50%; height:auto" src="{.}"/></dd>
	</xsl:template>

	<!-- matching section attribute of parameter -->
	<xsl:template match="@section">
		<dt><h4><xsl:value-of select="."/></h4></dt>
	</xsl:template>

</xsl:stylesheet>