是否可以动态创建toc.js
,frameset.html
,frameset-nav.html
,graphicMap.xml
文件,就像使用我创建的自定义插件的html2基础插件一样,插件创建在以下链接
我已经创建了像这样的自定义xhtml插件
我的plugin.xml代码是
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file is part of the DITA Open Toolkit project.
See the accompanying license.txt file for applicable licenses.
-->
<plugin id="com.custom.xhtml">
<!-- extensions -->
<feature extension="dita.xsl.xhtml" file="xslhtml/map2xhtmtoc.xsl"/>
<feature extension="dita.xsl.xhtml" file="xslhtml/dita2xhtml.xsl"/>
<feature extension="dita.conductor.transtype.check" value="xhtml-custom" type="txt"/>
<feature extension="dita.conductor.target.relative" file="build.xml"/>
<!-- change value to match your custom transtype -->
</plugin>
build.xml代码是
<?xml version="1.0" encoding="UTF-8"?>
<project name="com.custom.xhtml">
<import file="build_transtype-custom.xml"/>
</project>
build_transtype-custom.xml是
<project name="xhtml-custom" default="dita2xhtml-custom">
<property name="transtype" value="xhtml-custom"/>
<target name="dita2xhtml-custom">
<echo>custom HTML transform</echo>
<!-- Set properties here -->
<condition property="args.xhtml.toc.xsl" value="${dita.plugin.com.custom.xhtml.dir}/xslhtml/map2xhtmtoc.xsl">
<not>
<isset property="args.xhtml.toc.xsl"></isset>
</not>
</condition>
<condition property="args.xhtml.toc" value="index">
<not>
<isset property="args.xhtml.toc"></isset>
</not>
</condition>
<antcall target="dita2xhtml"/>
</target>
</project>
然后我将基础插件xsl文件夹粘贴到自定义插件我已更改名为dita2xhtml.xsl的xsl
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="dita2html-base.xsl"/>
<xsl:output method="xml" encoding="UTF-8" indent="no"/>
<xsl:variable name="source-chars" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ .'"/>
<xsl:variable name="target-chars" select="'abcdefghijklmnopqrstuvwxyz__'"/>
<xsl:template match="task">
<div class="topic">
<xsl:attribute name="id">
<xsl:value-of select="attribute::id"/>
</xsl:attribute>
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="task/title">
<h1>Chapter <xsl:number count="task"/>. <xsl:apply-templates/><xsl:text> </xsl:text><script type="text/javascript" language="JavaScript" src="find5.js"><xsl:text>​</xsl:text></script></h1>
</xsl:template>
<xsl:template match="section">
<div class="section" id="{translate(title, $source-chars, $target-chars )}">
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="taskbody">
<div>
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="title">
<h2 class="sectiontitle">
<xsl:apply-templates/>
</h2>
</xsl:template>
<xsl:template match="p">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="steps">
<ol>
<xsl:apply-templates/>
</ol>
</xsl:template>
<xsl:template match="step">
<li>
<xsl:apply-templates/>
</li>
</xsl:template>
<xsl:template match="cmd">
<span>
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template match="b">
<strong>
<xsl:apply-templates/>
<xsl:text>​</xsl:text>
</strong>
</xsl:template>
<xsl:template match="menucascade">
<span class="menucascade">
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template match="uicontrol">
<span class="uicontrol">
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template match="filepath">
<span class="filepath">
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template match="xref">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="info">
<div>
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="i">
<em>
<xsl:apply-templates/>
</em>
</xsl:template>
<!-- Add both lang and xml:lang attributes -->
<xsl:template match="@xml:lang" name="generate-lang">
<xsl:param name="lang" select="."/>
<xsl:attribute name="xml:lang">
<xsl:value-of select="$lang"/>
</xsl:attribute>
<xsl:attribute name="lang">
<xsl:value-of select="$lang"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
然后更改xslhtml \ map2htmtoc文件夹中名为generate-toc的名为map2htmtocImpl.xsl的xsl模板,如下所示
仅完成模板更改
<xsl:template name="generate-toc">
<html style="overflow-y:auto"><xsl:value-of select="$newline"/>
<head><xsl:value-of select="$newline"/><title>Configuring Workflow</title><xsl:value-of select="$newline"/>
<xsl:value-of select="$newline"/>
<xsl:call-template name="generateDefaultCopyright"/>
<xsl:call-template name="generateCharset"/>
<xsl:if test="string-length($contenttarget)>0 and
$contenttarget!='NONE'">
<base target="{$contenttarget}"/>
<xsl:value-of select="$newline"/>
</xsl:if>
<!-- initial meta information -->
<!-- Set the character set to UTF-8 -->
<!-- Generate a default copyright, if needed -->
<xsl:call-template name="generateDefaultMeta"/> <!-- Standard meta for security, robots, etc -->
<xsl:call-template name="copyright"/> <!-- Generate copyright, if specified manually -->
<xsl:call-template name="generateCssLinks"/> <!-- Generate links to CSS files -->
<xsl:call-template name="generateMapTitle"/> <!-- Generate the <title> element -->
<xsl:call-template name="gen-user-head" /> <!-- include user's XSL HEAD processing here -->
<xsl:call-template name="gen-user-scripts" /> <!-- include user's XSL javascripts here -->
<xsl:call-template name="gen-user-styles" /> <!-- include user's XSL style element and content here -->
</head><xsl:value-of select="$newline"/>
<body>
<xsl:if test="string-length($OUTPUTCLASS) > 0">
<xsl:attribute name="class">
<xsl:value-of select="$OUTPUTCLASS"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="$newline"/>
<nav><xsl:value-of select="$newline"/>
<div xmlns:glossdata="http://dita4publishers.org/glossdata" xmlns:mapdriven="http://dita4publishers.org/mapdriven" xmlns:enum="http://dita4publishers.org/enumerables" class="dynamic-toc"><xsl:value-of select="$newline"/>
<div id="container" ><xsl:value-of select="$newline"/>
<div id="containerTop"><xsl:value-of select="$newline"/>
<div id="main"><xsl:value-of select="$newline"/>
<div id="content"><xsl:value-of select="$newline"/>
<form name="mainForm" action="javscript:;"><xsl:value-of select="$newline"/>
<div class="newsItem"><xsl:value-of select="$newline"/>
<div id="expandcontractdiv"><xsl:value-of select="$newline"/>
<a href="javascript:tree.expandAll()" class="treetools">Expand all</a><xsl:value-of select="$newline"/>
<a href="javascript:tree.collapseAll()" class="treetools">Collapse all</a><xsl:value-of select="$newline"/>
</div><xsl:value-of select="$newline"/>
<div id="treeDiv1"> </div><xsl:value-of select="$newline"/>
</div><xsl:value-of select="$newline"/>
</form><xsl:value-of select="$newline"/>
</div><xsl:value-of select="$newline"/>
</div><xsl:value-of select="$newline"/>
</div><xsl:value-of select="$newline"/>
</div><xsl:value-of select="$newline"/>
</div><xsl:value-of select="$newline"/>
<xsl:apply-templates/>
</nav><xsl:value-of select="$newline"/>
<iframe class="contentwin" id="contentwin" name="contentwin" src="test.html">
</iframe><xsl:value-of select="$newline"/>
<div id="footer" class="footer"></div><xsl:value-of select="$newline"/>
<script xmlns:glossdata="http://dita4publishers.org/glossdata" xmlns:mapdriven="http://dita4publishers.org/mapdriven" xmlns:enum="http://dita4publishers.org/enumerables" type="text/javascript" src="yahoo.js"> </script><xsl:value-of select="$newline"/>
<script xmlns:glossdata="http://dita4publishers.org/glossdata" xmlns:mapdriven="http://dita4publishers.org/mapdriven" xmlns:enum="http://dita4publishers.org/enumerables" type="text/javascript" src="event.js"> </script><xsl:value-of select="$newline"/>
<script xmlns:glossdata="http://dita4publishers.org/glossdata" xmlns:mapdriven="http://dita4publishers.org/mapdriven" xmlns:enum="http://dita4publishers.org/enumerables" type="text/javascript" src="treeview.js"> </script><xsl:value-of select="$newline"/>
</body><xsl:value-of select="$newline"/>
</html>
</xsl:template>
用于创建toc.js,frameset.html,frameset-nav.html,graphicMap.xml文件的动画,就像html2一样,通过应用哪些命令我可以使用我的自定义插件动态创建文件。
如下所示
toc.js就像
一样 //
// Javascript generated by HTML2 Toolkit plugin
//
var tree;
function treeInit() {
tree = new YAHOO.widget.TreeView("treeDiv1");
var root = tree.getRoot();
var objd64e49 = {
label: " About This Book",
href: "topics/guide.html#about-this-book-install-guide",
target:"contentwin"
};
var d64e49 = new YAHOO.widget.TextNode(objd64e49, root, false);
var objd64e70 = {
label: " Notices",
href: "topics/5-install-guide.html#notices",
target:"contentwin"
};
var d64e70 = new YAHOO.widget.TextNode(objd64e70, root, false);
var objd64e95 = {
label: "Chapter 1. Flows",
href: "topics/guide.html#flows",
target:"contentwin"
};
var d64e95 = new YAHOO.widget.TextNode(objd64e95, root, false);
//for testing
var d64e163a = new YAHOO.widget.TextNode(objd64e163, root, false);
var d64e184a = new YAHOO.widget.TextNode(objd64e184, d64e163a, false);
var d64e205a = new YAHOO.widget.TextNode(objd64e205, d64e163a, false);
var d64e229a = new YAHOO.widget.TextNode(objd64e229, d64e163a, false);
var d64e163b = new YAHOO.widget.TextNode(objd64e163, root, false);
var d64e184b = new YAHOO.widget.TextNode(objd64e184, d64e163b, false);
var d64e205b = new YAHOO.widget.TextNode(objd64e205, d64e163b, false);
var d64e229b = new YAHOO.widget.TextNode(objd64e229, d64e163b, false);
var d64e163c = new YAHOO.widget.TextNode(objd64e163, root, false);
var d64e184c = new YAHOO.widget.TextNode(objd64e184, d64e163c, false);
var d64e205c = new YAHOO.widget.TextNode(objd64e205, d64e163c, false);
var d64e229c = new YAHOO.widget.TextNode(objd64e229, d64e163c, false);
var d64e163d = new YAHOO.widget.TextNode(objd64e163, root, false);
var d64e184d = new YAHOO.widget.TextNode(objd64e184, d64e163d, false);
var d64e205d = new YAHOO.widget.TextNode(objd64e205, d64e163d, false);
var d64e229d = new YAHOO.widget.TextNode(objd64e229, d64e163d, false);
tree.draw();
}
YAHOO.util.Event.addListener(window, "load", treeInit);
frameset.html as
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Flow</title>
<link rel="stylesheet" type="text/css" href="css/$csscommonltr.css">
</head>
<frameset cols="30%,*">
<frame name="tocwin" src="frameset-nav.html">
<frame name="contentwin" src="topics/guide.html">
</frameset>
</html>
frameset-nav.html as
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head><title>Flow</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<base target="contentwin"/>
<link rel="stylesheet" type="text/css" href="css/reset-html5.css"/>
<link rel="stylesheet" type="text/css" href="css/root-page.css"/>
<link rel="stylesheet" type="text/css" href="css/local/tree.css"/>
</head>
<body>
<div xmlns:glossdata="http://dita4publishers.org/glossdata" xmlns:mapdriven="http://dita4publishers.org/mapdriven" xmlns:enum="http://dita4publishers.org/enumerables" class="dynamic-toc">
<div id="container">
<div id="containerTop">
<div id="main">
<div id="content">
<form name="mainForm" action="javscript:;">
<div class="newsItem">
<div id="expandcontractdiv">
<a href="javascript:tree.expandAll()">Expand all</a>
<a href="javascript:tree.collapseAll()">Collapse all</a>
</div>
<div id="treeDiv1"> </div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script xmlns:glossdata="http://dita4publishers.org/glossdata" xmlns:mapdriven="http://dita4publishers.org/mapdriven" xmlns:enum="http://dita4publishers.org/enumerables" type="text/javascript" src="yahoo.js"> </script>
<script xmlns:glossdata="http://dita4publishers.org/glossdata" xmlns:mapdriven="http://dita4publishers.org/mapdriven" xmlns:enum="http://dita4publishers.org/enumerables" type="text/javascript" src="event.js"> </script>
<script xmlns:glossdata="http://dita4publishers.org/glossdata" xmlns:mapdriven="http://dita4publishers.org/mapdriven" xmlns:enum="http://dita4publishers.org/enumerables" type="text/javascript" src="treeview.js"> </script>
<script xmlns:glossdata="http://dita4publishers.org/glossdata" xmlns:mapdriven="http://dita4publishers.org/mapdriven" xmlns:enum="http://dita4publishers.org/enumerables" type="text/javascript" src="toc.js"> </script>
</body></html>
和graphicMap.xml一样
<?xml version="1.0" encoding="UTF-8"?>
<gmap:graphic-map xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
xmlns:gmap="http://dita4publishers/namespaces/graphic-input-to-output-map">
<gmap:graphic-map-item id="image-list-item-1"
input-url="images/m4_Oct31.png"
output-url="file:/E:/task/out/xhtml-rsuite4docs/images/m4_Oct31.png"/>
<gmap:graphic-map-item id="image-list-item-2"
input-url="images/m2_Oct31.png"
output-url="file:/E:/task/out/xhtml-rsuite4docs/images/m2_Oct31.png"/>
</gmap:graphic-map>