<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: element_dictionary.xsl 4150 2007-06-22 17:29:18Z abuttner $ -->
<!--
	****************************************************************************************
	Copyright (c) 2002-2007, The MITRE Corporation
	All rights reserved.
	
	Redistribution and use in source and binary forms, with or without modification, are
	permitted provided that the following conditions are met:
	
	* Redistributions of source code must retain the above copyright notice, this list
	of conditions and the following disclaimer.
	* Redistributions in binary form must reproduce the above copyright notice, this 
	list of conditions and the following disclaimer in the documentation and/or other
	materials provided with the distribution.
	* Neither the name of The MITRE Corporation nor the names of its contributors may be
	used to endorse or promote products derived from this software without specific 
	prior written permission.
	
	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
	EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
	OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
	SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
	OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
	TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
	EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
	
	****************************************************************************************
	
	This stylesheet was originally developed by The MITRE Corporation.
	It has been designed to generate documenation about the elements
	and types by looking at the annotation elements found in the OVAL
	Schema. It is maintained by The Mitre Corporation and developed
	for use by the public OVAL Community.  For more information,
	including how to get involved in the project, please visit the
	OVAL website at http://oval.mitre.org.
-->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

	<xsl:output method="html"/>

	<xsl:variable name="root_element_name" select="xsd:schema/xsd:element[position()=1]/@name"/>
     <xsl:variable name="target_namespace_prefix">oval</xsl:variable>

	<xsl:template match="xsd:schema">
		<html>
		<head>
			<title></title>
		</head>
		<body bgcolor="#ffffff">

		<xsl:for-each select="xsd:annotation">
			<h1 align="center">- Open Vulnerability and Assessment Language -<br/>Element Dictionary</h1>
			<ul>
			<li>Schema: <xsl:value-of select="xsd:appinfo/schema"/></li>
			<li>Version: <xsl:value-of select="xsd:appinfo/version"/></li>
			<li>Release Date: <xsl:value-of select="xsd:appinfo/date"/></li>
			</ul>
			<xsl:for-each select="xsd:documentation">
				<p align="justify"><xsl:value-of select="."/></p>
			</xsl:for-each>
		</xsl:for-each>

		<xsl:for-each select="xsd:element|xsd:complexType|xsd:simpleType|xsd:group|xsd:attributeGroup">
			<xsl:if test="@name=$root_element_name or

			              @name='GeneratorType' or
					      @name='CheckEnumeration' or
					      @name='DefinitionIDPattern' or
					      @name='EmptyStringType' or

					      @name='DefinitionsType' or
					      @name='TestsType' or
					      @name='ObjectsType' or
					      @name='StatesType' or
					      @name='VariablesType' or
					      @name='ActionEnumeration' or
					      @name='EntityBaseType' or

			              @name='SystemInfoType' or
			              @name='CollectedObjectsType' or
			              @name='SystemDataType' or
					      @name='FlagEnumeration' or
					      @name='EntityBaseType' or

			              @name='DirectivesType' or
					      @name='ResultsType' or
					      @name='ContentEnumeration' or

					      contains(@name, '_test') or
					      @name='EntityStateFamilyType' or
					      @name='EntityStateTrainIdentifierType' or
					      @name='EntityStateEndpointType' or
					      @name='EntityStateAddrTypeType' or
					      
					      contains(@name, '_item') or
					      @name='EntityItemFamilyType' or
					      @name='EntityItemTrainIdentifierType' or
					      @name='EntityItemEndpointType' or
					      @name='EntityItemAddrTypeType'
						  ">
				<hr noshade="true" size="5" width="100%"/>
				<hr noshade="true" size="5" width="100%"/>
			</xsl:if>
			<xsl:choose>
				<xsl:when test="name()='xsd:element'"><xsl:call-template name="global_element"/></xsl:when>
				<xsl:when test="name()='xsd:complexType'"><xsl:call-template name="global_complex_type"/></xsl:when>
				<xsl:when test="name()='xsd:simpleType'"><xsl:call-template name="global_simple_type"/></xsl:when>
				<xsl:when test="name()='xsd:group'"><xsl:call-template name="global_element_group"/></xsl:when>
				<xsl:when test="name()='xsd:attributeGroup'"><xsl:call-template name="global_attribute_group"/></xsl:when>
			</xsl:choose>
		</xsl:for-each>

		</body>
		</html>
	</xsl:template>
	<xsl:template name="global_element">
		<h3><xsl:text disable-output-escaping="yes">&lt;a name="</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">"/&gt;</xsl:text>&lt; <xsl:value-of select="@name"/> &gt;</h3>
		<xsl:call-template name="annotation"/>
		<xsl:if test="xsd:complexType/xsd:attribute">
			<xsl:call-template name="attributes"/>
		</xsl:if>
		<xsl:choose>
			<xsl:when test="xsd:complexType/xsd:complexContent/xsd:extension/xsd:sequence/xsd:choice/xsd:sequence/*"><xsl:call-template name="children"/></xsl:when>
			<xsl:when test="xsd:complexType/xsd:complexContent/xsd:extension/xsd:sequence/*"><xsl:call-template name="children"/></xsl:when>
			<xsl:when test="xsd:complexType/xsd:choice/xsd:sequence/*"><xsl:call-template name="children"/></xsl:when>
			<xsl:when test="xsd:complexType/xsd:sequence/*"><xsl:call-template name="children"/></xsl:when>
		</xsl:choose>
	     <xsl:if test="xsd:annotation/xsd:appinfo/evaluation_documentation">
	          <p align="justify"><xsl:value-of select="xsd:annotation/xsd:appinfo/evaluation_documentation"/></p>
	          <xsl:for-each select="xsd:annotation/xsd:appinfo/evaluation_chart">
	               <xsl:call-template name="evaluation_chart"/>
	          </xsl:for-each>
	     </xsl:if>
	     <br/>
	</xsl:template>
	<xsl:template name="global_complex_type">
		<h3><xsl:text disable-output-escaping="yes">&lt;a name="</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">"/&gt;</xsl:text>== <xsl:value-of select="@name"/> ==</h3>
		<xsl:call-template name="annotation"/>
		<xsl:if test="xsd:attribute">
			<xsl:call-template name="attributes"/>
		</xsl:if>
		<xsl:if test="xsd:sequence/*|xsd:choice/*">
			<xsl:call-template name="children"/>
		</xsl:if>
		<xsl:if test="xsd:simpleContent">
			<xsl:call-template name="simpleContent"/>
		</xsl:if>
	     <xsl:if test="xsd:annotation/xsd:appinfo/evaluation_documentation">
	          <p align="justify"><xsl:value-of select="xsd:annotation/xsd:appinfo/evaluation_documentation"/></p>
	          <xsl:for-each select="xsd:annotation/xsd:appinfo/evaluation_chart">
	               <xsl:call-template name="evaluation_chart"/>
	          </xsl:for-each>
	     </xsl:if>
	     
		<br/>
	</xsl:template>
	<xsl:template name="global_simple_type">
		<h3>-- <xsl:value-of select="@name"/> --</h3>
		<xsl:call-template name="annotation"/>
		
		<xsl:if test="xsd:restriction/xsd:pattern">
			<xsl:call-template name="pattern"/>
		</xsl:if>
		<xsl:if test="xsd:restriction/xsd:enumeration">
			<xsl:call-template name="enumeration"/>
		</xsl:if>

		<xsl:if test="xsd:annotation/xsd:appinfo/evaluation_documentation">
			<p align="justify"><xsl:value-of select="xsd:annotation/xsd:appinfo/evaluation_documentation"/></p>
			<xsl:for-each select="xsd:annotation/xsd:appinfo/evaluation_chart">
				<xsl:call-template name="evaluation_chart"/>
			</xsl:for-each>
		</xsl:if>

		<br/>
	</xsl:template>
	<xsl:template name="global_element_group">		
		<h3><xsl:text disable-output-escaping="yes">&lt;a name="</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">"/&gt;</xsl:text>-- <xsl:value-of select="@name"/> --</h3>
		<xsl:call-template name="annotation"/>
		<xsl:if test="xsd:choice/*">
			<xsl:call-template name="children"/>
		</xsl:if>
		<br/>
	</xsl:template>
	<xsl:template name="global_attribute_group">
		<h3>-- <xsl:value-of select="@name"/> --</h3>
		<xsl:call-template name="annotation"/>
		
		<xsl:if test="xsd:attribute">
			<xsl:call-template name="attributes"/>
		</xsl:if>

		<br/>
	</xsl:template>
	<xsl:template name="annotation">
		<xsl:for-each select="xsd:annotation">
			<xsl:for-each select="xsd:documentation">
				<p align="justify"><xsl:value-of select="."/></p>
			</xsl:for-each>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="attributes">
		<blockquote>
		<table bgcolor="#FFFFFF" border="0" cellpadding="0" cellspacing="0">
			<colgroup span="6">
				<col width="30"/>
				<col width="*"/>
				<col width="30"/>
				<col width="*"/>
				<col width="30"/>
				<col width="*"/>
			</colgroup>
			<tr>
				<td colspan="6"><b>Attributes:</b></td>
			</tr>
			<tr>
				<td colspan="6"><hr/></td>
			</tr>

			<xsl:for-each select="xsd:attribute|
			                      xsd:complexType/xsd:attribute">
			<tr>
				<td align="center" width="30">-</td>
				<td><xsl:value-of select="@name"/></td>
				<td width="30"></td>
				<td>
					<xsl:choose>
						<xsl:when test="not(@type)">n/a</xsl:when>
						<xsl:when test="substring-before(@type,':')=$target_namespace_prefix">
							<xsl:text disable-output-escaping="yes">&lt;a href="#</xsl:text>
							<xsl:value-of select="substring-after(@type,':')"/>
							<xsl:text disable-output-escaping="yes">"&gt;</xsl:text>
							<xsl:value-of select="@type"/>
							<xsl:text disable-output-escaping="yes">&lt;/a&gt;</xsl:text>
						</xsl:when>
						<xsl:otherwise><xsl:value-of select="@type"/></xsl:otherwise>
					</xsl:choose>
				</td>
				<td width="30"></td>
				<td><xsl:if test="@use"><font size="-1">(<xsl:value-of select="@use"/><xsl:if test="@default"> -- default='<xsl:value-of select="@default"/>'</xsl:if>)</font></xsl:if></td>
			</tr>
			</xsl:for-each>
			
		</table>
		</blockquote>
	</xsl:template>
	<xsl:template name="children">
		<blockquote>
		<table bgcolor="#F9F9F9" border="1" cellpadding="5" cellspacing="0" style="table-layout:fixed" width="88%">
			<colgroup span="4">
				<col width="200"/>
				<col width="*"/>
				<col width="80"/>
				<col width="80"/>
			</colgroup>
			<tr bgcolor="#F0F0F0">
				<td><b>Child Elements</b></td>
				<td><b>Type</b></td>
				<td align="center"><b><font size="-1">MinOccurs</font></b></td>
				<td align="center"><b><font size="-1">MaxOccurs</font></b></td>
			</tr>
				
			<xsl:for-each select="xsd:complexType/xsd:complexContent/xsd:extension/xsd:sequence/xsd:choice/xsd:sequence/*|
			                      xsd:complexType/xsd:complexContent/xsd:extension/xsd:sequence/*|
			                      xsd:complexType/xsd:choice/xsd:sequence/*|
			                      xsd:complexType/xsd:sequence/*|
			                      xsd:choice/*|
			                      xsd:sequence/*">
				<xsl:if test="@name|@ref[.!='oval-def:set']">
					<tr>
						<td>
							<font size="-1">
							<xsl:choose>
								<xsl:when test="@ref">
									<xsl:choose>
										<xsl:when test="substring-before(@ref,':')=$target_namespace_prefix">
											<xsl:text disable-output-escaping="yes">&lt;a href="#</xsl:text>
											<xsl:value-of select="substring-after(@ref,':')"/>
											<xsl:text disable-output-escaping="yes">"&gt;</xsl:text>
											<xsl:value-of select="@ref"/>
											<xsl:text disable-output-escaping="yes">&lt;/a&gt;</xsl:text>
										</xsl:when>
										<xsl:otherwise><xsl:value-of select="@ref"/></xsl:otherwise>
									</xsl:choose>
								</xsl:when>
								<xsl:when test="@name"><xsl:value-of select="@name"/></xsl:when>
								<xsl:when test="name()='xsd:any'">xsd:any</xsl:when>
							</xsl:choose>
							</font>
						</td>
						<td>
							<font size="-1">
								<xsl:choose>
									<xsl:when test="not(@type)">n/a</xsl:when>
									<xsl:when test="substring-before(@type,':')=$target_namespace_prefix">
										<xsl:text disable-output-escaping="yes">&lt;a href="#</xsl:text>
										<xsl:value-of select="substring-after(@type,':')"/>
										<xsl:text disable-output-escaping="yes">"&gt;</xsl:text>
										<xsl:value-of select="@type"/>
										<xsl:text disable-output-escaping="yes">&lt;/a&gt;</xsl:text>
									</xsl:when>
									<xsl:otherwise><xsl:value-of select="@type"/></xsl:otherwise>
								</xsl:choose>
							</font>
						</td>
						<td align="center"><font size="-1"><xsl:value-of select="@minOccurs"/></font></td>
						<td align="center"><font size="-1"><xsl:value-of select="@maxOccurs"/></font></td>
					</tr>
				</xsl:if>
			</xsl:for-each>

		</table>
		</blockquote>
	</xsl:template>
	<xsl:template name="simpleContent">
		<xsl:for-each select="xsd:simpleContent/xsd:extension">
			<xsl:call-template name="attributes"/>
		</xsl:for-each>
		<xsl:if test="xsd:simpleContent/xsd:extension/@base">
		<blockquote>
		<table border="3" cellpadding="5" cellspacing="0" style="table-layout:fixed" width="88%">
			<colgroup span="2">
				<col width="200"/>
				<col width="*"/>
			</colgroup>
			<tr bgcolor="#FAFAFA">
				<td><b>Simple Content</b></td>
				<td><xsl:value-of select="xsd:simpleContent/xsd:extension/@base"/></td>
			</tr>
		</table>
		</blockquote>
		</xsl:if>
		<xsl:if test="xsd:simpleContent/xsd:restriction/xsd:enumeration">
			<xsl:for-each select="xsd:simpleContent">
				<xsl:call-template name="enumeration"/>
			</xsl:for-each>
		</xsl:if>
	</xsl:template>
	<xsl:template name="pattern">
		<blockquote>
			<xsl:value-of select="xsd:restriction/xsd:pattern/@value"/>
		</blockquote>
	</xsl:template>
	<xsl:template name="enumeration">
		<blockquote>
		<table bgcolor="#F9F9F9" border="1" cellpadding="5" cellspacing="0" style="table-layout:fixed" width="88%">
			<colgroup span="2">
				<col width="250"/>
				<col width="*"/>
			</colgroup>
			<tr bgcolor="#F0F0F0">
				<td><b>Value</b></td>
				<td><b>Description</b></td>
			</tr>
			
			<xsl:for-each select="xsd:restriction/xsd:enumeration">
			<tr>
				<td valign="top"><xsl:value-of select="@value"/></td>
				<td>
					<xsl:for-each select="xsd:annotation/xsd:documentation">
						<p align="justify"><xsl:value-of select="."/></p>
					</xsl:for-each>
				</td>
			</tr>
			</xsl:for-each>
			
		</table>
		</blockquote>
	</xsl:template>

	<xsl:template name="evaluation_chart">
		<blockquote>
		<table align="center" bgcolor="#FCFCFC" border="5" cellpadding="5" cellspacing="0">
		<tr>
			<td><br/><pre><xsl:value-of select="."/></pre></td>
		</tr>
		</table>
		</blockquote>
	</xsl:template>

</xsl:stylesheet>

