Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xsl:fo help with creating different types of internal links

Status
Not open for further replies.

smillieha

Technical User
Aug 24, 2007
7
US
I am trying to modify an stylesheet so that if will handle 3 different types of internal links in a pdf document. The pdf document is made up of several smaller documents.

here are excerpts from the xml:
<!--links to para within document-->
<xref xidtype="para" xrefid="par-0001">A</xref>

<!--links to another document-->
<xref xidtype="other" xlink:href="docname">A</xref>

<!--links to para within another document-->
<xref xidtype="other" xlink:href="docname#par-0001">A</xref>

I know the following xsl works for linking from one document to another:
<xsl:template match="xref" mode="PageBody">
<fo:basic-link internal-destination="{concat(@xlink:href,'_page')}">
<xsl:value-of select="."/>
</fo:basic-link>
</xsl:template>


Here's my xsl attempt to address all 3 types of internal links, it doesn't work:

<xsl:template match="xref" mode="PageBody">
<xsl:variable name="link">
<xsl:if test="contains(@xlink:href,'#')">
<xsl:value-of select="replace(@xlink:href,'#','_')"/>
</xsl:if>
<xsl:if test="not(contains(@xlink:href,'#'))">
<xsl:value-of select="@xlink:href"/>
</xsl:if>
</xsl:variable>
<xsl:if test="@xlink:href">
<fo:basic-link internal-destination="{concat($link,'_page')}">
<xsl:value-of select="."/>
</fo:basic-link>
</xsl:if>
<xsl:if test="@xrefid">
<fo:basic-link internal-destination="{concat($module-code,'_',@xrefid)}">
<xsl:value-of select="."/>
</fo:basic-link>
</xsl:if>
</xsl:template>

appreciate any help.
 
>it doesn't work
In what sense? You are using replace() function. The xsl-stylesheet "version" attribute should be "2.0". Is it so?
 
tsuji,

I am using a system that publishes a publication list of xml files using Altsoft's xml2pdf. When the system is done processing the publication list the only xml files that have been published in pdf are the files that do not use the <xref>.

The xsl-stylesheet version is 1.0.

thanks,
Heather
 
What I meant is that replace() is a xslt2 function. Hence, for xslt1 engine, it will not recognize it. Hence, I would say either try:
[tt] <xsl:stylesheet version="[blue]2.0[/blue]"[/tt] ...
or replace the line.
[tt] [red]<!--[/red] <xsl:value-of select="replace(@xlink:href,'#','_')"/> [red]-->[/red][/tt]
[tt] <xsl:value-of select="[blue]translate[/blue](@xlink:href,'#','_')"/>[/tt]
 
I tried both suggestions but am still having issues. Any other suggestions.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top