<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2000/svg" exclude-result-prefixes="h xsd">
	<xsl:output encoding="UTF-8" indent="yes" doctype-public="-//W3C//DTD SVG 1.1 Basic//EN" doctype-system="http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd"/>
	<!-- This XSLT will produce an SVG interpretation of a major element within an XML Schema (XSD) -->

	<xsl:param name="Index" select="14"/>
	<xsl:param name="Name" select="''"/>
	<xsl:param name="DateTimeStamp" select="''"/>

	<xsl:template match="/">
		<xsl:apply-templates select="/xsd:schema/*[@name][$Index]" mode="base"/>
	</xsl:template>

	<xsl:template match="*" mode="base">
		<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1000%" height="1000%" overflow="scroll">
			<title><xsl:value-of select="@name"/></title>
			<desc>
				<xsl:choose>
					<xsl:when test="xsd:annotation/xsd:documentation"><xsl:value-of select="xsd:annotation/xsd:documentation"/></xsl:when>
					<xsl:otherwise><xsl:value-of select="comment()"/></xsl:otherwise>
				</xsl:choose>
			</desc>
			<defs>
				<filter id="Shadow" filterUnits="userSpaceOnUse" x="0" y="0" width="100%" height="100%">
					<feGaussianBlur in="SourceAlpha" stdDeviation="4" result="blur"/>
					<feOffset in="blur" dx="4" dy="4" result="offsetBlur"/>
					<feComposite in="SourceGraphic" in2="offsetBlur" operator="over"/>
				</filter>
				<path id="collapsedLinkPath" d="m0,0 l10,0 0,10 -10,0z M2,5 l6,0 M5,2 l0,6"/>
				<path id="expandedLinkPath" d="m0,0 l10,0 0,10 -10,0z M2,5 l6,0 M10,5 l12,0"/>
				<path id="connectorLinkPath" d="m0,0 l0,40 7,0"/>
				<xsl:apply-templates select="/*//*[name() != 'xsd:attribute' and name() != 'xsd:annotation' and (@name or @ref)]" mode="ContainerPath"/>
				<xsl:apply-templates select="/xsd:schema" mode="ContainerPath"/>
				<xsl:apply-templates select="..//*[xsd:attribute]" mode="AttributePath"/>
			</defs>
			<g filter="url(#Shadow)" stroke="black" onmouseover="mouseoverObject(evt)" onmouseout="mouseoutObject(evt)">
				<xsl:attribute name="fill">
					<xsl:call-template name="fillByType"/>
				</xsl:attribute>
				<xsl:apply-templates select="." mode="documentation"/>
			</g>
   <g id="toolTip" transform="translate(50,510)">
      <title>ToolTip box</title>
      <rect id="toolTipRect" width="200" height="13" fill="white" opacity="0.6"/>
      <text id="toolTipText" x="2" y="12" font-family="Arial" font-size="13" fill="red">
					_
				</text>
   </g>
			<script type="text/ecmascript">
		function onTargClick(evt, sVisID, sHidID) {
			// Get Document
			var target = evt.target;
			var doc = target.ownerDocument;

			if (sHidID == sVisID) {
				// Swap the current state
				var targVis = doc.getElementById(sVisID);
				var sDisp = targVis.getAttribute('display');
				switch (sDisp) {
				case 'none':	targVis.setAttribute('display', 'inline');	break;
				case 'inline':	targVis.setAttribute('display', 'none');	break;
				default:		targVis.setAttribute('display', 'inline');	break;
				}
			}
			else {
				// Make sHidId invisible
				var targHid = doc.getElementById(sHidID);
				targHid.setAttribute('display', 'none');
				// Make sVisID visible
				var targVis = doc.getElementById(sVisID);
				targVis.setAttribute('display', 'inline');
			}
		}
function mouseoverObject(evt) {
	var oTarget = evt.target;
	// if target is not text, or a link box...
	var sTargName = oTarget.getNodeName();
	if (sTargName == "text" || sTargName.indexOf("Collapse") != -1 || sTargName.indexOf("Expand") != -1) {
		return false;
	}
	// change appearance
	//oTarget.setAttribute("fill","red");
	oTarget.setAttribute("stroke","red");
	var oTitle = oTarget.parentNode.getElementsByTagName("title").item(0);
	if (oTitle == null) {
		return false;
	}
	var sTitle = oTitle.getFirstChild().nodeValue;
	//alert(evt.clientX);
	updateTip(oTarget,true,sTitle,evt.clientX+ 30,evt.clientY);
}

