AW: [xsl] can't display heading in between fields...pls. help

Subject: AW: [xsl] can't display heading in between fields...pls. help
From: Markus Abt <abt@xxxxxxxx>
Date: Fri, 18 Jul 2003 01:10:24 +0200
John,

this are my changes to your stylesheet (see comments marked with "MARKUS:").
-  I have changed the first template (HSContract)
-  I have added 2 new templates.
   Since you already work with modes, I picked this up.
   mode="target" produces the descriptions in the second part of the resulting HTML.



<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:template match="HSContract">
    <html>
      <head>
        <title/>
      </head>
      <body>
      	<!--<p><a href="#desc"><b>Contract Name: </b><xsl:value-of select="@contractName"/><br /></a>-->
		<p><b>Contract Name: </b><xsl:value-of select="@contractName"/><br />
		<b>ID: </b><xsl:value-of select="@id"/><br />
		<b>Start Date: </b><xsl:value-of select="@startDate"/><br /></p>
		<xsl:apply-templates select="HSDataContainerType[@name='Inputs']"/>
		<xsl:apply-templates select="HSDataContainerType[@name='Outputs']"/>
		<xsl:apply-templates select="HSDocumentation"/>

		<!-- MARKUS: the next two lines are new -->
		<xsl:apply-templates select="HSDataContainerType[@name='Inputs']" mode="target"/>
		<xsl:apply-templates select="HSDataContainerType[@name='Outputs']" mode="target"/>

		<!-- MARKUS: this is now done in the following two templates
		<xsl:apply-templates select="//HSString | //HSDouble | //HSInteger" mode="target" />
		-->
	  </body>
    </html>
  </xsl:template>

  <!-- MARKUS: This template generates the list of input fields -->
  <xsl:template match="HSDataContainerType[@name='Inputs']" mode="target">
	<p><b><a name="in">Input Descriptions</a></b></p>
  	<xsl:apply-templates select=".//HSString | .//HSDouble | .//HSInteger" mode="target" />
  </xsl:template>

  <!-- MARKUS: This template generates the list of output fields -->
  <xsl:template match="HSDataContainerType[@name='Outputs']" mode="target">
	<p><b><a name="out">Output Descriptions</a></b></p>
  	<xsl:apply-templates select=".//HSString | .//HSDouble | .//HSInteger" mode="target" />
  </xsl:template>

  <!-- MARKUS: Delete all <a name="in"> and <a name="out"> in the rest of the stylesheet -->

  <!-- if @name = Inputs, make it a link -->
  <xsl:template match="HSDataContainerType[contains(@name, 'Inputs')]">
  [...take the rest from your stylesheet...]





Notes:
-  you can use [contains(@name, 'Inputs'] instead of [@name='inputs'],
   if the name attribute may contain something like 'MyInputsVariant' in
   some of your XML data.
   Otherwise the latter is preferable.

-  // in match attributes is not needed.
   Use match="HSString" instead of match="//HSString"

-  You don't use <xsl:call-template ...> in your stylesheet, so you don't
   need name attributes in your templates (debugging stuff?).


Regards,
Markus
__________________________
Markus Abt
Comet Computer GmbH
http://www.comet.de


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


Current Thread