[Mono-list] Re: More help needed with XSLT.

Peter Williams peterw@ximian.com
17 Feb 2003 20:50:37 -0500


--=-9EBjh9opjO4Y+dSfYpsA
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi Miguel,

On Mon, 2003-02-17 at 20:29, Miguel de Icaza wrote:
> Hello!
> 
>     I am using the first attached XSLT in the Mono documentation
> browser, but it is not handling a couple of entries:...

This should do the trick, I think.

Peter

-- 
Peter Williams     peter@newton.cx / peterw@ximian.com

"[Ninjas] are cool; and by cool, I mean totally sweet."
                              -- REAL Ultimate Power

--=-9EBjh9opjO4Y+dSfYpsA
Content-Disposition: inline; filename=mono-ecma.xsl
Content-Type: text/plain; name=mono-ecma.xsl; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	
	<xsl:template name="string-replace" >
	  <xsl:param name="string"/>
	  <xsl:param name="from"/>
	  <xsl:choose>
		  <xsl:when test="contains($string,'(')">
		  <xsl:call-template name="string-replace">
		  <xsl:with-param name="string" select="substring-before($string,'(')"/>
		  <xsl:with-param name="from" select="$from"/>
		  </xsl:call-template>
		</xsl:when>
		<xsl:when test="contains($string,$from)">
		  <xsl:call-template name="string-replace">
		  <xsl:with-param name="string" select="substring-after($string,$from)"/>
		  <xsl:with-param name="from" select="$from"/>
		  </xsl:call-template>
		</xsl:when>
		<xsl:otherwise>
		  <xsl:value-of select="$string"/>
		</xsl:otherwise>
	  </xsl:choose>
	</xsl:template>	

	<xsl:template name="string-addsignature">
	  <xsl:param name="string"/>
	  <xsl:choose>
		  <xsl:when test="contains($string,'(')">
				(<xsl:value-of select="substring-after($string,'(')"/>
			</xsl:when>
	  </xsl:choose>
	</xsl:template>	
	
	
	<xsl:template match="document">
		<html>
			<head><title>Prueba de mono</title></head>
		<xsl:apply-templates/>
		</html>
	</xsl:template>

	<xsl:template match="para">
		<p>
			<xsl:apply-templates/>
		</p>
	</xsl:template>

	<xsl:template match="paramref">
		<i><xsl:value-of select="@name"/>
				<xsl:apply-templates/>
		</i>
	</xsl:template>

	<xsl:template match="example">
		<pre>
			<xsl:apply-templates/>
		</pre>
	</xsl:template>
	
	<xsl:template match="see">
		<xsl:choose>
		<xsl:when test="string-length(@langword)=0">
			<a href="{@cref}">
				<xsl:call-template name="string-replace">
					<xsl:with-param name="string" select="@cref"/>
					<xsl:with-param name="from">.</xsl:with-param>
				</xsl:call-template>
				<xsl:call-template name="string-addsignature">
				  <xsl:with-param name="string" select="@cref"/>
				</xsl:call-template>
				<xsl:apply-templates/>
			</a>
		</xsl:when>
		<xsl:otherwise>
			<a href="{@langword}"><xsl:value-of select="@langword"/></a>
		</xsl:otherwise>
		</xsl:choose>	  
	</xsl:template>
	

	
</xsl:stylesheet>

--=-9EBjh9opjO4Y+dSfYpsA--