function mouseoutObject(evt) {
	var oTarget = evt.target;
	var sTargName = oTarget.getNodeName();
	if (sTargName == "text" || sTargName.indexOf("Collapse") != -1 || sTargName.indexOf("Expand") != -1) {
		return false;
	}
	//oTarget.setAttribute("fill", "white");
	oTarget.setAttribute("stroke", "black");
	updateTip(oTarget,false);
}

function updateTip(oTarget,show,sText,x,y) {
	// updates text with string sText; moves toolTip object adjacent to x,y
	// if show=false, hides tip
	var SVGDoc = oTarget.getOwnerDocument();
	var oToolTip = SVGDoc.getElementById("toolTip");
	if (show) {
		// update text
		var oText = SVGDoc.getElementById("toolTipText").getFirstChild();
		oText.setData(sText);
		// move tooltip
		oToolTip.setAttribute("transform","translate(" + x + "," + y + ")" );
		oToolTip.setAttribute("visibility","visible");
	}
	else {
		oToolTip.setAttribute("visibility","hidden");
	}
	
}
			</script>
		</svg>
	</xsl:template>

	<xsl:template match="text()" mode="documentation">
	</xsl:template>

	<xsl:template match="comment()" mode="documentation">
	</xsl:template>

	<xsl:template name="fillByType">
		<xsl:choose>
			<xsl:when test="name() = 'xsd:annotation'">lightyellow</xsl:when>
			<xsl:when test="name() = 'xsd:import'">lightgoldenrodyellow</xsl:when>
			<xsl:when test="name() = 'xsd:include'">palegoldenrod</xsl:when>
			<xsl:when test="name() = 'xsd:notation'">cornsilk</xsl:when>

			<xsl:when test="name() = 'xsd:element'">mediumaquamarine</xsl:when>
			<xsl:when test="name() = 'xsd:complexType'">darkseagreen</xsl:when>
			<xsl:when test="name() = 'xsd:simpleType'">lightseagreen</xsl:when>
			<xsl:when test="name() = 'xsd:group'">mediumturquoise</xsl:when>

			<xsl:when test="name() = 'xsd:attribute'">lightsalmon</xsl:when>
			<xsl:when test="name() = 'xsd:attributeGroup'">coral</xsl:when>

			<xsl:otherwise>white</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="*" mode="NameHierarchy">
		<xsl:choose>
			<xsl:when test="@name | @ref">
				<xsl:value-of select="@name | @ref"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="substring(local-name(), 1, 1)"/>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:if test="name() != 'xsd:schema'">
			<xsl:apply-templates select=".." mode="NameHierarchy"/>
		</xsl:if>
	</xsl:template>

	<xsl:template match="*" mode="ContainerPath">
		<xsl:variable name="Title" select="@name | @ref"/>
		<path>
			<xsl:attribute name="id">
				<xsl:value-of select="concat('cntr', $Title, 'Path')"/>
			</xsl:attribute>
			<xsl:variable name="TitleLength">
				<xsl:choose>
					<xsl:when test="string-length($Title) > 3">
						<xsl:value-of select="string-length($Title)"/>
					</xsl:when>
					<xsl:otherwise>3</xsl:otherwise>
				</xsl:choose>
			</xsl:variable>
			<xsl:variable name="Width" select="4 + ($TitleLength * 8.4)"/>
			<xsl:variable name="Height" select="32"/>
			<xsl:attribute name="d">
				<xsl:value-of select="concat('M0,0 c-10,0 -10,-', $Height ,' 0,-', $Height ,' l', $Width, ',0 c10,0 10,', $Height ,' 0,', $Height ,'z')"/>
			</xsl:attribute>
		</path>
	</xsl:template>

	<xsl:template match="*[xsd:attribute]" mode="AttributePath">
		<path>
			<xsl:variable name="Title">
				<xsl:apply-templates select="." mode="NameHierarchy"/>
			</xsl:variable>
			<xsl:attribute name="id">
				<xsl:value-of select="concat('attr', $Title, 'Path')"/>
			</xsl:attribute>
			<xsl:variable name="Width">
				<xsl:variable name="WidthsOrdered">
					<xsl:for-each select="xsd:attribute/@name | xsd:attribute/@ref">
						<xsl:sort select="string-length(.)" data-type="number" order="descending"/>
						<xsl:value-of select="concat(18 + string-length(.) * 7.2, '|')"/>
					</xsl:for-each>
				</xsl:variable>
				<xsl:value-of select="number(substring-before($WidthsOrdered, '|'))"/>
			</xsl:variable>
			<xsl:variable name="Height" select="7 + count(xsd:attribute) * 18"/>
			<xsl:attribute name="d">
				<xsl:value-of select="concat('M0,0 l0,', $Height, ' ', $Width, ',0 l0,-', $Height, 'z')"/>
			</xsl:attribute>
		</path>
	</xsl:template>

	<xsl:template match="*[name() != 'xsd:attribute' and name() != 'xsd:annotation']" mode="documentation">
		<xsl:param name="OffsetX" select="22"/>
		<xsl:param name="OffsetY" select="50"/>
		<xsl:variable name="Title" select="@name | @ref"/>
		<xsl:variable name="HeirTitle">
			<xsl:choose>
				<xsl:when test="@name | @ref">
					<xsl:value-of select="@name | @ref"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:apply-templates select="." mode="NameHierarchy"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="TitleLength">
			<xsl:choose>
				<xsl:when test="string-length($Title) > 3">
					<xsl:value-of select="string-length($Title)"/>
				</xsl:when>
				<xsl:otherwise>3</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="PathWidth" select="4 + $TitleLength * 8.4"/>

		<g stroke="black">
			<xsl:attribute name="fill">
				<xsl:call-template name="fillByType"/>
			</xsl:attribute>
			<title><xsl:value-of select="name()"/></title>
			<use xmlns:xlink="http://www.w3.org/1999/xlink">
				<xsl:attribute name="x"><xsl:value-of select="$OffsetX"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$OffsetY"/></xsl:attribute>
				<xsl:attribute name="xlink:href">
					<xsl:value-of select="concat('#', 'cntr', $Title, 'Path')"/>
				</xsl:attribute>
 			</use>
			<xsl:if test="string-length($Title) > 0">
				<g fill="black" font-size="14" font-family="Courier New">
					<text>
						<xsl:attribute name="x"><xsl:value-of select="$OffsetX"/></xsl:attribute>
						<xsl:attribute name="y"><xsl:value-of select="$OffsetY - 15"/></xsl:attribute>
						<xsl:value-of select="$Title"/>
					</text>
				</g>
			</xsl:if>
			<xsl:if test="count(xsd:attribute) > 0">
				<xsl:variable name="AttrTitle">
					<xsl:apply-templates select="." mode="NameHierarchy"/>
				</xsl:variable>
				<g fill="black" font-size="10" font-family="Courier New">
					<xsl:attribute name="onclick">
						<xsl:value-of select='concat("onTargClick( evt, &apos;attr", $AttrTitle, "Link&apos;, &apos;attr", $AttrTitle, "Link&apos;)")'/>
					</xsl:attribute>
					<text>
						<xsl:attribute name="x"><xsl:value-of select="$OffsetX"/></xsl:attribute>
						<xsl:attribute name="y"><xsl:value-of select="$OffsetY - 5"/></xsl:attribute>
						<xsl:text>@attr</xsl:text>
					</text>
				</g>
				<g display="none" filter="none" fill="white" stroke="black">
					<xsl:attribute name="id"><xsl:value-of select="concat('attr', $AttrTitle, 'Link')"/></xsl:attribute>
					<use xmlns:xlink="http://www.w3.org/1999/xlink">
						<xsl:attribute name="x"><xsl:value-of select="$OffsetX"/></xsl:attribute>
						<xsl:attribute name="y"><xsl:value-of select="$OffsetY + 1"/></xsl:attribute>
						<xsl:attribute name="xlink:href">
							<xsl:value-of select="concat('#', 'attr', $AttrTitle, 'Path')"/>
						</xsl:attribute>
					</use>
					<xsl:for-each select="xsd:attribute">
						<xsl:apply-templates select="." mode="documentation">
							<xsl:with-param name="OffsetX" select="$OffsetX + 8"/>
							<xsl:with-param name="OffsetY" select="$OffsetY + 15 + (18 * (position()-1))"/>
						</xsl:apply-templates>
					</xsl:for-each>
				</g>
			</xsl:if>
			<xsl:if test="count(*[name() != 'xsd:attribute' and name() != 'xsd:annotation']) > 0">
				<xsl:variable name="conColName" select="concat('cntr', $HeirTitle, 'Collapse')"/>
				<xsl:variable name="conExpName" select="concat('cntr', $HeirTitle, 'Expand')"/>
				<xsl:variable name="LinkX" select="$OffsetX + $PathWidth"/>
				<xsl:variable name="LinkY" select="$OffsetY - 21"/>
				<g filter="none" fill="white" stroke="black">
					<xsl:attribute name="id"><xsl:value-of select="$conColName"/></xsl:attribute>
					<use xlink:href="#collapsedLinkPath" filter="none" xmlns:xlink="http://www.w3.org/1999/xlink">
						<xsl:attribute name="x"><xsl:value-of select="$LinkX"/></xsl:attribute>
						<xsl:attribute name="y"><xsl:value-of select="$LinkY"/></xsl:attribute>
						<xsl:attribute name="onclick">
							<xsl:value-of select='concat("onTargClick( evt, &apos;", $conExpName, "&apos;, &apos;", $conColName, "&apos;)")'/>
						</xsl:attribute>
					</use>
				</g>
				<g display="none" fill="white" filter="none" stroke="black">
					<xsl:attribute name="id"><xsl:value-of select="$conExpName"/></xsl:attribute>
					<use xlink:href="#expandedLinkPath" filter="none" xmlns:xlink="http://www.w3.org/1999/xlink">
						<xsl:attribute name="x"><xsl:value-of select="$LinkX"/></xsl:attribute>
						<xsl:attribute name="y"><xsl:value-of select="$LinkY"/></xsl:attribute>
						<xsl:attribute name="onclick">
							<xsl:value-of select='concat("onTargClick( evt, &apos;", $conColName, "&apos;, &apos;", $conExpName, "&apos;)")'/>
						</xsl:attribute>
					</use>
					<xsl:for-each select="*[name() != 'xsd:attribute' and name() != 'xsd:annotation']">
						<xsl:apply-templates select="." mode="documentation">
							<xsl:with-param name="OffsetX" select="$OffsetX + $PathWidth + 30"/>
							<xsl:with-param name="OffsetY" select="$OffsetY + (40 * (position()-1))"/>
						</xsl:apply-templates>
						<xsl:if test="position() > 1">
							<use xlink:href="#connectorLinkPath" fill="none" xmlns:xlink="http://www.w3.org/1999/xlink">
								<xsl:attribute name="x"><xsl:value-of select="$LinkX + 15"/></xsl:attribute>
								<xsl:attribute name="y"><xsl:value-of select="$LinkY + 5 + (40 * (position()-2))"/></xsl:attribute>
							</use>
						</xsl:if>
					</xsl:for-each>
				</g>
			</xsl:if>
		</g>
	</xsl:template>

	<xsl:template match="*[name() = 'xsd:attribute']" mode="documentation">
		<xsl:param name="OffsetX" select="0"/>
		<xsl:param name="OffsetY" select="0"/>
		<xsl:variable name="Title" select="@name | @ref"/>
		<g fill="black" font-size="12" font-family="Courier New">
			<text>
				<xsl:attribute name="x"><xsl:value-of select="$OffsetX"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$OffsetY"/></xsl:attribute>
				<xsl:value-of select="$Title"/>
			</text>
		</g>
	</xsl:template>

</xsl:stylesheet><!-- Stylus Studio meta-information - (c)1998-2003 eXcelon Corp.
<metaInformation>
<scenarios ><scenario default="no" name="wcEdit" userelativepaths="yes" externalpreview="no" url="..\SCHEMA_REPOSITORY\Workcard\wcEdit&#x2D;v1.0.xsd" htmlbaseurl="" outputurl="" processortype="internal" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext=""/><scenario default="yes" name="wcOrder" userelativepaths="yes" externalpreview="no" url="..\SCHEMA_REPOSITORY\Workcard\wcOrder&#x2D;v1.0.xsd" htmlbaseurl="" outputurl="" processortype="internal" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext=""/></scenarios><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>
</metaInformation>
-->