Unable to understand why a template match is not caught though declared - xslt

I'm writing a XSLT script and there is a section named footnotes, my script is catching all elements other than footnotes. I'm using XSL2.0 and Below is my XML
<?xml version="1.0" encoding="utf-8"?>
<chapter num="D" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:acknowledgement="file://acknowledgement.xsd" xmlns:admission="file://admission.xsd" xmlns:affidavit="file://affidavit.xsd" xmlns:agreement="file://agreement.xsd" xmlns:appeal="file://appeal.xsd" xmlns:appearance="file://appearance.xsd" xmlns:application="file://application.xsd" xmlns:assent="file://assent.xsd" xmlns:authorisation="file://authorisation.xsd" xmlns:award="file://award.xsd" xmlns:brief="file://brief.xsd" xmlns:caveat="file://caveat.xsd" xmlns:certificate="file://certificate.xsd" xmlns:checklist="file://checklist.xsd" xmlns:claim="file://claim.xsd" xmlns:clause="file://clause.xsd" xmlns:comparisontable="file://comparisontable.xsd" xmlns:conditionsofcontract="file://conditionsofcontract.xsd" xmlns:declaration="file://declaration.xsd" xmlns:defaultjudgment="file://defaultjudgment.xsd" xmlns:defence="file://defence.xsd" xmlns:demand="file://demand.xsd" xmlns:flowchart="file://flowchart.xsd" xmlns:form="file://form.xsd" xmlns:guarantee="file://guarantee.xsd" xmlns:instruction="file://instruction.xsd" xmlns:judgment="file://judgment.xsd" xmlns:letter="file://letter.xsd" xmlns:minutes="file://minutes.xsd" xmlns:notice="file://notice.xsd" xmlns:oath="file://oath.xsd" xmlns:order="file://order.xsd" xmlns:patent="file://patent.xsd" xmlns:petition="file://petition.xsd" xmlns:powerofattorney="file://powerofattorney.xsd" xmlns:praecipe="file://praecipe.xsd" xmlns:questionnaire="file://questionnaire.xsd" xmlns:recognisance="file://recognisance.xsd" xmlns:release="file://release.xsd" xmlns:renunciation="file://renunciation.xsd" xmlns:reply="file://reply.xsd" xmlns:report="file://report.xsd" xmlns:request="file://request.xsd" xmlns:schedule="file://schedule.xsd" xmlns:statementofclaim="file://statementofclaim.xsd" xmlns:subpoena="file://subpoena.xsd" xmlns:summons="file://summons.xsd" xmlns:undertaking="file://undertaking.xsd" xmlns:warrant="file://warrant.xsd" xmlns:writ="file://writ.xsd" xmlns:book="file://book.xsd" xmlns:forms="file://forms.xsd" xmlns:misc="file://misc.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:htm="http://www.w3.org/TR/html5/">
<htm:p align="center">
<htm:b>Bold Content</htm:b>
<footnote num="1">
<para>
Footnote content.
</para>
</footnote>
</htm:p>
</chapter>
And below is my XSLT.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ntw="Number2Word.uri" xmlns:altova="http://www.altova.com/xslt-extensions" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:acknowledgement="file://acknowledgement.xsd" xmlns:admission="file://admission.xsd" xmlns:affidavit="file://affidavit.xsd" xmlns:agreement="file://agreement.xsd" xmlns:appeal="file://appeal.xsd" xmlns:appearance="file://appearance.xsd" xmlns:application="file://application.xsd" xmlns:assent="file://assent.xsd" xmlns:authorisation="file://authorisation.xsd" xmlns:award="file://award.xsd" xmlns:brief="file://brief.xsd" xmlns:caveat="file://caveat.xsd" xmlns:certificate="file://certificate.xsd" xmlns:checklist="file://checklist.xsd" xmlns:claim="file://claim.xsd" xmlns:clause="file://clause.xsd" xmlns:comparisontable="file://comparisontable.xsd" xmlns:conditionsofcontract="file://conditionsofcontract.xsd" xmlns:declaration="file://declaration.xsd" xmlns:defaultjudgment="file://defaultjudgment.xsd" xmlns:defence="file://defence.xsd" xmlns:demand="file://demand.xsd" xmlns:flowchart="file://flowchart.xsd" xmlns:form="file://form.xsd" xmlns:guarantee="file://guarantee.xsd" xmlns:instruction="file://instruction.xsd" xmlns:judgment="file://judgment.xsd" xmlns:letter="file://letter.xsd" xmlns:minutes="file://minutes.xsd" xmlns:notice="file://notice.xsd" xmlns:oath="file://oath.xsd" xmlns:order="file://order.xsd" xmlns:patent="file://patent.xsd" xmlns:petition="file://petition.xsd" xmlns:powerofattorney="file://powerofattorney.xsd" xmlns:praecipe="file://praecipe.xsd" xmlns:questionnaire="file://questionnaire.xsd" xmlns:recognisance="file://recognisance.xsd" xmlns:release="file://release.xsd" xmlns:renunciation="file://renunciation.xsd" xmlns:reply="file://reply.xsd" xmlns:report="file://report.xsd" xmlns:request="file://request.xsd" xmlns:schedule="file://schedule.xsd" xmlns:statementofclaim="file://statementofclaim.xsd" xmlns:subpoena="file://subpoena.xsd" xmlns:summons="file://summons.xsd" xmlns:undertaking="file://undertaking.xsd" xmlns:warrant="file://warrant.xsd" xmlns:writ="file://writ.xsd" xmlns:book="file://book.xsd" xmlns:forms="file://forms.xsd" xmlns:misc="file://misc.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:htm="http://www.w3.org/TR/html5/" xpath-default-namespace="http://foo.bar.com/ns" exclude-result-prefixes="#all">
<xsl:output method="html"/>
<xsl:strip-space elements="*"/>
<!--<xsl:preserve-space elements="para"/>-->
<xsl:variable name="nums" as="element()+">
<ntw:nums num="1" word="first"/>
<ntw:nums num="2" word="second"/>
<ntw:nums num="3" word="third"/>
<ntw:nums num="4" word="forth"/>
<ntw:nums num="5" word="fifth"/>
<ntw:nums num="6" word="sixth"/>
<ntw:nums num="7" word="seventh"/>
<ntw:nums num="8" word="eighth"/>
<ntw:nums num="9" word="nighth"/>
<ntw:nums num="10" word="tenth"/>
</xsl:variable>
<xsl:template match="/">
<xsl:text disable-output-escaping="yes"><![CDATA[<!DOCTYPE html>]]></xsl:text>
<html>
<head>
<xsl:text disable-output-escaping="yes"><![CDATA[</meta>]]></xsl:text>
<title>
<xsl:value-of select="chapter/title/text()"/>
</title>
<link rel="stylesheet" href="C:\Users\u0138039\Desktop\Proview\MY\2016\CCA3ED\XML\XSLT\main.css" type="text/css"/>
<xsl:text disable-output-escaping="yes"><![CDATA[</link>]]></xsl:text>
</head>
<body>
<section class="tr_chapter">
<xsl:apply-templates/>
</section>
<xsl:if test="//footnote">
<section class="tr_footnotes">
<xsl:text disable-output-escaping="yes"><![CDATA[<hr />]]></xsl:text>
<xsl:apply-templates select="//page | //footnote" mode="footnote"/>
</section>
</xsl:if>
</body>
</html>
</xsl:template>
<xsl:template match="chapter">
<xsl:apply-templates select="descendant::title[1]/page" mode="first"/>
<div class="chapter">
<xsl:variable name="num_S">
<xsl:value-of select="."/>
</xsl:variable>
<a name="CLIHK_CH_{$num_S}"/>
<div class="chapter-title">
<span class="chapter-num">
<xsl:value-of select="normalize-space(concat('Chapter ',format-number(./#num,'0')))"/>
</span>
<xsl:text disable-output-escaping="yes"><![CDATA[<br /><br />]]></xsl:text>
<xsl:apply-templates select="title/node() except descendant-or-self::page"/>
<xsl:text disable-output-escaping="yes"><![CDATA[<br /><br />]]></xsl:text>
<xsl:apply-templates select="chapter-meta"/>
</div>
<xsl:apply-templates select="child::node()[not(self::title|self::chapter-meta)]"/>
</div>
</xsl:template>
<xsl:template match="htm:b">
<span class="font-style-bold">
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template match="htm:p">
<xsl:apply-templates select="./node()[1][self::page]" mode="first"/>
<div>
<xsl:choose>
<xsl:when test="./#align">
<xsl:attribute name="class"><xsl:text>para align-</xsl:text><xsl:value-of select="./#align"/></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class"><xsl:text>para</xsl:text></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="footnote">
<xsl:variable name="cnt" select="count(preceding::footnote)+1"/>
<xsl:variable name="varHeaderNote" select='concat("f",$cnt)'/>
<xsl:variable name="varFootNote" select='concat("#ftn.",$cnt)'/>
<sup>
<a name="{$varHeaderNote}" href="{$varFootNote}" class="tr_ftn">
<xsl:value-of select="#num"/>
</a>
</sup>
</xsl:template>
<xsl:template match="footnote" mode="footnote">
<xsl:variable name="cnt" select="count(preceding::footnote)+1"/>
<div class="tr_footnote">
<div class="footnote">
<sup>
<a>
<xsl:attribute name="name"><xsl:text>ftn.</xsl:text><xsl:value-of select="$cnt"/></xsl:attribute>
<xsl:attribute name="href"><xsl:text>#f</xsl:text><xsl:value-of select="$cnt"/></xsl:attribute>
<xsl:attribute name="class"><xsl:text>tr_ftn</xsl:text></xsl:attribute>
<xsl:value-of select="#num"/>
</a>
</sup>
<xsl:apply-templates/>
</div>
</div>
</xsl:template>
</xsl:stylesheet>
My current output is as below
<!DOCTYPE html><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>
<title></title>
<link rel="stylesheet" href="C:\Users\u0138039\Desktop\Proview\MY\2016\CCA3ED\XML\XSLT\main.css" type="text/css"></link>
</head>
<body>
<section class="tr_chapter">
<div class="para align-center"><span class="font-style-bold">Bold Content</span>
Footnote content.
</div>
</section>
</body>
</html>
But my expected output is
<!DOCTYPE html><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>
<title></title>
<link rel="stylesheet" href="C:\Users\u0138039\Desktop\Proview\MY\2016\CCA3ED\XML\XSLT\main.css" type="text/css"></link>
</head>
<body>
<section class="tr_chapter">
<div class="para align-center"><span class="font-style-bold">Bold Content</span><sup>
<a name="f1" href="#ftn.1" class="tr_ftn">1</a>
</sup>
</div>
</section>
<section class="tr_footnotes"><hr/>
<div class="tr_footnote">
<div class="footnote">
<sup>
<a name="ftn.1" href="#f1" class="tr_ftn">1</a>
</sup>
<div class="para">Footnote content.
</div>
</div>
</div></section>
</body>
</html>
Here is a working demo
please let me know where Am I going wrong and how can I fix this.
Thanks

