I am totally new with xslt and try to make simple XSLT for converting docbook5 to fb2/fb3 and other formats needed for me.
But I found problem that I can not understand - if <book>
tag has xmlns="http://docbook.org/ns/docbook"
xslt did not work.
Minimal example of docbook (db.docbook):
<?xml version="1.0" encoding="UTF-8"?>
<book xml:id="simple_book" version="5.0"
xml:lang="ru"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
>
<info>
<title>An Example Book</title>
</info>
</book>
and XSLT (xsl/example.xsl):
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<tag><xsl:value-of select="/book/info/title"/></tag>
</xsl:template>
</xsl:stylesheet>
I try xsltproc
xsltproc xsl/example.xsl db.docbook
and saxon
saxon-xslt db.docbook xsl/example.xsl
in Debian GNU/Linux 9.1, but got
<?xml version="1.0"?>
<tag/>
if I remove xmlns in docbook:
<?xml version="1.0" encoding="UTF-8"?>
<book xml:id="simple_book" version="5.0"
xml:lang="ru"
xmlns:xlink="http://www.w3.org/1999/xlink"
>
<info>
<title>An Example Book</title>
</info>
</book>
both processors make right output:
<?xml version="1.0"?>
<tag>An Example Book</tag>
May be somebody know how make xslt without removing xlmns?
You have to declare the namespace in your XSLT and use it: