<xsl:choose>
  <xsl:when test="string-length(name) &gt; 5">
    <xsl:value-of select="substring(name, 1, 5)"/>...
  </xsl:when>
  <xsl:otherwise>
    <xsl:value-of select="name"/>
  </xsl:otherwise>
</xsl:choose>


yours
Christoph Gaffga
[EMAIL PROTECTED]


----- Original Message -----
From: "Niket Anand" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, May 28, 2002 7:15 AM
Subject: XSL function to handle String


> Hi Luca,
> last time you really helped me out from the following problem.Thanks for
> that.
> This time I want to use a function in XSL such that it takes two
parameters-
> string and length.
> such as
> showName(String name, int length)
> here I want to show name upto 5 character length, if name length is more
> than 5 character then show "....." after 5 character such as
> showName("Luca Morandini", 5)
> then it should show Luca....
> I want to handle it in XSL only but not in XSP. so please help me such
that
> I can use this type of function in XSL and pass name in run time.
> Can you send me an example for that?
> Thanks for that.
> Niket
> ----- Original Message -----
> From: "Luca Morandini" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Saturday, April 13, 2002 6:17 PM
> Subject: RE: making tree like structure using XML,XSP,XSL
>
>
> > Niket,
> >
> > here you are...
> >
> > SITEMAP.XMAP (fragment)
> > <map:pipeline>
> > <map:match pattern="hash.xml">
> > <map:generate src="documents/hashtable.xml"/>
> >      <map:transform src="stylesheets/hashtable.xsl"/>
> >      <map:serialize type="xml"/>
> > </map:match>
> > </map:pipeline>
> >
> > HASHTABLE.XML
> > <?xml version="1.0"?>
> > <page>
> > <entry id="1"  parentid="0"/>
> > <entry id="2"  parentid="0"/>
> > <entry id="3"  parentid="0"/>
> > <entry id="4"  parentid="0"/>
> > <entry id="5"  parentid="1"/>
> > <entry id="6"  parentid="1"/>
> > <entry id="7"  parentid="6"/>
> > <entry id="8"  parentid="7"/>
> > <entry id="11" parentid="5"/>
> > <entry id="9"  parentid="2"/>
> > <entry id="10" parentid="2"/>
> > <entry id="12" parentid="5"/>
> > </page>
> >
> > HASHTABLE.XSL
> > <?xml version="1.0"?>
> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> > version="1.0">
> >
> > <xsl:template match="page">
> >
> > <!-- Starts the tree -->
> > <xsl:element name="tree">
> >
> > <xsl:apply-templates/>
> >
> > </xsl:element>
> >
> > </xsl:template>
> >
> > <!-- Selects main branches -->
> > <xsl:template match="//entry[@parentid=0]">
> >
> > <xsl:call-template name="process-branch">
> > <xsl:with-param name="id"><xsl:value-of select="@id"/></xsl:with-param>
> > <xsl:with-param name="parentid"><xsl:value-of
> > select="@parentid"/></xsl:with-param>
> > </xsl:call-template>
> >
> > </xsl:template>
> >
> > <!-- Recursive function -->
> > <xsl:template name="process-branch">
> > <xsl:param name="id"/>
> > <xsl:param name="parentid"/>
> >
> > <xsl:choose>
> >
> > <!-- If element has no branches (i.e. is a leaf) -->
> > <xsl:when test="count(//entry[@parentid=current()/@id])=0">
> >
> > <!-- Writes the "leaf" element -->
> > <xsl:element name="leaf">
> > <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
> > </xsl:element>
> >
> >     </xsl:when>
> >
> > <!-- If element has branches -->
> >     <xsl:otherwise>
> >
> > <!-- Starts a "branch" element -->
> > <xsl:element name="branch">
> > <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
> >
> > <!-- For every branches of current branch -->
> > <xsl:for-each select="//entry[@parentid=current()/@id]">
> >
> > <!-- Recurse the branch processing -->
> > <xsl:call-template name="process-branch">
> > <xsl:with-param name="id"><xsl:value-of
> > select="@id"/></xsl:with-param>
> > <xsl:with-param name="parentid"><xsl:value-of
> > select="@parentid"/></xsl:with-param>
> > </xsl:call-template>
> >
> > </xsl:for-each>
> >
> > </xsl:element>
> >
> >     </xsl:otherwise>
> >
> > </xsl:choose>
> >
> > </xsl:template>
> >
> > </xsl:stylesheet>
> >
> > Best regards,
> >
> > ---------------------------------------------
> >                Luca Morandini
> >                GIS Consultant
> >               [EMAIL PROTECTED]
> > http://utenti.tripod.it/lmorandini/index.html
> > ---------------------------------------------
> >
> > -----Original Message-----
> > From: Niket Anand [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, April 12, 2002 5:13 PM
> > To: Niket Anand
> > Subject: making tree like structure using XML,XSP,XSL
> >
> >
> > Hi All,
> > I have one function that connect to database and retrive data in form of
> > Hashtable.
> > My Hashtable may be like this.
> > MsgID         ParentID
> > 1                    0
> > 2                    0
> > 3                    0
> > 4                    0
> > 5                    1
> > 6                    1
> > 7                    6
> > 8                    7
> > 9                    2
> > 10                  2
> > 11                  5
> > 12                  5
> >
> > Tree structure would be like this based on MsgID and ParentID
> > MsgID will be the Id of a tag and parentid is the id of the parent with
> > which it is linked.
> > 1(parent0)
> > |
> > |
> > -------5(child of 1)
> >         |
> >         |___11(child of 5)
> >         |
> >         |____12(child of 5 and sibling of 11)
> > ____6(child of 1 and sibling of 5)
> >         |
> >         |____7(child of 6)
> >                 |
> >                 |___8(child of 7)
> > 2(parent 2)
> > |
> > |____9(child of 2)
> > |
> > |____10(child of 2)
> >
> > 3(parent 3)
> >
> > 4(parent 4)
> > Like this I have to show dynamic tree like structure in HTML form.I am
> using
> > cocoon2.0
> > This can be either handled by XSP or XSL or both.
> > Please suggest me how to solve the recursive loop problem using XSL..
> > How can I apply logic to have dynamic tree structure building function
> based
> > on the values of Hashtable keys and values.
> > Pls suggest  ideas.
> > Thanks,
> > Niket
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <[EMAIL PROTECTED]>
> For additional commands, e-mail: <[EMAIL PROTECTED]>


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

Reply via email to