Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unwanted showing of content nodes

Status
Not open for further replies.

CvW1979

Programmer
Apr 17, 2005
3
NL
Hi,

I have a problem with an XSL file that I use to show a XML file as a tree in my browser. The XML-file I use is:

Code:
<types title="types">
	<frontpage id="1" title="frontpage">
		<display id="2" title="display">block</display>
	</frontpage>
	<page id="3" title="page">
		<display id="4" title="display">inline</display>
	</page>
</types>

And the XSL (downloaded from
Code:
    </html>
  </xsl:template>

  <!-- Show each tree line -->

  <xsl:template match="*" mode="line">
    <div class="Node">
      <xsl:call-template name="graft"/>
      <xsl:apply-templates select="." mode="item"/>
    </div>
    <xsl:apply-templates mode="line"/>
  </xsl:template>

  <!-- Show item displays for different element types -->

  <xsl:template match="*" mode="item">
    <xsl:value-of select="@title"/>
  </xsl:template>


  <!-- Templates used to generate the "stick stack" of
       tree connectors -->

  <xsl:template name="graft">
    <!-- Generate ancestor connectors -->
    <xsl:apply-templates select="ancestor::*" mode="tree"/>

    <!-- Generate current-node connector -->
    <xsl:choose>
      <xsl:when test="following-sibling::*">
        <img src="icons/tree_tee.gif"/>
      </xsl:when>
      <xsl:otherwise>
        <img src="icons/tree_corner.gif"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <!-- Suppress ancestor connector for the top node -->

  <xsl:template match="types" mode="tree"/>

  <!-- Show ancestor connectors for all other node types -->

  <xsl:template match="*" mode="tree">
    <xsl:choose>
      <xsl:when test="following-sibling::*">
        <img src="icons/tree_bar.gif"/>
      </xsl:when>
      <xsl:otherwise>
        <img src="icons/tree_spacer.gif"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

</xsl:stylesheet>

I keep getting the content nodes (i.e., "block" and "inline") printed at the bottom of the output. I already experimented with templates to supress them, but without any succes. Any help would be greatly appreciated.
 
I'm sorry, I apparently missed the top bit of the xsl-file. Here it is:

Code:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]

  <!-- Templates used to generate text content -->

  <xsl:template match="/*">
    <html>
      <head>
        <title>test</title>
        <style type="text/css">
          body { font-size: smaller }
          div, img { border: 0px; margin: 0px; padding: 0px }
          div.Node * { vertical-align: middle }
        </style>
      </head>
      <body>
        <b><xsl:value-of select="@title"/></b>
        <xsl:apply-templates select="*" mode="line"/>
      </body>
    </html>
  </xsl:template>

  <!-- Show each tree line -->

...
 
Code:
    <!-- Show each tree line -->
    <xsl:template match="*" mode="line">
        <div class="Node">
            <xsl:call-template name="graft"/>
            <xsl:apply-templates select="." mode="item"/>
        </div>
        <xsl:apply-templates mode="line" select="*"/>
    </xsl:template>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top