Your stylesheet declares:
xpath-default-namespace="http://foo.bar.com/ns"
The footnote in your XML is in no namespace, therefore the test in:
<xsl:if test="//footnote">
returns false.

Related

How do I add unit and chapter tags from my source files to my output file using XSLT?

I'm working on an XSLT script to create an ePub TOC from a source file. I am able to get the content I need for the HTML files themselves but I also need to include the <unit> and <chapter> tags as well. I'm stuck how to get those into my output file.
This is my input file:
<?xml version="1.0" encoding="UTF-8"?>
<toc xmlns="http://www.standardnine.com/s9ml" data-uuid="c667450f8f7d45888630f13533a20e14">
<metadata thumbnailpath="../img/toc_thumbs/.crops/9781506250953_7c4cbc8d37244424a9f2a00ab56b5db7.jpg">
<remarks path="remarks.s9ml"/>
<edition/>
<title>SHSAT Course 2021</title>
<author/>
<publisher/>
<shortname>sn_a9645</shortname>
<pubdate>Publish Date</pubdate>
<version>Version</version>
<revision>Revision</revision>
<s9version>s9version</s9version>
<productid>Product ID</productid>
<bundleconfig path="config.s9ml"/>
<reflowable>true</reflowable>
<subtitle/>
</metadata>
<spine>
<unit designation="" enumeration="" data-uuid="f2aab3845c9d4e1988de8c6a22429af8">
<title/>
<chapter thumbnailpath="../img/toc_thumbs/.crops/9781506250953_56d8078f9660471799cb1741a3a45ade.jpg" designation="" enumeration="" data-uuid="c848cd9de0b646e1b3590904031e41f8" sandbox="true">
<title>Front Matter</title>
<exhibit path="frontmatter/fm_cover.html"/>
<exhibit path="frontmatter/fm_titlepage.html"/>
<exhibit path="frontmatter/copyright.html"/>
</chapter>
</unit>
<unit designation="Section" enumeration="1" data-uuid="d1ff46bfa6fe47dda6f27a9d871eb727">
<title>Getting Started</title>
<chapter thumbnailpath="../img/toc_thumbs/ch01_thumb.png" designation="Chapter" enumeration="1" data-uuid="6f33bec0993d4133b75e4bd9b3902ef8" sandbox="false">
<title>SHSAT Basics</title>
<exhibit path="chapter01/ch01_part.html"/>
<exhibit path="chapter01/ch01_reader_0.html"/>
</chapter>
<chapter thumbnailpath="../img/toc_thumbs/ch02_thumb.png" designation="Chapter" enumeration="2" data-uuid="2bf06864e6264270843990fe377ecb41" sandbox="false">
<title>Inside the SHSAT</title>
<exhibit path="chapter02/ch02_reader_0.html"/>
<exhibit path="chapter02/ch02_reader_1.html"/>
</chapter>
</unit>
</spine>
</toc>
This my XSLT script:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:math="http://www.w3.org/2005/xpath-functions/math"
xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:s9ml="http://www.standardnine.com/s9ml" exclude-result-prefixes="xs math xd xhtml s9ml"
xmlns:epub="http://www.idpf.org/2007/ops"
version="3.0">
<xsl:output method="xhtml"/>
<xsl:param name="topicPrefix"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>EPUB 3 Specifications - Table of Contents</title>
<link rel="stylesheet" type="text/css" href="../css/epub-spec.css" />
</head>
<body>
<nav epub:type="toc" id="toc">
<h1 class="title">Table of Contents</h1>
<ol>
<xsl:apply-templates select="//s9ml:exhibit" />
</ol>
</nav>
</body>
</html>
</xsl:template>
<!-- process exhibits referenced from toc.s9ml -->
<xsl:template match="s9ml:exhibit">
<xsl:element name="li" namespace="http://www.w3.org/1999/xhtml">
<xsl:variable name="count" select="position()"/>
<xsl:attribute name="id">
<xsl:value-of select="$topicPrefix"/>
<xsl:number format="0000" level="any"/>
</xsl:attribute>
<xsl:element name="a" namespace="http://www.w3.org/1999/xhtml">
<xsl:attribute name="href">
<xsl:value-of select="#path" />
</xsl:attribute>
<xsl:apply-templates select="document(#path)//xhtml:title">
</xsl:apply-templates>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
This is the output I'm getting:
<?xml version="1.0" encoding="UTF-8"?><html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>EPUB 3 Specifications - Table of Contents</title>
<link rel="stylesheet" type="text/css" href="../css/epub-spec.css" />
</head>
<body>
<nav epub:type="toc" id="toc">
<h1 class="title">Table of Contents</h1>
<ol>
<li id="0001">Cover</li>
<li id="0002">Title Page</li>
<li id="0003">Copyright</li>
<li id="0004">Section 1: Getting Started</li>
<li id="0005">SHSAT Basics</li>
<li id="0006">Inside the SHSAT</li>
<li id="0007">Structure of the Test</li>
</ol>
</nav>
</body>
</html>
This is the output I need is:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>EPUB 3 Specifications - Table of Contents</title>
<link rel="stylesheet" type="text/css" href="../css/epub-spec.css" />
</head>
<body>
<nav epub:type="toc" id="toc">
<h1 class="title">Table of Contents</h1>
<ol>
<li>Front Matter <ol>
<li id="0001">Cover</li>
<li id="0002">Title Page</li>
<li id="0003">Copyright</li>
</ol>
</li>
<li>Section 1 Getting Started <ol>
<li>Chapter 1 SHSAT Basics <ol>
<li id="0004"><a href="chapter01/ch01_part.html">Section 1: Getting
Started</a></li>
<li id="0005"><a href="chapter01/ch01_reader_0.html">SHSAT
Basics</a></li>
</ol>
</li>
<li>Chapter 2 Inside the SHSAT <ol>
<li id="0006"><a href="chapter02/ch02_reader_0.html">Inside the
SHSAT</a></li>
<li id="0007"><a href="chapter02/ch02_reader_1.html">Structure of
the Test</a></li>
</ol>
</li>
</ol>
</li>
</ol>
</nav>
</body>
</html>
It sounds as if you want to start processing <xsl:apply-templates select="//s9ml:unit"/> instead of <xsl:apply-templates select="//s9ml:exhibit" />, then write a template
<xsl:template mmatch="s9ml:unit | s9ml:chapter">
<li>
<xsl:value-of select="s9ml:title"/>
<ol>
<xsl:apply-templates select="node() except s9ml:title"/>
</ol>
</li>
</xsl:template>
to make sure you get a hierarchy of nested, ordered lists.
The whole snippets assumes you want to output XHTML result elements and have therefore declared xmlns="http://www.w3.org/1999/xhtml" on the xsl:stylesheet root element.

