[KLUG Members] XSLT Transforms

Justin Buist members@kalamazoolinux.org
Thu, 9 Jan 2003 18:32:19 -0500


I just went through some of my old XSL work here, as I'm sure I ran into
this same problem 2 years ago when I last did it :).  What I found was this:

    <xsl:template match="/graphics-text-list">
	<xsl:variable name="pgCnt">
	        <xsl:value-of select="count(graphic-text)"/>
    </xsl:variable>
	<!-- some HTML formatting to begin the page -->
	        <!-- if there is no graphics print a message -->
		    <xsl:if test="count(graphic-text) = 0">
				<!-- message here -->
			</xsl:if>
	... more templates.


If you put in a similar check under the <customer> tag, and reversed the
conditional you'd be able to output the OEM header inside the <customer> tag,
if and only if oem info existed below it.  Then just apply your closing footer
at the end of the apply-template with the same conditonal check.

I guess the only error in your thinking is that it would go in the OEM data
tag and not the customer tag... if you could call that an error.  There
probably is a way to do it from within the OEM tag, but I found it easiest
to do it in the parent element rather than the child.

Hope that helps.  If you want I could try and send you the whole .xsl file
but I'm not even sure if I have a valid .xml file to run it against.  I could
try and dig one up though.

Justin Buist