Question 1: What is the cause of the xmns="" in <section>?
Question 2: why did the "epub" namespace in <section> vanish ?
Description of the problem:
I have an index.xml, which contains a list of XML files that I want to process with ONE XSLT file. The whole transformation and the looping etc goes well. This is the start of the index.xml file:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="file:///E:/toyota.xslt"?>
<list>
<entry>
<file>01.xml</file>
</entry>
<entry>
<file>02.xml</file>
</entry>
... etc.
The file 01.xml is a mix of html tags and "special"tags (my own).
The file 01.xml looks like this:
<?xml version="1.0" encoding="utf-8"?>
<body>
<section epub:type="frontmatter">
<p>....</p>
<p>....</p>
<p>....</p>
</section>
</body>
This is part of toyota.xslt (which has grown rather long). Here you see the loop mechanism and the template that processes the <body> part of the <entry><file>:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="2.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:epub="http://www.idpf.org/2007/ops" exclude-result-prefixes="xs fn">
<xsl:output method="xhtml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="/list/entry"/>
</xsl:template>
<xsl:template match="entry">
<xsl:variable name="filename" select="concat('new/' , substring-before( file, '.'), '.xhtml')"/>
<xsl:result-document href="{$filename}" >
<xsl:text disable-output-escaping="yes">
<!DOCTYPE html>
</xsl:text>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" lang="nl" xml:lang="nl">
<head>
<meta charset="utf-8" />
<title>
<xsl:value-of select="./title"/>
</title>
</head>
<xsl:apply-templates select="document(file)/body"/>
</html>
</xsl:result-document>
</xsl:template>
<xsl:template match="/body">
<body>
<xsl:apply-templates select="/body/@* | /body/node()"/>
</body>
</xsl:template>
I get this result (notice the superfluous xmlns attribute on <section>. I get them on other tags as well, but they have the same cause, I guess):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" lang="nl" xml:lang="nl">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<section xmlns="" type="frontmatter">
<p> .... </p>
<p> .... </p>
</section>
</body>
</html>
I'm quite new to XSLT, but am proud to have this system working so far. With help. Now, this namespace issue... Btw: I use XMLSpy 2011.