Is it possible to create toc.js, frameset.html, frameset-nav.html, graphicMap.xml using xhtml base plugin

Is it possible to create the toc.js, frameset.html, frameset-nav.html, graphicMap.xml files dynamically as like html2 base plugin using custom plugin I have created, plugin creation explained in below link
custom plugin created
I have created the custom xhtml plugin like this
my plugin.xml code is
<?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 code is
<?xml version="1.0" encoding="UTF-8"?>
<project name="com.custom.xhtml">
<import file="build_transtype-custom.xml"/>
</project>
the build_transtype-custom.xml is
<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>
then I have pasted the base plugin xsl folder to customized plugin the I have changed the xsl named dita2xhtml.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>
then changed the xsl named map2htmtocImpl.xsl template named as generate-toc in xslhtml\map2htmtoc folder as like this
template changes only done
<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"/>
Expand all<xsl:value-of select="$newline"/>
Collapse all<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>
for the created plugin for the creation of toc.js, frameset.html, frameset-nav.html, graphicMap.xml files dynamically as like html2 by applying which commands i can create the files dynamically using my customized plugin.
shown below
toc.js as like
//
// 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">
Expand all
Collapse all
</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>
and the graphicMap.xml as like
<?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>

How to Enumerate a Table Sequentially

I would like to know how it is possible to enumerate a table sequentially and to save this value into some kind of variable so this value can be selected in another template.
Each time the template table is called, the variable has to be incremented (the first value of the "counter" has to be 1).
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<head>
<title>Tables.</title>
</head>
<body>
<xsl:apply-templates select="table"/>
<!-- apply more templates -->
</body>
</html>
</xsl:template>
<xsl:template match="table">
<center>
<b>Table **ENUMERATION OF THE TABLE** - </b><xsl:value-of select="title"/>
</center>
<br/>
</xsl:template>
<!-- more templates -->
Input (XML):
<table id="table1">
<title>Title.</title>
<br/>
</table>
<table id="table2">
<title>Title.</title>
<br/>
</table>
Output (HTML):
Table 1 - Title.
Table 2 - Title.
Your example is not a good one. If your input looks something like:
<root>
<table id="table1">
<title>Title 1</title>
</table>
<not-table/>
<table id="table2">
<title>Title 2</title>
</table>
<not-table/>
<table id="table3">
<title>Title 3</title>
</table>
</root>
then applying:
<xsl:template match="/root">
<xsl:copy>
<xsl:apply-templates select="table"/>
</xsl:copy>
</xsl:template>
<xsl:template match="table">
<center>
<b>Table <xsl:value-of select="position()"/> - </b>
<xsl:value-of select="title"/>
</center>
<br/>
</xsl:template>
will result in:
<root>
<center>
<b>Table 1 - </b>Title 1</center>
<br/>
<center>
<b>Table 2 - </b>Title 2</center>
<br/>
<center>
<b>Table 3 - </b>Title 3</center>
<br/>
</root>

