[Mono-list] Help needed with XSLT:

Peter Williams peterw@ximian.com
18 Jan 2003 15:40:46 -0500


--=-gYuCe7SzA3WggWR69AJM
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Sat, 2003-01-18 at 15:02, Miguel de Icaza wrote:
> Hey guys,
> 
>    I posted this to the docs mailing list, but got no input so far. 
> Anyone could help us with this?
> 
> Miguel

I have to leave now but I think this should do the job? Attached is the
template and a test file that I used. Note it doesn't munge the text in
<see> correctly; there are string routines but I don't have time to look
them up.

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

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

--=-gYuCe7SzA3WggWR69AJM
Content-Disposition: attachment; filename=Test.xml
Content-Type: text/xml; name=Test.xml; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<super>
   <sub>
      <para>This is some stuff</para>
      <para>With <child>sub</child> elements</para>
      <para>Also, see <see cref="Foo.Bar.Bam"/> too</para>
      <para>Also, <paramref name="bob"/> is cool too.</para>
   </sub>
</super>

--=-gYuCe7SzA3WggWR69AJM
Content-Disposition: attachment; filename=monodoc.xsl
Content-Type: text/plain; name=monodoc.xsl; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE xsl:stylesheet>

<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">

  <xsl:output method="xml"/>

  <!-- Basically, copy the entire tree, except for:
      	* para -> p
	* see -> a href
	* paramref -> i -->

  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="para">
    <p>
      <xsl:apply-templates select="@*|node()"/>
    </p>
  </xsl:template>

  <xsl:template match="see">
    <a href="{@cref}"><xsl:value-of select="@cref"/></a>
  </xsl:template>

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

</xsl:stylesheet>

--=-gYuCe7SzA3WggWR69AJM--