Re: [xsl] XSLT for XSL-FO internal-destination

Subject: Re: [xsl] XSLT for XSL-FO internal-destination
From: Robert Siebens <telehodown@xxxxxxxxx>
Date: Fri, 20 Nov 2009 11:14:31 -0800 (PST)
David,

I'm still not quite clear about how to connect the id from the href to the id
at the heading of each page. Just to clarify, here is a simplified stylesheet
(test.xsl), XML table of contents page (text.xml), and two XHTML source files
(file_one.htm and file_two.htm). I'm calling the text.xml file that points to
the file_one.htm and file_two.htm source files.

For the purposes of this example, I've moved all the files into the same
directory, but is the purpose of the translate function merely to remove
special characters the directory path in order to create an id? If so, perhaps
it's not necessary in this latest example:

--------------------
test.xsl
--------------------

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                xmlns:fo="http://www.w3.org/1999/XSL/Format";>

<xsl:template match="/">
   <fo:root>
	  <fo:layout-master-set>

    <!-- Simple Page Master for body -->
    <fo:simple-page-master
    	master-name="only"
    	page-height="29.7cm"
    	page-width="15cm"
    	margin-top="1cm"
    	margin-bottom="2cm"
    	margin-left="1cm"
    	margin-right="1cm">
        	<fo:region-body
        		   region-name="xsl-region-body"
        		   margin="2cm" />
        	<fo:region-before
        		   region-name="xsl-region-before"
        		   extent="3cm"
        			display-align="before" />
        	<fo:region-after region-name="footer" extent="0.5in"/>
        	<fo:region-start
        			region-name="xsl-region-start"
        			 extent="2cm"/>
        	<fo:region-end
        			region-name="xsl-region-end"
        			 extent="2cm"/>
    </fo:simple-page-master>
    </fo:layout-master-set>

    <!-- Page sequence for body pages -->
	<fo:page-sequence master-reference="only" format="1">
    	     <fo:static-content flow-name="footer">
                <fo:block text-align="center">
                   <fo:page-number/>
                 </fo:block>
            </fo:static-content>
              <fo:flow flow-name="xsl-region-body">
                   <fo:block>
                        <xsl:for-each select="//TocEntry">
                         <!--Added id here for each page -->
                                      <fo:block id="{@Link}"/>
                            <xsl:for-each select="document(@Link)//body">
                              <xsl:apply-templates/>
                            </xsl:for-each>

                        </xsl:for-each>
                         <fo:inline keep-together.within-line="always"/>
                   </fo:block>
              </fo:flow>
   </fo:page-sequence>
</fo:root>
</xsl:template>

<xsl:template match="p|P">
    <fo:block
      font-family="Arial"
      font-size="10pt"
      space-before="12pt"
      space-after="12pt"
      text-align="justify">
		 <xsl:apply-templates/>
    </fo:block>
</xsl:template>

<xsl:template match="a|A">
   <fo:inline>
      <fo:basic-link color="blue">
              <xsl:attribute name="internal-destination">
                 <xsl:value-of select="translate(@href,':/','')"/>
                  <xsl:apply-templates />
              </xsl:attribute>
              <xsl:apply-templates/>
      </fo:basic-link>
    </fo:inline>
</xsl:template>

</xsl:stylesheet>

--------------------
test.xml (acts as a table of contents in online help)
--------------------
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>

<Toc
  Version="1">
    <TocEntry
      Title="file_one.htm"
      Link="file_one.htm" />
    <TocEntry
      Title="file_two.htm"
      Link="file_two.htm" />
</Toc>

--------------------
file_one.htm
--------------------
<?xml version="1.0" encoding="utf-8"?>
<html>
    <head>
       <title> </title>
    </head>
    <body>
        <p>Link example: <a href="file_two.htm">Link to file two. </a> </p>
    </body>
</html>

--------------------
file_two.htm
--------------------
<?xml version="1.0" encoding="utf-8"?>
<html>
    <head>
       <title> </title>
    </head>
    <body>
        <p>Text in file two. </p>
    </body>
</html>

Thanks,

Rob


--- On Fri, 11/20/09, David Carlisle <davidc@xxxxxxxxx> wrote:

> From: David Carlisle <davidc@xxxxxxxxx>
> Subject: Re: [xsl] XSLT for XSL-FO internal-destination
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Cc: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Date: Friday, November 20, 2009, 8:48 AM
>
>
> well you're leaving me to guess a lot about your uinput
> structure, but
> I'd guess that
>
>                
>    <fo:block id="{@href}">
>
>            
>         <xsl:for-each
> select="//TocEntry">
>            
>            
> <xsl:for-each select="document(@Link)//body">
>                
>            
>   <xsl:apply-templates/>
>
>
> just puts in a single id (with possibly empty value) at the
> top of teh
> document
> you want an id for each file inclusion so perhaps
>
>
>
>
>            
>         <xsl:for-each
> select="//TocEntry">
>                
>                
>       <fo:block id="{@Link}"/>
>            
>            
> <xsl:for-each select="document(@Link)//body">
>                
>            
>   <xsl:apply-templates/>
> David
>
> ________________________________________________________________________
> The Numerical Algorithms Group Ltd is a company registered
> in England
> and Wales with company number 1249803. The registered
> office is:
> Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United
> Kingdom.
>
> This e-mail has been scanned for all viruses by Star. The
> service is
> powered by MessageLabs.
> ________________________________________________________________________

Current Thread