[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: RE: [docbook-apps] generating javascript navigation
|
Hello, It seems that
I have figured it out. The
stylesheet bellow now generates the
file with javascript tree contaning the table of contents. Greetings, Pavel �kop�k <xsl:import href=“chunk.xsl"/> ��� <xsl:template match="/"> ������� <xsl:choose> ����������� <xsl:when ��������������� test="(function-available('exsl:node-set') or ��������������� contains(system-property('xsl:vendor'), ������������ ���'Apache Software Foundation')) ��������������� and
(*/self::ng:* or */self::db:*)"> ��������������� <xsl:call-template name="log.message"> ������������������� <xsl:with-param name="level">Note</xsl:with-param> ������������������� <xsl:with-param name="context-desc"> ����������������������� <xsl:text>namesp. cut</xsl:text> ������������������� </xsl:with-param> ������������������� <xsl:with-param name="message"> ����������������������� <xsl:text>stripped namespace before processing</xsl:text> ������������ �������</xsl:with-param> ��������������� </xsl:call-template> ��������������� <xsl:variable name="nons"> ������������������� <xsl:apply-templates mode="stripNS"/> ��������������� </xsl:variable> ��������������� <xsl:call-template name="log.message"> ����� ��������������<xsl:with-param name="level">Note</xsl:with-param> ������������������� <xsl:with-param name="context-desc"> ����������������������� <xsl:text>namesp. cut</xsl:text> ������������������� </xsl:with-param> ������������������� <xsl:with-param name="message"> ����������������������� <xsl:text>processing stripped document</xsl:text> ������������������� </xsl:with-param> ��������������� </xsl:call-template> ��������������� <xsl:apply-templates select="exsl:node-set($nons)"/> ����������� </xsl:when> ����������� <xsl:otherwise> ��������������� <xsl:choose> ������������������� <xsl:when test="$rootid !=
''"> ����������������������� <xsl:choose> ��������������������������� <xsl:when test="count(key('id',$rootid)) = 0"> ������������������������������� <xsl:message terminate="yes"> ����������������������������������� <xsl:text>ID '</xsl:text> ����������������������������������� <xsl:value-of
select="$rootid"/> ����������������������������������� <xsl:text>' not found in document.</xsl:text> ������������������������������� </xsl:message> ��������������������������� </xsl:when> ��������������������������� <xsl:otherwise> ������������������������������� <xsl:if �����������������������������������
test="$collect.xref.targets = 'yes' or ����������������������������������� $collect.xref.targets
= 'only'"> ����������������������������������� <xsl:apply-templates
select="key('id', $rootid)" ���������������������������������������
mode="collect.targets"/> ������������������������ �������</xsl:if> ������������������������������� <xsl:if test="$collect.xref.targets
!= 'only'"> ����������������������������������� <xsl:message>Formatting from <xsl:value-of
select="$rootid"/></xsl:message> ����������������������������������� <xsl:apply-templates
select="key('id',$rootid)" ���������������������������������������
mode="process.root"/> ����������������������������������� <xsl:call-template
name="jstoc"/> ������������������������������� </xsl:if> ��������������������������� </xsl:otherwise> ����������������������� </xsl:choose> ������������������� </xsl:when> ������������������� <xsl:otherwise> ����������������������� <xsl:if ��������������������������� test="$collect.xref.targets
= 'yes' or ��������������������������� $collect.xref.targets
= 'only'"> ��������������������������� <xsl:apply-templates
select="/" mode="collect.targets"/> ����������������������� </xsl:if> ����������������������� <xsl:if test="$collect.xref.targets != 'only'"> ��������������������������� <xsl:apply-templates
select="/" mode="process.root"/> ��������������������������� <xsl:call-template
name="jstoc"/> ����������������������� </xsl:if> ������������������� </xsl:otherwise> ��������������� </xsl:choose> ����������� </xsl:otherwise> ������� </xsl:choose> ��� </xsl:template> ��� <xsl:template match="text()"
mode="jstoc"/> ��� <!—template
for creating javascript tree file --> ��� <xsl:template name="jstoc"> ������� <xsl:call-template name="write.chunk"> ����������� <xsl:with-param name="filename"> ��������������� <xsl:if test="$manifest.in.base.dir
!= 0"> ������������������� <xsl:value-of select="$base.dir"/> ��������������� </xsl:if> ��������������� <xsl:value-of select="'toctree.js'"/> ����������� </xsl:with-param> ����������� <xsl:with-param name="method" select="'text'"/> ����������� <xsl:with-param name="encoding" select="'windows-1250'"/> ����������� <xsl:with-param name="indent" select="'yes'"/> ����������� <xsl:with-param name="content"> ���������������������������������������������� ���������������������������������������������� <!—javascript code which draws the
tree --> ��������������� <xsl:text> ������������������� var tree; ������������������� ������������������� function
treeInit() { ������������������� tree
= new YAHOO.widget.TreeView("treeDiv1"); ������������������� var root
= tree.getRoot(); ��������������� </xsl:text> ����������� ��������������� <xsl:apply-templates mode="jstoc"/> ��������������� <xsl:text> ������������������� tree.draw(); ������������������� } ������������������� ������������������� YAHOO.util.Event.addListener(window, "load", treeInit); ��������������� </xsl:text> ����������� </xsl:with-param> ������� </xsl:call-template> ��� </xsl:template> ��� <!-- this template generate nodes of the
javascript tree �--> ��� <xsl:template
match="book|part|reference|preface|chapter|bibliography|appendix|article|glossary|section|sect1|sect2|sect3|sect4|sect5|refentry|colophon|bibliodiv|index"
mode="jstoc"> ������� <xsl:param name="current.node" select="."/> ������� ������� <xsl:variable name="objID" select="generate-id()"/> ����������� ������� <!-- let's find out if current node is a root node; if not it
gets the ‘root’ value, otherwise id of parent node is generated --> ������� <xsl:variable name="parentID"> ����������� <xsl:if test="$current.node = /"> ��������������� <xsl:value-of select="'root'"/> ����������� </xsl:if> ��������� ��<xsl:if test="$current.node != /"> ��������������� <xsl:value-of select="generate-id(parent::*)"/> ����������� </xsl:if> ������� </xsl:variable> ����������������������� ������� <xsl:variable name="title"> ����������� <xsl:apply-templates select="." mode="title.markup"/> ������� </xsl:variable> ���� ����������� ������� <xsl:variable name="href"> ����������� <xsl:call-template name="href.target.with.base.dir"> ��������������� <xsl:with-param name="context" select="/"/> ����������� </xsl:call-template> ������� </xsl:variable> ������� ������� <!—javascript
tree nodes --> ������� <xsl:text>var
</xsl:text> � ������<xsl:value-of select="concat('obj', $objID)"/> ������� <xsl:text>
= { label: "</xsl:text> ������� <xsl:value-of select="normalize-space($title)"/> ������� <xsl:text>",
href:"</xsl:text> ������� <xsl:value-of select="$href"/> ������� <xsl:text>",
target:"content"};</xsl:text> ������� ������� <xsl:text>var
</xsl:text> ������� <xsl:value-of select="$objID"/> ������� <xsl:text>
= new YAHOO.widget.TextNode(</xsl:text> ������� <xsl:value-of select="concat('obj', $objID)"/> ������� <xsl:text>,
</xsl:text> �������
<xsl:value-of select="$parentID"/> ������� <xsl:text>,
false);</xsl:text> ������� <xsl:apply-templates mode="jstoc"
select="book|part|reference|preface|chapter|bibliography|appendix|article|glossary|section|sect1|sect2|sect3|sect4|sect5|refentry|colophon|bibliodiv|index"/> ��� </xsl:template> |
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]