configreport.xsl

来自「Application Note Abstract The unique co」· XSL 代码 · 共 2,215 行 · 第 1/5 页

XSL
2,215
字号
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">

<HTML>
<HEAD>
	<STYLE>
		DIV.page { page-break-before: always }
	</STYLE>

  
	<XML ID="ZZZ" SRC="PSoCConfig.xml"></XML>


	<SCRIPT language="JavaScript">
	
	<![CDATA[
		
		var g_PO_defs;	
		var g_PO_4nPinBodycXcY;
		var g_PO_InteriorLableCX;
		var g_PO_SVGDoc;	
		var g_PO_SVGRoot; 
		var g_PO_objXMLDoc;
		var	g_PO_nodeList_PIN_DESC;

		var g_PO_ColorArray;			
		var g_PO_ColorStringArray;
		var g_PO_PinSelectSubStringArray;
		var g_PO_PinSelectArraySize;
		
		var g_PO_sBaseDevice	= ""; 
		var m_sPackageType	= "";  

		var g_DeviceEditor				= null;
		var g_ps						= null;
		var	g_PV_InitGlobalsInitted		= false;

		
		////////////////
		//
		//	Called from outside 
		//	Adds Name PSoC Designer and Device editor to scripting engines namespace
		//	Causes cascade of recalcs
		//
		////////////////
		function setPSoC(ps)
		{
			g_ps			= ps;
			g_DeviceEditor	= ps.GetDeviceEditor();

			if (g_DeviceEditor == null)
			{
				alert("g_DeviceEditor = null");
			}
			else
			{
				PO_InitGlobals();	
				PV_InitGlobals();	

				var n = document.embeds.length;
				for (i =0; i , i < n; i++)
				{		
					var sSVGID = document.embeds[i].id;

					if (-1 == sSVGID.lastIndexOf("_PV_SVG"))
					{
						PO_InitSVG(sSVGID); 
					}
					else
					{
						PV_InitSVG(sSVGID);
					}
				}
			}
		}	
		

		///////////////////Begin global funcs/////////////////////////
		/**************************************************************************
		* 
		*	
		*	
		****************************************************************************/
		function fnc_trim(str_String)
		{
		   return str_String.replace(/^\s*/, '').replace(/\s*$/,'');
		}
		
		/**************************************************************************
		* 
		* This function is called to suppress javascript error messages when it is
		* known that the errors are not real problems.	
		*	
		****************************************************************************/
		function suppress_errors ()
		{
			
			return true;
		}
	
		/**************************************************************************
		* 
		*	
		*	
		****************************************************************************/
		function does_SVG_EMBED_exist (sName)
		{
			// First, redirect the error handler so that if the SVG plug-in has not
			// yet loaded or is not present, it doesn't cause the browser to
			// issue a JavaScript error.
			var old_error = window.onerror;
			window.onerror = suppress_errors;

			// Now attempt to get the SVG object.
			var svgobj = document.embeds[sName];

			// Reset the error hanlder to the browser's default handler.
			window.onerror = old_error;

			// Return appropriate value.
			if (svgobj == null)
			{
				return false;
			}
			else
			{
				return true;
			}
		}

		
		/**************************************************************************
		* 
		*	Verify that the indicated SVG element exists.
		*	
		****************************************************************************/
		function does_element_exist (sName, element_name)
		{
			// First, redirect the error handler so that if the SVG plug-in has not
			// yet loaded or is not present, it doesn't cause the browser to
			// issue a JavaScript error.
			var old_error = window.onerror;
			window.onerror = suppress_errors;

			// Now attempt to get the SVG object.
			var svgobj = document.embeds[sName].getSVGDocument().getElementById(element_name);

			// Reset the error hanlder to the browser's default handler.
			window.onerror = old_error;

			// Return appropriate value.
			if (svgobj == null)
				return false;
			else
				return true;
		}


		
		/**************************************************************************
		* ImportXMLOutOfSandBox	 
		*	ImportXMLOutOfSandBox
		*	
		****************************************************************************/
		function ImportXMLOutOfSandBox(sXML)
		{
			//var old_error	= window.onerror;
			//window.onerror	= suppress_errors;

			

			var xmlDoc = null;
			if (g_ps != null)
			{
				xmlDoc =  g_ps.GetXMLDOM(); 
				xmlDoc.load(sXML);
			}

			

			// Reset the error hanlder to the browser's default handler.
			//window.onerror = old_error;


			return xmlDoc;
		}
		///////////////////end global funcs/////////////////////////


		///////////////////end global funcs/////////////////////////






		/**************************************************************************
		* PO_CreateTextPath
		* 
		*	create a  path element with a textPath element with a ref to a def
		*	creat def
		*
		***************************************************************************/
		function PO_CreateTextPath(sText,  sPath, sPathID)
		{
			//path with id and dummy data
			var pathForTextPath = g_PO_SVGDoc.createElement("path");
			pathForTextPath.setAttribute("id", sPathID);
		
			//ad path to defs
			g_PO_defs.appendChild(pathForTextPath);
			g_PO_SVGRoot.appendChild(g_PO_defs);
			pathForTextPath.setAttribute("d", sPath);
				
			text = g_PO_SVGDoc.createElement("text");
			text.setAttribute("style", "font-family:Verdana; font-size:10; fill:#000000; ; text-anchor: start");

			var sFullID = "#" + sPathID;	

			//textpath
			textPath = g_PO_SVGDoc.createElement("textPath");
			textPath.setAttributeNS(
			  "http://www.w3.org/1999/xlink",
			  "xlink:href",
			  sFullID
			);

			
			textNode = g_PO_SVGDoc.createTextNode(sText);
			textPath.appendChild(textNode);
			text.appendChild(textPath);
			g_PO_SVGRoot.appendChild(text);
		}


		/**************************************************************************
		* PO_GetFormattedPinLabel
		* 
		*	
		****************************************************************************/
		function PO_GetFormattedPinLabel(nItem)
		{
			// get label
			var sPinLabel = "";
			mapStatus = g_PO_nodeList_PIN_DESC.item(nItem).attributes;
			attrStatus = mapStatus.getNamedItem("PIN_LABEL");
			if (attrStatus != null)
			{	
				sPinLabel = attrStatus.value;
			}

			//get pin number
			var sPinNumber = "";
			attrStatus = mapStatus.getNamedItem("PIN_NUMBER");
			if (attrStatus != null)
			{	
				sPinNumber = attrStatus.value;
			}

			var sText = sPinNumber + " " + sPinLabel;
			return sText;
		}


		/**************************************************************************
		* PO_CreateTopPins4
		*	CreateTopPins for a 4 sided part
		*	
		****************************************************************************/
		function PO_CreateTopPins4(nPinsPerSide, nPinBodyWidth, nPinBodyX, nPinBodyY, nPinHeight, nPinWidth)
		{
			var nCurPinOffSet = nPinHeight;
			
			var nStart	=	(nPinsPerSide * 4) - 1;
			var nEnd	= 	(nPinsPerSide * 3) -1;

			var j = 0;
			for (var i = nStart; i > nEnd; i--, j++) 
			{
				//calc y 
				var yLabel = nPinBodyY + (2*nPinHeight) + (j * (2*nPinHeight)) -(nPinHeight/2) + g_PO_FontHeight/2 + g_PO_InteriorLableCX/2;
			
				//PIN LABEL
				{
					var sText = PO_GetFormattedPinLabel(i); 
					var sID		= "CreateTopPins4Label"	+ j;
					var sPath	=	"M "						
									+ (nPinBodyX +  (nCurPinOffSet + g_PO_InteriorLableCX/2) + nPinHeight)
									+ "	"	
									+ (nPinBodyY + (3*nPinWidth) ) 
									+ " l 0 -200";

					PO_CreateTextPath(sText, sPath, sID);
				}


				//CUSTOM PIN LABEL
				{
					// get label
					var sText = "";
					mapStatus = g_PO_nodeList_PIN_DESC.item(i).attributes;
					attrStatus = mapStatus.getNamedItem("PIN_CUSTOM_NAME");

					if (attrStatus != null)
					{	
						sText = attrStatus.value;
					}
					else
					{
						sText = "fish";
					}
								
					var sID		= "CreateTopPins4CustomLabel"	+ i;
					var sPath	=	"M "						
									+ (nPinBodyX +  (nCurPinOffSet + g_PO_InteriorLableCX/2) + nPinHeight)
									+ "	"	
									+ (nPinBodyY  -  (1.5 * nPinWidth) ) 
									+ " l 0 -200";
					PO_CreateTextPath(sText, sPath, sID);
				}


				//DRAW PIN 
				{
					var sdValue		= "M "		+ nPinBodyX							+ "	"	+ nPinBodyY
									+ " m "		+ (nCurPinOffSet + g_PO_InteriorLableCX/2)	+ " 0 "	
									+ " l "		+ " 0 -"								+ nPinWidth			 
									+ " l "		+ nPinHeight							+ " 0" 
									+ " l "		+ " 0 "									+ nPinWidth			 

				
					var mypath;
					mypath = g_PO_SVGDoc.createElement("path");
					mypath.setAttribute("d", sdValue);
					var sStyleString = PO_GetPinFillColor(i);
					mypath.setAttribute("fill", sStyleString);
					mypath.setAttribute("stroke", "black");
					mypath.setAttribute("stroke-width", "2");
					g_PO_SVGRoot.appendChild(mypath);
				}	
				nCurPinOffSet += (nPinHeight*2);
			}
		
			// Propagate the event to other handlers.
			return true;
		}

		
		/**************************************************************************
		* CreateBottomPins
		*	CreateBottomPins for a 4 sided part
		*	
		****************************************************************************/
		function PO_CreateBottomPins4(nPinsPerSide, nPinBodyWidth, nPinBodyX, nPinBodyY, nPinHeight, nPinWidth) 
		{
			
			var nCurPinOffSet = nPinHeight;

			var nStart	= nPinsPerSide;
			var nEnd	= 2*nPinsPerSide;
			
			for (var i = nStart; i < nEnd; i++) 
			{
				//calc x 
				var xLabel = nPinBodyX + (2*nPinHeight) + (i * (2*nPinHeight)) -(nPinHeight/2) + g_PO_FontHeight/2 + g_PO_InteriorLableCX/2;
			
				//PIN LABEL
				{
					var sText = PO_GetFormattedPinLabel(i); 
					var sID		= "PO_CreateBottomPins4"	+ i;
					var sPath	=	"M "						
									+ (nPinBodyX +  (nCurPinOffSet + g_PO_InteriorLableCX/2) + nPinHeight)
									+ "	"	
									+ (nPinBodyY + g_PO_4nPinBodycXcY -nPinHeight) // - (4*nPinWidth) )
									+ " l 0 -200";

					PO_CreateTextPath(sText, sPath, sID);
				}

				//DRAW PIN 
				{
					var sdValue		= "M "		+ nPinBodyX							+ "	"	+ (nPinBodyY + g_PO_4nPinBodycXcY)
									+ " m "		+ (nCurPinOffSet + g_PO_InteriorLableCX/2)	+ " 0 "	
									+ " l "		+ " 0 "									+ nPinWidth			 
									+ " l "		+ nPinHeight							+ " 0" 
									+ " l "		+ " 0 -"								+ nPinWidth			 

					
					var mypath;
					mypath = g_PO_SVGDoc.createElement("path");
					mypath.setAttribute("d", sdValue);
					var sStyleString = PO_GetPinFillColor(i);
					mypath.setAttribute("fill", sStyleString);
					mypath.setAttribute("stroke", "black");
					mypath.setAttribute("stroke-width", "2");
					g_PO_SVGRoot.appendChild(mypath);
				}	


				//CUSTOM PIN LABEL
				{
					// get label
					var sText = "";
					mapStatus = g_PO_nodeList_PIN_DESC.item(i).attributes;
					attrStatus = mapStatus.getNamedItem("PIN_CUSTOM_NAME");

					if (attrStatus != null)
					{	
						sText = attrStatus.value;
					}
					else
					{
						sText = "fish";
					}
								
					var sID		= "CreateBottomPins4PinLabel"	+ i;
					var sPath	=	"M "						
									+ (nPinBodyX +  (nCurPinOffSet + g_PO_InteriorLableCX/2) + nPinHeight)
									+ "	"	
									+ (nPinBodyY + g_PO_4nPinBodycXcY + (4*nPinWidth) )
									+ " l 0 -200";

					PO_CreateTextPath(sText, sPath, sID);
				}
				nCurPinOffSet += (nPinHeight*2);


			}
		
			// Propagate the event to other handlers.
			return true;
		}

		/**************************************************************************
		* CreateBottomPins
		*	CreateBottomPins for a 4 sided part
		*	
		****************************************************************************/
		function PO_CreateLeftPins4(nPinsPerSide, nPinBodyWidth, nPinBodyX, nPinBodyY, nPinHeight, nPinWidth) 
		{
			
			var nCurPinOffSet	= nPinHeight;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?