RE: Re: [xsl] creating sequence diagrams for stylesheets

Subject: RE: Re: [xsl] creating sequence diagrams for stylesheets
From: "McNally, David" <David.McNally@xxxxxxxxxx>
Date: Mon, 25 Feb 2002 13:00:09 -0500
> A tree could look like this  (hope it comes out right!):
> 
> root
> |
> -child
>  |
>  - child 2
> -child
> 
> and so on.
> 
> I know I could write that easily, but I am soooo lazy :-) and 
> I bet it does already exist!
> 

How's this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
	<xsl:output method="text" indent="no"/>
	
<xsl:variable name="nl"><xsl:text>
</xsl:text></xsl:variable>
	
<xsl:template match="*">
	<xsl:variable name="name" select="name(.)"/>
	<xsl:variable name="indent">
		<xsl:for-each select="ancestor::*">
			<xsl:text>   |</xsl:text>
		</xsl:for-each>
	</xsl:variable>
	<xsl:value-of select="concat($nl,$indent,'-')"/>
	<xsl:value-of select="name(.)"/>
	<xsl:choose>
		<xsl:when test="child::*">
			<xsl:value-of select="concat($nl,$indent,'   |')"/>

			<xsl:apply-templates/>
			<xsl:value-of select="concat($nl,$indent)"/>

		</xsl:when>
		<xsl:otherwise>
			<xsl:apply-templates/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template match="text()"></xsl:template>

</xsl:stylesheet>

This stylesheet's tree is:

-xsl:stylesheet
   |
   |-xsl:output
   |-xsl:variable
   |   |
   |   |-xsl:text
   |
   |-xsl:template
   |   |
   |   |-xsl:variable
   |   |-xsl:variable
   |   |   |
   |   |   |-xsl:for-each
   |   |   |   |
   |   |   |   |-xsl:text
   |   |   |
   |   |
   |   |-xsl:value-of
   |   |-xsl:value-of
   |   |-xsl:choose
   |   |   |
   |   |   |-xsl:when
   |   |   |   |
   |   |   |   |-xsl:value-of
   |   |   |   |-xsl:apply-templates
   |   |   |   |-xsl:value-of
   |   |   |
   |   |   |-xsl:otherwise
   |   |   |   |
   |   |   |   |-xsl:apply-templates
   |   |   |
   |   |
   |
   |-xsl:template


Hope this helps,
David.
--
David McNally            Moody's Investors Service
Software Engineer        99 Church St, NY NY 10007 
David.McNally@xxxxxxxxxx            (212) 553-7475 



---------------------------------------

The information contained in this e-mail message, and any attachment thereto, is confidential and may not be disclosed without our express permission.  If you are not the intended recipient or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution or copying of this message, or any attachment thereto, in whole or in part, is strictly prohibited.  If you have received this message in error, please immediately notify us by telephone, fax or e-mail and delete the message and all of its attachments.  Thank you.

Every effort is made to keep our network free from viruses.  You should, however, review this e-mail message, as well as any attachment thereto, for viruses.  We take no responsibility and have no liability for any computer virus which may be transferred via this e-mail message.

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


Current Thread