[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Attribute Names of the longest branch (Creating CSV data

Subject: RE: Attribute Names of the longest branch (Creating CSV data)
From: "Steve Brown" <prospect@xxxxxxxxxxx>
Date: Wed, 12 Apr 2000 09:18:49 +1000
xsl csv attribute
As my data is going to be output to a text file (not html) I dont use a
table element.  If you are outputing to a table well you'll need to change
the code a little.

As for the header file I have come up with something which is very kludgy
but works for me.  It assumes that the depth of your data goes no more than
7 levels down though:

<xsl:template match="*" mode="headercreator">
		<xsl:choose>
			<xsl:when test="*[*/*/*/*/*/*]"><xsl:apply-templates
select="*[*/*/*/*/*/*]" mode="headers" /></xsl:when>
			<xsl:when test="*[*/*/*/*/*]"><xsl:apply-templates select="*[*/*/*/*/*]"
mode="headers" /></xsl:when>
			<xsl:when test="*[*/*/*/*]"><xsl:apply-templates select="*[*/*/*/*]"
mode="headers" /></xsl:when>
			<xsl:when test="*[*/*/*]"><xsl:apply-templates select="*[*/*/*]"
mode="headers" /></xsl:when>
			<xsl:when test="*[*/*]"><xsl:apply-templates select="*[*/*]"
mode="headers" /></xsl:when>
			<xsl:when test="*[*]"><xsl:apply-templates select="*[*]" mode="headers"
/></xsl:when>
			<xsl:when test="*"><xsl:apply-templates select="*" mode="headers"
/></xsl:when>
			<xsl:otherwise/>
		</xsl:choose>
</xsl:template>


<xsl:template match="@*"><xsl:value-of select="."/>,</xsl:template>

<xsl:template match="*">
	<xsl:param name="sofar"></xsl:param>
	<xsl:param name="concat"><xsl:value-of
select="$sofar"/><xsl:apply-templates select="@*" /></xsl:param>
	<xsl:apply-templates><xsl:with-param name="sofar"
select="$concat"/></xsl:apply-templates>
	<xsl:if test="count(*) = 0">
		<xsl:value-of
select="substring(string($concat),0,string-length(string($concat)))"/><xsl:t
ext>&#10;</xsl:text>
	</xsl:if>
</xsl:template>


<xsl:template match="@*" mode="headers"><xsl:value-of
select="name()"/>,</xsl:template>

<xsl:template match="*" mode="headers">
	<xsl:param name="sofar"></xsl:param>
	<xsl:param name="concat"><xsl:value-of
select="$sofar"/><xsl:apply-templates select="@*"
mode="headers"/></xsl:param>
	<xsl:apply-templates select="*[position()=1]"
mode="headers"><xsl:with-param name="sofar"
select="$concat"/></xsl:apply-templates>
	<xsl:if test="count(*) = 0">
		<xsl:value-of
select="substring(string($concat),0,string-length(string($concat)))"/><xsl:t
ext>&#10;</xsl:text>
	</xsl:if>
</xsl:template>


pretty ugly isnt it!  Still I cant come up with anything better at the
moment.  I have no idea how it would perform under any significant load
either.  Hopefully someone will give me a better solution but until then...

Hope this helps,

Steve


-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxx]On Behalf Of Selva, Francis
Sent: Wednesday, 12 April 2000 3:37
To: 'xsl-list@xxxxxxxxxxxxxxxx'
Subject: RE: Attribute Names of the longest branch (Creating CSV data)



> To make the data I used the following templates (among others).  If you
can
> see any holes/problems please tell me:

> 		<xsl:value-of
> select="substring(string($concat),0,string-length(string($conc
> at)))"/><xsl:t
> ext>&#10;</xsl:text>
> 	</xsl:if>
> </xsl:template>
>
> Steve.



Steve,
   It looks good.The only tag it requires is a <table> since the format is a
table format which ofcourse is not a problem or hole :) .So did u find a way
to display the title or u still working on it.Im working on it right now.

Thanx,
Francis











*****************************************************
The woods are lovely,dark and deep.
But I have promises to keep,
And miles to go before I sleep
And miles to go before I sleep.
*****************************************************


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


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.