Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 28th, 2006, 05:54 PM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default create an index

Hi all, I am slowly learning XSLT and I am trying to build an index.html (with links) file from 2 xml file with the same schema.
xml files:

test1.xml
test2.xml

output names:

test1.html
test2.html


The xml element is:
<indexterm> with an attribute @id

can any one help?

Thanks
 
Old July 29th, 2006, 03:33 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

It's difficult to help without knowing where you are hitting difficulties. Start by simplifying the problem down to its essence, show us a simple input and output that you want to achieve, and show us your first attempt at solving it - however inadequate, this lets us know how far you can get without help.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old July 29th, 2006, 05:45 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

Michael,

Thank you for your reply. Actually I picked up XSLT 2. (3rd addition) and its been very helpful. I was able to creat e a TOC for my XML project. Now i am stuck on the index.
Taking this example http://www.xml.com/cookbooks/xsltckb...tion.csp?day=1 I am trying to apply it to my xml files.

Here is some info on the XML element "indexterm"

it has two attributes @id and @name. I am using the @id for cross referencing later.

Thanks for the help.



This is what I have so far

Code:
<xsl:stylesheet version="1.0"   
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:saxon="http://icl.com/saxon" 
 extension-element-prefixes="saxon">

<xsl:output method="html"/>

<xsl:template match="/">
  <xsl:apply-templates select="*" mode="index"/>
  <xsl:apply-templates select="*" mode="content"/>
</xsl:template>




<xsl:template match="JBU:indexterm" mode="index">
  <saxon:output href="index.html">     
    <html>
     <head>
       <title>Index</title>
     </head>

     <body bgcolor="#FFFFFF" text="#000000">
      <h1>Index</h1>
      <xsl:apply-templates mode="index"/>
     </body>
    </html>
  </saxon:output>
</xsl:template>

<xsl:template match="JBU:indexterm" mode="index">
  <h2>
    <a href="{concat(@name,'.html')}">
      <xsl:value-of select="@id"/>
    </a>
  </h2>
</xsl:template>





<xsl:template match="JBU:indexterm" mode="content">
  <saxon:output href="{@name}.html">     
    <html>
     <head>
        <title><xsl:value-of select="@id"/> Sales</title>
     </head>

     <body bgcolor="#FFFFFF" text="#000000">
      <h1><xsl:value-of select="@id"/> Sales</h1>
      <ol>
          <xsl:apply-templates mode="content"/>
      </ol>
     </body>
    </html>
  </saxon:output>
</xsl:template>

</xsl:stylesheet>
 
Old July 29th, 2006, 05:55 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

oh I almost forgot. The desired outcome is a book type index:

A

[u]Aircraft</u>
[u]Airplane</u>

B.

Books

and so on....

The index.html is a seperate file. They would hyperlink to the HTML file. I will have about 35 manuals in our system and I want to build a single index file for all manuals. So the xsl would scan all the xml files for the indexterms, I would know the HTMl outputs for all the manuals.

 
Old July 29th, 2006, 07:17 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

on a quick note, this is exactly what I am trying to achieve:

http://www.gca.org/papers/xmleurope2...dex/keywd.html

once again thanks for the help.

 
Old July 31st, 2006, 08:14 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

Hi all,

If at all posssible, can someone point me in some direction with this. I am under a timeline.I am starting to sweat!

Thanks again

Bones






Similar Threads
Thread Thread Starter Forum Replies Last Post
Create generic XSL Template to create table Venkatachalapathy XSLT 5 March 11th, 2008 07:49 AM
Index carumuga SQL Server 2000 1 December 31st, 2007 12:42 PM
Index with Pagenumbers alleycat XSLT 0 March 15th, 2006 10:53 AM
How to Create Index in Access Database using ASP ramk_1978 Classic ASP Databases 1 November 8th, 2004 12:43 PM
create unique index junemo MySQL 6 September 22nd, 2004 05:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.