[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] AW: intra document link
Hm...first of all thanks for your answer. But I have a little problem ;-) your solution does not work with my setup. IE and even Mozilla couldn't find the anchor's id destination. The anchor looks like this: file:///path/id. I'm trying to make a dynamic approach on client/browser side. Do I have to make a static serverside compilation/transformation? Best regards, Nick |-----Ursprüngliche Nachricht----- |Von: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl- |list@xxxxxxxxxxxxxxxxxxxxxx] Im Auftrag von G. Ken Holman |Gesendet: Donnerstag, 19. Februar 2004 02:29 |An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx |Betreff: Re: intra document link | |At 2004-02-18 22:50 +0100, Nikolas Nehmer wrote: |>Hi, sorry it's me again. | |No need to apologize! | |>I'm looking for a possibility of intra document links with xhtml. For |>better imagination a little example: |>... |> <iese.Chapter:Chapter> |> <iese.Chapter:heading>Kapitel |>1</iese.Chapter:heading> |>... |>For each chapter I would like to create a link, for |>example a href to that chapter. When you klick that link the |>visualisation for that Chapter should be displayed (e.g a table again). |>Creating the visualisation is not my problem, but I don't know if there |>is way to build those intra document links! Are there any possibilities, |>any suggestions? | |Absolutely ... the designers of XSLT provided for just this. | |>I frist thought about declaring an ID attribute for any |>chapter but I don't know if I can point to that ID by html hrefs. | |Yes, you could do that, but it is not necessary in XSLT. | |Every node in every tree created for an XSLT process (all source trees and |the stylesheet tree) is assigned a generated unique identifier. This |identifier is an opaque value that is used in its entirety and is defined |by the processor in any fashion it wishes, provided that the identifier |lexically matches an XML NCName. | |NCNames can, therefore, be used in HTML anchors as names and hrefs. | |You ask the processor for a node's generated identifier using the function |generate-id(nodeAddress) and every time you ask for that node's identifier |in a given run of a stylesheet, you get the same value back. It may or may |not be the same value the next time you run the stylesheet, so you cannot |rely on any persistence so you cannot expect an identifier generated for a |node in one run will be the same in the next run. | |You take advantage of these generated identifiers to synthesize ID/IDREF |relationships, not only where there are no ID values available, but I have |learned through experience it is safest to use generated identifiers even |for nodes that have ID values (this protects from ambiguities when dealing |with multiple source trees with ID values in each). | |When you process your chapter table of contents, you utilize the chapter's |generated identifier in the href= attribute. To ensure there is something |to point to when you process your chapter, you utilize the chapter's |generated identifier in the name= attribute. The resulting file has |resolved HTML hyperlinks from your TOC to your body. | | <!--TOC--> | <xsl:for-each select="b:Book/b:chapters/iese.Chapter:Chapter"> | <li> | <a href="{generate-id(.)}"> | <xsl:value-of select="iese.Chapter:heading"/> | </a> | </li> | </xsl:for-each> | ... | <!--Body processing--> | <xsl:for-each select="b:Book/b:chapters/iese.Chapter:Chapter"> | <h3> | <a name="{generate-id(.)}"> | <xsl:value-of select="iese.Chapter:heading"/> | </a> | </h3> | <!--rest of chapter processing--> | </xsl:for-each> | |I hope this helps. | |............................. Ken | |p.s. I am teaching XSLT/XPath/XSL-FO in May in Bremen ... if you could |please help spread the word to any local XML user groups, it would be |greatly appreciated; thanks! | |-- |Public courses: upcoming world tour of hands-on XSL training events |Each week: Monday-Wednesday: XSLT/XPath; Thursday-Friday: XSL-FO |Washington, DC: 2004-03-15 San Francisco, CA: 2004-03-22 |Hong Kong: 2004-05-17 Germany: 2004-05-24 England: 2004-06-07 |World-wide on-site corporate, government & user group XML training! | |G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx |Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ |Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) |Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc | | | XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|