Build a tree from a XML file using XSLT?

Being a XML file, I know to generate some output by the XSL. But I need to build a navigation tree either to hidden the contents that I don't have to look at or show those I want to. Tree that I am looking for should look like this one:
+VIEW1
+VIEW2
if hitting something like '+' somewhere, for instance on VIEW2 , we should get the content of VIEW2 like this one:
+VIEW1
-VIEW2
yy NO
aa YES
zz NO
tt NO
Here's a part of my XML file and "view.xsl" which i wrote. I also tried to modify some examples from the stackoverflow but i didn't find how to get right solution.
view.xsl
<xsl:stylesheet version="2.0"
xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" cdata-section-elements="Cdata" indent="yes"/>
<xsl:template match = "/">
<html >
<head>
<title Localizable_1="True"><xsl:value-of select="DOC/show"/></title>
</head>
<BODY class="BODY">
<H1><xsl:value-of select="DOC/show"/></H1>
<TABLE WIDTH="500px">
<xsl:for-each select="DOC/Entry">
<xsl:call-template name="RULE"/>
</xsl:for-each>
</TABLE>
</BODY>
</html>
</xsl:template>
<xsl:template name="RULE">
<xsl:choose>
<xsl:if test="level='ON'"><xsl:value-of select="light"/>YES</xsl:if>
<xsl:if test="level='OFF'"><xsl:value-of select="light"/>NO</xsl:if>
</xsl:choose>
file.XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml:stylesheet type='text/xsl' href='view.xsl'?>
<DOC>
<show>VIEW1</show>
<Entry>
<light>ae</light>
<level>ON</level>
</Entry>
<Entry>
<light>by</light>
<level>OFF</level>
</Entry>
<Entry>
<light>ac</light>
<level>OFF</level>
</Entry>
<show>VIEW2</show>
<Entry>
<light>yy</light>
<level>OFF</level>
</Entry>
<Entry>
<light>aa</light>
<level>ON</level>
</Entry>
<Entry>
<light>zz</light>
<level>OFF</level>
</Entry>
<Entry>
<light>tt</light>
<level>OFF</level>
</Entry>
</DOC>
Thanks for any help
This works (I build a table with tr and td elements but I assume you can enhance from here).
Helpful links on following-sibling
<xsl:stylesheet version="2.0"
xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml" >
<xsl:output method="html" cdata-section-elements="Cdata" indent="yes"/>
<xsl:template match = "/">
<html >
<head>
<title Localizable_1="True">
<xsl:value-of select="DOC/show"/>
</title>
<script src="http://code.jquery.com/jquery-1.9.1.min.js" type="text/javascript">
<xsl:comment>jq</xsl:comment>
</script>
<script src="https://raw.github.com/vakata/jstree/master/dist/jstree.min.js" type="text/javascript">
<xsl:comment>tree</xsl:comment>
</script>
</head>
<body class="BODY">
<div class="tree">
<xsl:apply-templates select="DOC/show" />
</div>
<script>
$('div.tree')
.jstree({
core: {}
})
.bind("select_node.jstree", function (event, data) {
alert(data.node.context.id); /* do clever things here */
})
.delegate("a", "click", function (event, data) { event.preventDefault(); });
</script>
</body>
</html>
</xsl:template>
<!-- match show elements -->
<xsl:template match="show">
<ul class="tree">
<li>
<a>
<xsl:value-of select="."/>
</a>
<ul>
<!-- only select the next Entry element -->
<xsl:apply-templates select="following-sibling::*[1][self::Entry] "/>
</ul>
</li>
</ul>
</xsl:template>
<xsl:template match="Entry">
<li class="rule">
<xsl:call-template name="RULE"/>
</li>
<!-- only select the next Entry element -->
<xsl:apply-templates select="following-sibling::*[1][self::Entry] "/>
</xsl:template>
<xsl:template name="RULE">
<xsl:element name="a">
<!-- or have a href here -->
<xsl:attribute name="id">
<xsl:value-of select="light"/>
</xsl:attribute>
<span class="light">
<xsl:value-of select="light"/>
</span>
<span class="level">
<xsl:choose>
<xsl:when test="level='ON'">
<xsl:text>YES</xsl:text>
</xsl:when>
<xsl:when test="level='OFF'">
<xsl:text>NO</xsl:text>
</xsl:when>
</xsl:choose>
</span>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

XSLT validation error javax.xml.transform.TransformerConfigurationException:

i'm having this error when i tried to validate my XSLT
javax.xml.transform.TransformerConfigurationException:
javax.xml.transform.TransformerException:
javax.xml.transform.TransformerException:
A node test that matches either NCName:* or QName was expected.
this is my XSLT
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="html" />
<xsl:template match="\Apps">
<html>
<head> <title>Apps List</title>
<link rel="StyleSheet" href="table_style.css" type="text/css"/>
<style type="text/css">
body {font-family: Helvetca;}
h1 { color : Grey;}
h2 {color : Blue;}</style>
</head>
<body>
<h1> Apps List: <xsl:value-of select="\#List_Type" /></h1>
<p>This is a list of all currently hot apps:</p>
<xsl:for-each select="\App">
<xsl:if test="\App\#installed == true">
<h2 style="color:Green;"><xsl:value-of select="\App\app_name" />(instaled)</h2>
</xsl:if>
<xsl:otherwise>
<h2><xsl:value-of select="\App\app_name" /></h2>
</xsl:otherwise>
<p style="font-style:bold;">App info:</p>
<table id="#gradient-style">
<tr><th>Category:</th><td><xsl:value-of select="\App\catogry" /></td></tr>
<tr><th>Verdion:</th><td><xsl:value-of select="\App\version" /></td></tr>
<tr><th>Description:</th><td><xsl:value-of select="\App\description" /></td></tr>
<tr><th>App Reviews:</th><td><xsl:for-each select="\App\reviews\review">
<span style="font-style:bold;"><xsl:value-of select="\App\reviews\review\reviewer_name" /></span>
| <xsl:value-of select="\App\reviews\review\review_date" />
| <xsl:value-of select="\App\reviews\review\review_Time" /><br/>
<span style="font-style:bold;">Rating:</span>
<xsl:value-of select="string(\App\reviews\review\rating" /> <br/>
<xsl:value-of select="\App\reviews\review\ontent" /><br/>
----------------------------------------------------------
</xsl:for-each>
</td></tr>
</table>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
this is the XML that tried with
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="ShdenXSLT.xsl"?>
<Apps xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" List_Type="new releases" >
<App device_type="tablet" app_id="120">
<app_name>Meeting Manager</app_name>
<catogry>LifeStyle </catogry>
<catogry>Bussnisse </catogry>
<version>1.0</version>
<description>This app is about managing the bussnisse meeting</description>
<reviews>
<review>
<reviewer_name>Shaden</reviewer_name>
<review_date>2012-02-13</review_date>
<review_time>11:35:02</review_time>
<content>it was a useful app</content>
<rating>4.5</rating>
</review>
<review>
<reviewer_name>Mohamed</reviewer_name>
<review_date>2012-03-01</review_date>
<review_time>12:15:00</review_time>
<content>i really loved this app</content>
<rating>5.0</rating>
</review>
</reviews>
</App>
<App device_type="tablet" app_id="100">
<app_name>ToDoList</app_name>
<catogry>LifeStyle </catogry>
<version>3.4.2</version>
<description>a simple To Do List applecation</description>
<reviews>
<review>
<reviewer_name>Fahad</reviewer_name>
<review_date>2010-02-05</review_date>
<review_time>09:40:55</review_time>
<content>nice app</content>
<rating>4.0</rating>
</review>
</reviews>
</App>
</Apps>
You are using backslash (\) as your XPath separator (i.e. <xsl:value-of select="\#List_Type" />), which is incorrect. It should be a forward slash (/)