English 中文(简体)
XLST, 在由此产生的超文本文件中插入“超声波”
原标题:XLST to insert HTML snippet into resulting HTML document
  • 时间:2011-10-12 11:19:23
  •  标签:
  • xslt
  • docbook

I have a docBook 4.4 XML file which is a user guide. I can use the (Maven) tools to convert that to HTML, PDF no problem. The problem i have is to insert an small HTML code snippet into the resulting HTML file.

我愿补充如下文HTML:

<xsl:template name="xxxxxxx">
  <img src="images/pdfdoc.gif">PDF</img>
</xsl:template>

由此形成的“超文本”守则就是这样:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Title</title>
<link rel="stylesheet" type="text/css" href="./hilfeKMV.css">
<meta name="generator" content="DocBook XSL Stylesheets V1.76.0">
<meta name="date" content="10/12/2011">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084"
    alink="#0000FF">
    <div lang="de" class="book"
        title="Title">
        <div class="titlepage">
            <div>
                <div>
                    <h1 class="title">
                        <a name="d0e1"></a>title
                    </h1>
                </div>
            </div>
            <hr>
        </div>
        <div class="toc">
            <p>
                <b>TOC</b>
            </p>

I would like to insert the HTML snippet before the <div class="toc">...So the question is how to solve this? I m using docbook 1.76.0 I think there must be something like the following to solve that but i don t know how to set call-template etc. ?

   <xsl:template name="xxxxxxx">
      <xsl:variable name="top-anchor">
        <xsl:call-template name="object.id">
          <xsl:with-param name="object" select="/*[1]"/>
        </xsl:call-template>
      </xsl:variable>
      <img src="images/pdfdoc.gif">PDF</img>
    </xsl:template>
最佳回答

I have found the correct location to insert the code i need. In the titlepage.templates.xsl file i found the correct solution. I just taken the snippet from the titlepage.templates.xsl and enhanced it like the following:

<xsl:template name="book.titlepage.separator">
    <div class="subsubtile">
        <div class="pdflink">
            <a href="./xxxx.pdf" title="Hilfeseite als PDF-Dokument">
                <img src="images/pdfdoc.gif" border="0" alt="Hilfeseite als PDF-Dokument" />
                <br />
                PDF
            </a>
        </div>
    </div>
    <hr/>
</xsl:template>
问题回答

The <div class="toc"> element is generated by the template named "make.toc", which is called by "division.toc" (in autotoc.xsl). In order to output something immediately before this <div>, you can override the "division.toc" template in your customization layer. Just copy the original template and add your code, like this:

<xsl:template name="division.toc">
  <xsl:param name="toc-context" select="."/>
  <xsl:param name="toc.title.p" select="true()"/>

  <img src="images/pdfdoc.gif" alt="PDF"/>    <!-- Your stuff here -->

  <xsl:call-template name="make.toc">
    ...
    ...
  </xsl:call-template>
</xsl:template>




相关问题
When test hanging in an infinite loop

I m tokenising a string with XSLT 1.0 and trying to prevent empty strings from being recognised as tokens. Here s the entire function, based on XSLT Cookbook: <xsl:template name="tokenize"> ...

quick xslt for-each question

Let s say I have an XML document that has this: <keywords> <keyword>test</keyword> <keyword>test2</keyword> <keyword>test3</keyword> <keyword>test4</...

XSLT Transform XML with Namespaces

I m trying to transform some XML into HTML using XSLT. Problem: I can t get it to work. Can someone tell me what I m doing wrong? XML: <ArrayOfBrokerage xmlns:i="http://www.w3.org/2001/...

XSLT output to HTML

In my XSLT file, I have the following: <input type="button" value= <xsl:value-of select="name">> It s an error as it violates XML rule. What I actually want is having a value from an ...

Mangling IDs and References to IDs in XML

I m trying to compose xml elements into each other, and the problem I am having is when there s the same IDs. Basically what I need to do is mangle all the IDs in an xml file, as well as the ...

Sharepoint 2007 Data view Webpart custom parameters

I m sort of new to the custom parameters that can be setup on a DataView Webpart. There are 6 options: - None - Control - Cookie - Form - QueryString - Server Variable I think that None, Cookie and ...

热门标签