This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Attribute Names of the longest branch (Creating CSV data)
- To: <xsl-list at mulberrytech dot com>
- Subject: RE: Attribute Names of the longest branch (Creating CSV data)
- From: "Steve Brown" <prospect at flex dot com dot au>
- Date: Wed, 12 Apr 2000 09:18:49 +1000
- Reply-To: xsl-list at mulberrytech dot com
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> </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> </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@mulberrytech.com
[mailto:owner-xsl-list@mulberrytech.com]On Behalf Of Selva, Francis
Sent: Wednesday, 12 April 2000 3:37
To: 'xsl-list@mulberrytech.com'
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> </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