RE: [xsl] ?Formating Issue?

Subject: RE: [xsl] ?Formating Issue?
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Tue, 4 Nov 2003 11:26:44 -0500
[SHEIKH Sajjad]Hi
> 
> Following is my xml.  I am looking for the output as [	
> You are here:
> Sajjad >>> Learning Material ] 
> 
> 
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <?xml-stylesheet type="text/xsl" href="4.xsl"?>
> <livelink>
> <location path='..\'>sajjad</location>  
> <location last='true' path=''>Learning Material</location>
> </livelink>  
> 
> I don't know where am I making mistake in the following stylesheet.
> Since I get Sajjad Learning Material in one line but I can 
> not add ">>>"
> sign to it.
> 

It looks like you want to build up the path display using the "location"
elements, although your template seems to be trying to build them from
"livelink" elements instead.  Is this correct, that you want to use
:location" elements?  If not, I cannot understand what you are trying to
do, although a larger sample of the xml source might help.

Here is a basic way to to it -

<xsl:template match='livelink'>
   <xsl:apply-templates select='location'/>
</xsl:template>

<xsl:template match='location'>
   <xsl:value-of select='.'/> >>>
</xsl:template>

Now this is a bit too simple to use as is.   First of all, you do not
want the ">>>" separator appear after the last step of the path.  So you
have to use a test to prevent it.  You could use

<xsl:template match='location'>
   <xsl:value-of select='.'/> <xsl:if test='position() != last()'> >>>
</xsl:if>
</xsl:template>

Next, you would add the href elements, and it should be pretty obvious
how to add them.  BTW, you probably want to use a forward slash in the
paths, even if you are on Windows.

Finally, you can add any formatting you want, such as wrapping the steps
in their own "td" elements (although this probably will not be that
useful and could be omitted).

Notice that there is no need to use for-each, just select the nodes that
you want and apply the corresponding template.  Of course, you could
succeed with for-each as well, but it is a bit cleaner and simpler to
just use a template instead.

Cheers,

Tom P

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


Current Thread