Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes372downloads
Maml_HTML_Style.xsl385 linesDownload Raw Back to PSMaml
1<?xml version="1.0" encoding="UTF-8"?>2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 3                 xmlns:xhtml="http://www.w3.org/1999/xhtml" 4                 version="1.0">5	<xsl:template match="/">6		<HTML>7			<BODY style = "margin-top: 0; margin-left: 4; margin-bottom: 0; margin-right: 0;">8				<xsl:apply-templates/>9			</BODY>10		</HTML>11	</xsl:template>12 13	<!-- CALS table -->14	<!-- a priority of 10 insures that this template has a higher priority15	     than any templates not explicitly assigned on-->16	<xsl:template match='tgroup|entrytbl' priority='10'>17		<table>18			<!-- handle table width -->19			<!-- if the table uses proportional column widths, its width should be 100%;20			     otherwise, it should not be set -->21			<xsl:if test='colspec[contains(@colwidth,"*") or not(@colwidth)]'>22				<xsl:attribute name='width'>100%</xsl:attribute>23			</xsl:if>24			25			<!-- handle table frame attribute -->26			<xsl:attribute name='style'>27				border-collapse: collapse;28				border-width: 1px;29				border-color: black;30				31				<xsl:variable name='frame' select='ancestor::table/@frame'/>32				<xsl:choose>33					<xsl:when test='$frame="sides"'>34						border-left-style: solid;35						border-right-style: solid;36						border-top-style: hidden;37						border-bottom-style: hidden;38					</xsl:when>39					<xsl:when test='$frame="topbot"'>40						border-left-style: none;41						border-right-style: none;42						border-top-style: hidden;43						border-bottom-style: hidden;44					</xsl:when>45					<xsl:when test='$frame="top"'>46						border-left-style: hidden;47						border-right-style: hidden;48						border-top-style: solid;49						border-bottom-style: hidden;50					</xsl:when>51					<xsl:when test='$frame="bottom"'>52						border-left-style: hidden;53						border-right-style: hidden;54						border-top-style: hidden;55						border-bottom-style: solid;56					</xsl:when>57					<xsl:when test='$frame="none"'>58						border-left-style: hidden;59						border-right-style: hidden;60						border-top-style: hidden;61						border-bottom-style: hidden;62					</xsl:when>63					<xsl:otherwise>64						border-left-style: solid;65						border-right-style: solid;66						border-top-style: solid;67						border-bottom-style: solid;68					</xsl:otherwise>69				</xsl:choose>70			</xsl:attribute>71		72			<!-- transform colspecs -->73			<xsl:for-each select='colspec'>74				<col>75				76					<!-- handle width property -->77					<xsl:variable name='colwidth' select='@colwidth'/>78					<xsl:choose>79                        <!-- "*" or empty colwidth attributes are equivalent to "1*" -->80                        <!-- mixed measure colwidths are handled as if they were "1*" -->81						<xsl:when test='contains($colwidth,"+") or not($colwidth) or $colwidth="*"'>82							<xsl:attribute name='width'>1*</xsl:attribute>83						</xsl:when>84						<xsl:when test='contains($colwidth,"*")'>85							<xsl:attribute name='width'><xsl:value-of select='$colwidth'/></xsl:attribute>86						</xsl:when>87						<xsl:otherwise>88							<xsl:attribute name="style">width: 89								<xsl:choose>90									<xsl:when test='contains($colwidth,"pi")'>91										<!-- CALS and CSS use different abbreviations for picas -->92										<xsl:value-of select='translate($colwidth,"i","c")'/>93									</xsl:when>94									<xsl:otherwise>95										<xsl:value-of select='$colwidth'/>96									</xsl:otherwise>97								</xsl:choose>98							</xsl:attribute>99						</xsl:otherwise>100					</xsl:choose>101					102				</col>103			</xsl:for-each>104			105			<!-- transform rows -->106			<xsl:for-each select='thead|tfoot|tbody'>107				<xsl:copy>108					<xsl:for-each select='row'>109						<tr>110							<!-- transform cells -->111							<xsl:for-each select='entry|entrytbl'>112								<xsl:call-template name='transformCALSCell'/>113							</xsl:for-each>114						</tr>115					</xsl:for-each>116				</xsl:copy>117			</xsl:for-each>118		</table>119	</xsl:template>120	121	<xsl:template name='transformCALSCell'>122		<td>123			<!-- handle horizontal extension of the cell -->124			<xsl:variable name='spanname' select='@spanname'/>125			<xsl:variable name='namest' select='@namest'/>126			<xsl:variable name='nameend' select='@nameend'/>127			128			<xsl:choose>129				<xsl:when test='$spanname'>130					<xsl:variable name='spanspec' select='ancestor::*[spanspec][1]/spanspec[@spanname=$spanname]'/>131					<xsl:variable name='namest_2' select='$spanspec/@namest'/>132					<xsl:variable name='nameend_2' select='$spanspec/@nameend'/>133					134					<xsl:variable name='startColumn' select='count(ancestor::*[colspec][1]/colspec[@colname=$namest_2]/preceding-sibling::*)'/>135					<xsl:variable name='endColumn' select='count(ancestor::*[colspec][1]/colspec[@colname=$nameend_2]/preceding-sibling::*)'/>136					137					<xsl:attribute name='colspan'><xsl:value-of select='$endColumn - $startColumn + 1'/></xsl:attribute>138					139				</xsl:when>140				141				<xsl:when test='$namest and $nameend'>142					<xsl:variable name='startColumn' select='count(ancestor::*[colspec][1]/colspec[@colname=$namest]/preceding-sibling::*)'/>143					<xsl:variable name='endColumn' select='count(ancestor::*[colspec][1]/colspec[@colname=$nameend]/preceding-sibling::*)'/>144					145					<xsl:attribute name='colspan'><xsl:value-of select='$endColumn - $startColumn + 1'/></xsl:attribute>146				</xsl:when>147			</xsl:choose>148			149			<!-- handle vertical extension of the cell -->150			<xsl:variable name='morerows' select='@morerows'/>151			<xsl:if test='$morerows'>152				<xsl:attribute name='rowspan'><xsl:value-of select='$morerows+1'/></xsl:attribute>153			</xsl:if>154			155			<!-- handle horizontal alignment -->156			<xsl:call-template name='findInheritedAttribute'>157				<xsl:with-param name='attributeName'>align</xsl:with-param>158			</xsl:call-template>159			<xsl:call-template name='findInheritedAttribute'>160				<xsl:with-param name='attributeName'>char</xsl:with-param>161			</xsl:call-template>162			<xsl:call-template name='findInheritedAttribute'>163				<xsl:with-param name='attributeName'>charoff</xsl:with-param>164			</xsl:call-template>165			166			<!-- handle vertical alignment -->167			<xsl:variable name='valign' select='ancestor-or-self::*[@valign][1]/@valign'/>168			<xsl:attribute name='valign'>169				<xsl:choose>170					<xsl:when test='$valign'>171						<xsl:value-of select='$valign'/>172					</xsl:when>173					<xsl:otherwise>174						<!-- the default vertical alignment depends on whether175						     this cell is the table header, footer or body -->176						<xsl:choose>177							<xsl:when test='parent::*/parent::thead'>178								bottom179							</xsl:when>180							<xsl:otherwise>181								top182							</xsl:otherwise>183						</xsl:choose>184					</xsl:otherwise>185				</xsl:choose>186			</xsl:attribute>187			188			<!-- handle borders -->189			<xsl:attribute name='style'>190				border-width: 1px;191				border-color: black;192				193				<xsl:call-template name='findInheritedAttribute'>194					<xsl:with-param name='attributeName'>colsep</xsl:with-param>195				</xsl:call-template>196				197				<xsl:call-template name='findInheritedAttribute'>198					<xsl:with-param name='attributeName'>rowsep</xsl:with-param>199				</xsl:call-template>200			</xsl:attribute>201			202			<!-- transform cell content -->203			<xsl:apply-templates select='.'/>204		</td>205	</xsl:template>206	207	<!-- If the context node is an entry or entrytbl, searches for the value of an208	     inherited attribute by following the normal inheritance path.  If a209	     value is found, calls transformInheritedAttribute with attributeName210	     passes as is and attributeValue set to the found value; otherwise, calls211	     transformInheritedAttribute with attributeValue set to the empty string.212	     213	     Parameter attributeName is the name of the attribute found.214     -->215	216	<xsl:template name='findInheritedAttribute'>217		<xsl:param name='attributeName'/>218		219		<xsl:variable name='colname' select='@colname'/>220		<xsl:variable name='colname_colspec' select='ancestor::*[colspec][1]/colspec[@colname=$colname]'/>221		222		<xsl:variable name='namest' select='@namest'/>223		<xsl:variable name='namest_colspec' select='ancestor::*[colspec][1]/colspec[@colname=$namest]'/>224		225		<xsl:variable name='spanname' select='@spanname'/>226		<xsl:variable name='spanspec' select='ancestor::*[spanspec][1]/spanspec[@spanname=$spanname]'/>227		<xsl:variable name='span_namest' select='$spanspec/@namest'/>228		<xsl:variable name='span_colspec' select='ancestor::*[colspec][1]/colspec[@colname=$span_namest]'/>229		230		231		<xsl:choose>232			<!-- start by looking at the context node -->233			<xsl:when test='@*[local-name()=$attributeName]'>234				<xsl:call-template name='transformInheritedAttribute'>235					<xsl:with-param name='attributeName' select='$attributeName'/>236					<xsl:with-param name='attributeValue' select='@*[local-name()=$attributeName]'/>237				</xsl:call-template>238			</xsl:when>239			240			<!-- next, look at the containing row -->241			<xsl:when test='parent::*/@*[local-name()=$attributeName]'>242				<xsl:call-template name='transformInheritedAttribute'>243					<xsl:with-param name='attributeName' select='$attributeName'/>244					<xsl:with-param name='attributeValue' select='parent::*/@*[local-name()=$attributeName]'/>245				</xsl:call-template>246			</xsl:when>247			248			<!-- next, look at the spanspec -->249			<xsl:when test='$spanspec/@*[local-name()=$attributeName]'>250				<xsl:call-template name='transformInheritedAttribute'>251					<xsl:with-param name='attributeName' select='$attributeName'/>252					<xsl:with-param name='attributeValue' select='$spanspec/@*[local-name()=$attributeName]'/>253				</xsl:call-template>254			</xsl:when>255			256			<!-- next, look at the colspec -->257			<!-- (at most one of colname_colspec, span_colspec, namest_colspec will be non-empty -->258			<xsl:when test='$colname_colspec/@*[local-name()=$attributeName]'>259				<xsl:call-template name='transformInheritedAttribute'>260					<xsl:with-param name='attributeName' select='$attributeName'/>261					<xsl:with-param name='attributeValue' select='$colname_colspec/@*[local-name()=$attributeName]'/>262				</xsl:call-template>263			</xsl:when>264			<xsl:when test='$span_colspec/@*[local-name()=$attributeName]'>265				<xsl:call-template name='transformInheritedAttribute'>266					<xsl:with-param name='attributeName' select='$attributeName'/>267					<xsl:with-param name='attributeValue' select='$span_colspec/@*[local-name()=$attributeName]'/>268				</xsl:call-template>269			</xsl:when>	270			<xsl:when test='$namest_colspec/@*[local-name()=$attributeName]'>271				<xsl:call-template name='transformInheritedAttribute'>272					<xsl:with-param name='attributeName' select='$attributeName'/>273					<xsl:with-param name='attributeValue' select='$namest_colspec/@*[local-name()=$attributeName]'/>274				</xsl:call-template>275			</xsl:when>276			277			<!-- next, look at the tgroup or entrytbl -->278			<xsl:when test='parent::*/parent::*/parent::*/@*[local-name()=$attributeName]'>279				<xsl:call-template name='transformInheritedAttribute'>280					<xsl:with-param name='attributeName' select='$attributeName'/>281					<xsl:with-param name='attributeValue' select='parent::*/parent::*/parent::*/@*[local-name()=$attributeName]'/>282				</xsl:call-template>283			</xsl:when>284							285			<!-- next, look at the table -->286			<xsl:when test='ancestor::table[1]/@*[local-name()=$attributeName]'>287				<xsl:call-template name='transformInheritedAttribute'>288					<xsl:with-param name='attributeName' select='$attributeName'/>289					<xsl:with-param name='attributeValue' select='ancestor::table[1]/@*[local-name()=$attributeName]'/>290				</xsl:call-template>291			</xsl:when>					292			293			<!-- it wasn't found -->294			<xsl:otherwise>295				<xsl:call-template name='transformInheritedAttribute'>296					<xsl:with-param name='attributeName' select='$attributeName'/>297					<xsl:with-param name='attributeValue' select='""'/>298				</xsl:call-template>299			</xsl:otherwise>300			301		</xsl:choose>302	</xsl:template>303	304	<!-- Transforms a CALS table attribute found using findInheritedAttribute305	     into an HTML table attribute.306		  307		  Parameter attributeName is the name of the found attribute.  Parameter308		  attributeValue is its value.309	-->310	<xsl:template name='transformInheritedAttribute'>311		<xsl:param name='attributeName'/>312		<xsl:param name='attributeValue'/>313		314		<xsl:choose>315			<!-- transform colsep -->316			<!-- colseps are transformed while outputting a style attribute -->317			<xsl:when test='$attributeName = "colsep"'>318				<xsl:choose>319					<xsl:when test='$attributeValue = "0"'>320						border-right-style: none;321					</xsl:when>322					<xsl:otherwise>323						border-right-style: solid;324					</xsl:otherwise>325				</xsl:choose>326			</xsl:when>327			328			<!-- transform rowsep -->329			<!-- rowseps are transformed while outputting a style attribute -->330			<xsl:when test='$attributeName = "rowsep"'>331				<xsl:choose>332					<xsl:when test='$attributeValue = "0"'>333						border-bottom-style: none;334					</xsl:when>335					<xsl:otherwise>336						border-bottom-style: solid;337					</xsl:otherwise>338				</xsl:choose>339			</xsl:when>340			341			<!-- transform align -->342			<!-- default to left if no value is specified -->343			<xsl:when test='$attributeName = "align"'>344				<xsl:attribute name='align'>345					<xsl:choose>346						<xsl:when test='$attributeValue'>347							<xsl:value-of select="$attributeValue"/>348						</xsl:when>349						<xsl:otherwise>350							left351						</xsl:otherwise>352					</xsl:choose>353				</xsl:attribute>354			</xsl:when>355			356			<!-- transform char -->357			<!-- default to no char attribute if no value is specified -->358			<xsl:when test='$attributeName = "char"'>359				<xsl:if test='$attributeValue'>360					<xsl:attribute name='char'>361						<xsl:value-of select="$attributeValue"/>362					</xsl:attribute>363				</xsl:if>364			</xsl:when>365			366			<!-- transform charoff -->367			<!-- default to 50% if no value is specified -->368			<xsl:when test='$attributeName = "charoff"'>369				<xsl:attribute name='charoff'>370					<xsl:choose>371						<xsl:when test='$attributeValue'>372							<!-- CALS charoffs are implicitly percentages -->373							<xsl:value-of select="$attributeValue"/>%374						</xsl:when>375						<xsl:otherwise>376							50%377						</xsl:otherwise>378					</xsl:choose>379				</xsl:attribute>380			</xsl:when>381		382		</xsl:choose>383	</xsl:template>384</xsl:stylesheet>385