J
J Bondo
Dear group,
I'm new to both DocBook and XSLT and am having troubles understanding
why my XSLT stylesheet doesn't work. I'm using xsltproc on my Mac to
generate a plist file. For some reason, none of my templates, except
for <xsl:template match="/">, are being executed. I've tried all kinds
of combinations for the search pattern. What am I doing wrong? See
file listings below.
Any help is appreciated, thanks in advance,
Joachim
---
Executing
$ xsltproc -o Test.plist test.xsl test.docbook
gives this output:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://
www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>
---
test.docbook:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V5.0//EN" "http://
www.oasis-open.org/docbook/xml/5.0b5/dtd/docbook.dtd">
<book xmlns="http://docbook.org/ns/docbook" version="5.0"
xml:lang="en" xml:id="my-doc-id">
<info>
<title>My Book Title</title>
<revhistory>
<revision>
<revnumber>1st revision</revnumber>
<date>January 17, 2009</date>
</revision>
</revhistory>
</info>
<chapter>
<title>First Chapter</title>
<section>
<title>First section in chapter 1</title>
<para>First paragraph of section 1 in chapter 1</para>
</section>
</chapter>
<!-- General -->
<chapter>
<title>Second Chapter</title>
<section>
<title>Section 1 of chapter 2</title>
<para>First paragraph in section 1, chapter 2</para>
<para>Second paragraph in section 1, chapter 2</para>
</section>
</chapter>
</book>
test.xsl:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" >
<xslutput encoding="UTF-8" indent="yes" method="xml"
doctype-public="-//Apple//DTD PLIST 1.0//EN"
doctype-system="http://www.apple.com/DTDs/PropertyList-1.0.dtd" />
<xsl:template match="/">
<plist version="1.0">
<dict>
<xsl:apply-templates />
</dict>
</plist>
</xsl:template>
<!-- TEMPLATES -->
<xsl:template match="book/info">
<key>Title</key>
<string><xsl:value-of select="title" /></string>
<key>Date</key>
<string><xsl:value-of select="revhistory/revision[1]/date" /></
string>
<key>Chapters</key>
<array>
<xsl:apply-templates />
</array>
</xsl:template>
<xsl:template match="chapter">
<dict>
<key>Title</key>
<string><xsl:value-of select="title" /></string>
<key>Sections</key>
<array>
<xsl:apply-templates />
</array>
</dict>
</xsl:template>
<xsl:template match="section">
<dict>
<key>Title</key>
<string><xsl:value-of select="title" /></string>
</dict>
</xsl:template>
<xsl:template match="*">
</xsl:template>
</xsl:stylesheet>
I'm new to both DocBook and XSLT and am having troubles understanding
why my XSLT stylesheet doesn't work. I'm using xsltproc on my Mac to
generate a plist file. For some reason, none of my templates, except
for <xsl:template match="/">, are being executed. I've tried all kinds
of combinations for the search pattern. What am I doing wrong? See
file listings below.
Any help is appreciated, thanks in advance,
Joachim
---
Executing
$ xsltproc -o Test.plist test.xsl test.docbook
gives this output:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://
www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>
---
test.docbook:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V5.0//EN" "http://
www.oasis-open.org/docbook/xml/5.0b5/dtd/docbook.dtd">
<book xmlns="http://docbook.org/ns/docbook" version="5.0"
xml:lang="en" xml:id="my-doc-id">
<info>
<title>My Book Title</title>
<revhistory>
<revision>
<revnumber>1st revision</revnumber>
<date>January 17, 2009</date>
</revision>
</revhistory>
</info>
<chapter>
<title>First Chapter</title>
<section>
<title>First section in chapter 1</title>
<para>First paragraph of section 1 in chapter 1</para>
</section>
</chapter>
<!-- General -->
<chapter>
<title>Second Chapter</title>
<section>
<title>Section 1 of chapter 2</title>
<para>First paragraph in section 1, chapter 2</para>
<para>Second paragraph in section 1, chapter 2</para>
</section>
</chapter>
</book>
test.xsl:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" >
<xslutput encoding="UTF-8" indent="yes" method="xml"
doctype-public="-//Apple//DTD PLIST 1.0//EN"
doctype-system="http://www.apple.com/DTDs/PropertyList-1.0.dtd" />
<xsl:template match="/">
<plist version="1.0">
<dict>
<xsl:apply-templates />
</dict>
</plist>
</xsl:template>
<!-- TEMPLATES -->
<xsl:template match="book/info">
<key>Title</key>
<string><xsl:value-of select="title" /></string>
<key>Date</key>
<string><xsl:value-of select="revhistory/revision[1]/date" /></
string>
<key>Chapters</key>
<array>
<xsl:apply-templates />
</array>
</xsl:template>
<xsl:template match="chapter">
<dict>
<key>Title</key>
<string><xsl:value-of select="title" /></string>
<key>Sections</key>
<array>
<xsl:apply-templates />
</array>
</dict>
</xsl:template>
<xsl:template match="section">
<dict>
<key>Title</key>
<string><xsl:value-of select="title" /></string>
</dict>
</xsl:template>
<xsl:template match="*">
</xsl:template>
</xsl:stylesheet>