Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Is this possible in XSL?

From: "Marrow" <m--a-r-r-o-w@--------------------.--->
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




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent