Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Is this possible in XSL? >Thread Next - Re: Is this possible in XSL? Re: Is this possible in XSL?To: NULL Date: 10/2/2004 3:42:00 PM Hi,
Yes, it's possible.
You might be as well to use the generate-id() function for the a ref names,
something like...
using well-formed example XML...
<?xml version="1.0"?>
<root>
<target name="one">
<task>
<message> Some Message Text1 </message>
<message> Some Message Text2 </message>
</task>
<task>
<message> Some Message Text3 </message>
</task>
</target>
<target name="two">
<task>
<message> Some Message Text1 </message>
</task>
</target>
</root>
a stylesheet something along the lines of...
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:template match="root">
<html>
<body>
<!-- make header links -->
<xsl:for-each select="target">
<a href="#{generate-id()}">
<xsl:value-of select="@name"/>
</a>
<br/>
</xsl:for-each>
<hr/>
<!-- show the targets, tasks and messages -->
<xsl:apply-templates select="target"/>
</body>
</html>
</xsl:template>
<xsl:template match="target">
<a name="{generate-id()}"/>
<h3>
<xsl:text>Target: </xsl:text>
<xsl:value-of select="@name"/>
</h3>
<!-- show the messages -->
<xsl:apply-templates select="task"/>
</xsl:template>
<xsl:template match="task">
<h4>
<xsl:text>Task: </xsl:text>
<xsl:number count="task"/>
</h4>
<xsl:apply-templates select="message"/>
</xsl:template>
<xsl:template match="message">
<span>
<xsl:text>message: </xsl:text>
<xsl:value-of select="."/>
</span>
<br/>
</xsl:template>
</xsl:stylesheet>
HTH
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator
"Prabh" <Prab_kar@h...> wrote in message
news:e7774537.0409301222.6008f6e7@p......
> Hello all,
> I'm a newbie to the world of XML, XSL stylesheets and transformation
> etc. and wonder if the following is possible?
>
> I have an XML file of the following sort and I want to HTML-ize it
> using an XSL.
>
> XML:
>
> ==========================================================
> <target name="one">
> <task>
> <message> Some Message Text1 </message>
> <message> Some Message Text2 </message>
> </task>
>
> <task>
> <message> Some Message Text3 </message>
> </task>
> </target>
>
> <target name="two">
> <task>
> <message> Some Message Text1 </message>
> </task>
> </target>
>
> and so on.
> =========================================================
>
> After transformation, in my .html file, I'd like to create a top-area
> of just the target names and clicking on the links would get me to
> their details (i.e., the tasks and messages info) somewhere down
> below.
>
> Something along the lines...
>
> <a href="#TargetOneInfo"> Target One </a>
> <a href="#TargetTwoInfo"> Target Two </a>
> .
> .
> .
> <a name="TargetOne"> Target One Details </a>
> <a name="TargetTwo"> Target Two Details </a>
> and so on.
>
> Is it possible to achieve this in XSL?
> How do I specify in XSL to collect all 'targets' and put the href tags
> around them and similarly put the name tags around the details
> section?
> Could someone please give me some pointers on how to go about doing
> this?
>
> Thanks for your time,
> Prabh
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
