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 October 21st, 2003, 01:53 PM
Registered User
 
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default converting cross refs between HTML documents

I'm trying to use XSLT to convert an XML book into multiple HTML files, and I'm having an issue with cross references betweent the files.

The book is made up of multiple chapters, and I'm outputting each chapter as a separate HTML file-- chapter 1 is output as ch_1.html, and so on--using <xsl:number>. Within the chapters are Xref elements with an id attribute. I can create the text of the cross reference just fine:

<a href="#{@Target}">See <xsl:value-of select="id(@Target)/Head"/></a>

This works just fine for xref destinations within the same HTML file. The problem is that for a destination in a different HTML file, I can't figure out how to get the filename of the HTML file in the hypertext link. The Xref elementsare descendants of the Chapter element, but they aren't immediate children, and the number of elements between the Chapter and the Xref elements can vary.

Any ideas how I can get the destination filename in the hypertext link?

FYI, the DTD looks like this:

<!ELEMENT Manual (Chapter+)>
<!ELEMENT Chapter (title, Section*)>
<!ELEMENT Section (Head, Body*, Section*)>
<!ATTLIST Section Id #IMPLIED>
<!ELEMENT Body (#PCDATA | Xref)*>
<!ELEMENT Xref Empty>
<!ATTLIST Xref Target IDREF #REQUIRED
                        format CDATA #IMPLIED>
 
Old October 22nd, 2003, 12:21 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 147
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to armmarti
Default

Try this:

Code:
<a href="ch_{count(id(@Target)/ancestor::Chapter[1]/preceding-sibling::*)+1}.html#{@Target}">See <xsl:value-of select="id(@Target)/Head"/></a>
Regards,
Armen
 
Old October 22nd, 2003, 11:00 AM
Registered User
 
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You're a genius--that worked perfectly. Thanks!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting PDF to HTML sunil.konduri C# 2005 1 July 11th, 2008 07:34 AM
converting from html to aspx sss22 ASP.NET 1.0 and 1.1 Basics 1 February 2nd, 2006 05:48 AM
converting self-nested xml to html its_vippy XSLT 1 June 1st, 2005 04:47 AM
Appending HTML documents to a Crystal Report hangar18 Crystal Reports 0 February 7th, 2005 04:48 AM
Q. PHP and HTML documents standards compliance richard.york PHP FAQs 0 June 28th, 2004 09:33 PM





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