This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Stylesheet assistance


Daniel --

Well, it's ugly but it does seem to do what you want.  Maybe someone can
come up with a more abbreviated version.

========================
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html" indent="yes" />
<xsl:strip-space elements="test"/>

<xsl:template match="test">
<html>
  <body>
    <xsl:apply-templates/>
  </body>
</html>
</xsl:template>

<xsl:template match="a1">
  <xsl:apply-templates select="p"/>
  <xsl:apply-templates select="a2">
    <xsl:with-param name="indent">
      <xsl:choose>
	  <xsl:when test="b">12</xsl:when>
	  <xsl:otherwise>0</xsl:otherwise>
      </xsl:choose>
    </xsl:with-param>
  </xsl:apply-templates>
</xsl:template>

<xsl:template match="a2">
  <xsl:param name="indent" select="0"/>
  <xsl:apply-templates select="p">
    <xsl:with-param name="indent" select="$indent"/>
  </xsl:apply-templates>
  <xsl:apply-templates select="a3">
    <xsl:with-param name="indent">
      <xsl:choose>
        <xsl:when test="$indent > 0"><xsl:value-of
select="number($indent)+12"/></xsl:when>
	  <xsl:when test="b">12</xsl:when>
	  <xsl:otherwise>0</xsl:otherwise>
      </xsl:choose>
    </xsl:with-param>
  </xsl:apply-templates>
</xsl:template>

<xsl:template match="a3">
  <xsl:param name="indent" select="0"/>
  <xsl:apply-templates select="p">
    <xsl:with-param name="indent"  select="$indent"/>
  </xsl:apply-templates>
  <xsl:apply-templates select="a4">
    <xsl:with-param name="indent">
      <xsl:choose>
        <xsl:when test="$indent > 0"><xsl:value-of
select="number($indent)+12"/></xsl:when>
	  <xsl:when test="b">12</xsl:when>
	  <xsl:otherwise>0</xsl:otherwise>
      </xsl:choose>
    </xsl:with-param>
  </xsl:apply-templates>
</xsl:template>

<xsl:template match="a4">
  <xsl:param name="indent" select="0"/>
  <xsl:apply-templates select="p">
    <xsl:with-param name="indent"  select="$indent"/>
  </xsl:apply-templates>
  <xsl:apply-templates select="a5">
    <xsl:with-param name="indent">
      <xsl:choose>
        <xsl:when test="$indent > 0"><xsl:value-of
select="number($indent)+12"/></xsl:when>
	  <xsl:when test="b">12</xsl:when>
	  <xsl:otherwise>0</xsl:otherwise>
      </xsl:choose>
    </xsl:with-param>
  </xsl:apply-templates>
</xsl:template>

<xsl:template match="a5">
  <xsl:param name="indent" select="0"/>
  <xsl:apply-templates select="p">
    <xsl:with-param name="indent"  select="$indent"/>
  </xsl:apply-templates>
  <xsl:apply-templates select="a6">
    <xsl:with-param name="indent">
      <xsl:choose>
        <xsl:when test="$indent > 0"><xsl:value-of
select="number($indent)+12"/></xsl:when>
	  <xsl:when test="b">12</xsl:when>
	  <xsl:otherwise>0</xsl:otherwise>
      </xsl:choose>
    </xsl:with-param>
  </xsl:apply-templates>
</xsl:template>

<xsl:template match="a6">
  <xsl:param name="indent" select="0"/>
  <xsl:apply-templates select="p">
    <xsl:with-param name="indent"  select="$indent"/>
  </xsl:apply-templates>
</xsl:template>

<xsl:template match="p">
  <xsl:param name="indent" select="0"/>
  <p>
    <xsl:if test="$indent > 0">
      <xsl:attribute name="style">margin-left: <xsl:value-of
select="$indent"/>px</xsl:attribute>
    </xsl:if>
    <xsl:value-of select="." />
  </p>
</xsl:template>

</xsl:stylesheet>
========================

Daniel Pitti wrote:
> 
> Any suggestions on how do do the following?
> 
> Given the following DTD:
> ...


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]