[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

generate ePub Toc by XSLT

Subject: generate ePub Toc by XSLT
From: "J. S. Rawat" <jrawat@xxxxxxxxxxxxxx>
Date: Mon, 19 Jan 2009 12:24:33 +0530
 generate ePub Toc by XSLT
Dear Experts!!
As we all know that XML is the single solution for multiple problems in the field of publishing. We can generate multiple formats from single source and XSL is right choice to develop them. International Digital Publishing Forum (formerly Open eBook Forum) has introduced a new format i.e. ePub. In order to generate TOC, we have certain rules which are shown in the required output. I have started to writing a template with the help of my previous post but it seems that xslt is letting me down in some areas like sequence generation, extracting inner level sections etc. I am clueless as I am already very weak to handling feature like key, collection, regex etc. Any help in this direction is highly appreciable!!!


Rules
ABC (folder)
  a.xml
  b.xml
  n.xml

1. Read the file folder ABC
2. Process each each XML one by one
   A. Process a.xml
      i. Extract article head
      ii. Extract first level head
   B. Process b.xml
      i. Extract article head
      ii. Extract first level head
   N. Process nth.xml
      i. Extract article head
      ii. Extract first level head
3. Generate order sequence


XSL
<xsl:variable name="file-collection" select="collection(concat(abc,'abc/?select=*.xml;recurse=yes'))" />
<xsl:template match="/">
<navMap>
<navLabel><text>Table of Contents</text></navLabel>
<xsl:for-each select="$file-collection">
<navPoint class="chapter" id="" playOrder="">
<navLabel><text><xsl:value-of select="./doc//ti[@t='d']"/></text></navLabel>
<content>
<xsl:call-template name="source">
<xsl:with-param name="filename"><xsl:value-of select="tokenize(document-uri(.), '/')[last()]"/></xsl:with-param>
</xsl:call-template>
</content>
<navPoint class="section1" id="" playOrder="">
<navLabel><text><xsl:value-of select="./doc//sc1"/></text></navLabel>
<content>
<xsl:call-template name="source">
<xsl:with-param name="filename"><xsl:value-of select="tokenize(document-uri(.), '/')[last()]"/></xsl:with-param>
</xsl:call-template>
</content>
</navPoint>
</navPoint>
</xsl:for-each>
</navMap>
</xsl:template>


OUTPUT REQUIRED
<navMap>
<!-- ID and playOrder should be in sequence -->
<navPoint class="chapter" id="id1" playOrder="1">
<navLabel><text>Article head of A.xml</text></navLabel>
<content src="a.htm"/>
<navPoint class="section1" id="id2" playOrder="2">
<navLabel><text>Head 1: First level heading of A.xml (first head)</text></navLabel>
<content src="a.htm#sec1"/>
</navPoint>
<navPoint class="section1" id="id3" playOrder="3">
<navLabel><text>Head 1: First level heading of A.xml (second head)</text></navLabel>
<content src="a.htm#sec2"/>
</navPoint>
</navPoint>
<navPoint class="chapter" id="id4" playOrder="4">
<navLabel><text>Article head of B.xml</text></navLabel>
<content src="B.htm"/>
<navPoint class="section1" id="id5" playOrder="5">
<navLabel><text>Head 1: First level heading of B.xml (first head)</text></navLabel>
<content src="b.htm#sec1"/>
</navPoint>
<navPoint class="section1" id="id6" playOrder="6">
<navLabel><text>Head 1: First level heading of A.xml (second head)</text></navLabel>
<content src="b.htm#sec2"/>
</navPoint>
</navPoint>
...
</navMap>


Thanks in advance !!!
...JSR

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.