Hi Robert,
To answer your questions here:

The epub/docbook.xsl stylesheet hardcodes the namespace for each output element it generates, so strictly speaking it does not need the default namespace declaration. It wouldn't hurt, though.

The problem with the stylesheet looking for the fragment file in the stylesheet directory is a result of using the non-namespaced stylesheets to process DocBook 5 documents. When you do that, the stylesheet must first process the input to strip off the DocBook namespace from all the elements, and it saves the result into an internal variable. Then it processes the content of that variable as if it were your input document. However, the variable does not have a directory context, so the stylesheet falls back to the only directory context it has, which is the stylesheet file.

If you are processing primarily DocBook 5 documents, I would highly recommend using the namespace version of the stylesheets (docbook-xsl-ns-1.75.2). It avoids such headaches.

Bob Stayton
Sagehill Enterprises
[email protected]


----- Original Message ----- From: "Robert Nagle" <[email protected]>
To: "Bob Stayton" <[email protected]>
Cc: <[email protected]>
Sent: Thursday, October 15, 2009 9:02 AM
Subject: Re: [docbook-apps] why do user templates generate empty xmlns attributes?


I am happy to report that your explanation makes perfect sense. And
including a xhmtl namespace declaration (in addition to the Transform
namespace)  does the job:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
   xmlns="http://www.w3.org/1999/xhtml";
   version="1.0">

It leaves me wondering why the epub transform wouldn't already include
this information already.

By the way, I figured out the problem with the processing which wasn't
processed. Apparently, it looks for the     <?dbhtml-include
href="fragment1.html"?>   file inside the directory of the default
docbook stylesheet, NOT the directory of the source XML. (This also
seems strange and a little unwieldy for me, but maybe the intent was
to use this functionality not for individual projects. Thanks again.


SystemID: I:\My Documents\xml\noncrappy\epub-xsl1-import.xsl
Engine name: Saxon6.5.5
Severity: warning
Description: Failure reading
file:/I:/My%20Documents/xml/docbook-xsl-1.75.2/docbook-xsl-1.75.2/epub/fragment1.html
- I:\My Documents\xml\docbook-xsl-1.75.2\docbook-xsl-1.75.2\epub\fragment1.html
(The system cannot find the file specified)


Robert

On Wed, Oct 14, 2009 at 4:52 PM, Bob Stayton <[email protected]> wrote:
Well, namespaces are a known confusion factor. There is the namespace on
the input elements, which is the DocBook 5 namespace, and the namespace on
the output elements, which is XHTML's namespace.

In my previous response, I thought we were still talking about reading an
external file with the dbhtml-insert processing instruction to insert an
HTML fragment. If that were the case, then that fragment in the external
file would need:

<html xmlns="http://www.w3.org/1999/xhtml";>
<p>My stuff</p>
</html>

Since this content is just copied, the input namespace also needs to be the
XHTML namespace. Then when that content is copied, the elements are in the
right namespace for XHTML output.

In your present case, however, you are generating the HTML fragment in the
stylesheet's user.header.content template. The xhtml-1_1/docbook.xsl
stylesheet that the epub stylesheet imports has this namespace declaration:

<xsl:stylesheet xmlns=http://www.w3.org/1999/xhtml (among others)

By not including a namespace prefix, this declaration sets the default
output namespace for any generated elements to this namespace. That means
that any output elements that don't otherwise have a namespace assigned to
them will get the XHTML namespace.

However, your stylesheet customization lacks this default namespace
declaration, so the elements your customization generates are *not* in that
namespace (a default namespace is not inherited by xsl:import).

So any stylesheet customization using XHTML output needs to declare this
default namespace. The last example on this page shows this:

http://www.sagehill.net/docbookxsl/OtherOutputForms.html#CustomizeXhtml

Bob Stayton
Sagehill Enterprises
[email protected]


----- Original Message ----- From: "Robert Nagle"
<[email protected]>
To: "Bob Stayton" <[email protected]>
Cc: <[email protected]>
Sent: Wednesday, October 14, 2009 1:47 PM
Subject: Re: [docbook-apps] why do user templates generate empty xmlns
attributes?


Alas, now I am even more confused (but hopeful!).

what do you mean by the "root element of the included html"? I'm not
sure what action I can take here.

i have an index.xml file plus several xinclude files. one such
xincluded file is called nt001.xml.

The top stuff of nt001.xml. looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book [
<!ENTITY % isopub SYSTEM
"http://www.w3.org/2003/entities/iso8879/isopub.ent";>
%isopub;
]>
<chapter xmlns="http://docbook.org/ns/docbook"; version="5.0" xml:id="nt001">
<title>Would Kafka have kept a weblog? </title>


the generated html file nt001.html looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";><head><title>Would Kafka
have kept a weblog?


the top stuff of the index.xml file looks like this

<?xml version="1.0" encoding="UTF-8"?>
<?oxygen
RNGSchema="http://www.oasis-open.org/docbook/xml/5.0/rng/docbookxi.rng";
type="xml"?>
<!DOCTYPE book [
<!ENTITY % isopub SYSTEM
"http://www.w3.org/2003/entities/iso8879/isopub.ent";>
%isopub;
]>
<book xmlns="http://docbook.org/ns/docbook";
xmlns:xi="http://www.w3.org/2001/XInclude";
xmlns:xlink="http://www.w3.org/1999/xlink"; version="5.0" xml:id="index5">
<info>


I wish to add that I can't even begin to guess how to add this
namespace reference or what it would look like. Common sense would
tell me that I'd need to add <html
xmlns="http://www.w3.org/1999/xhtml";> at the beginning of the
xincluded file. If I recall, my xml editor Oxygen couldn't validate
the character entities in my docbook project without a doctype
declaration, and that was preventing me from adding <html
xmlns="http://www.w3.org/1999/xhtml";>. My memory becomes fuzzy.....

thanks for your help. .

Rj






On Wed, Oct 14, 2009 at 1:58 PM, Bob Stayton <[email protected]> wrote:

Hi Robert,
1) The epub stylesheet generates XHTML, which is in the XHTML namespace:

xmlns="http://www.w3.org/1999/xhtml";

You will need to add that namespace attribute to the root element of your
included HTML. If you don't then the processor marks it as being outside
of
the XHTML namespace.



----- Original Message ----- From: "Robert Nagle"
<[email protected]>
To: <[email protected]>
Sent: Wednesday, October 14, 2009 11:30 AM
Subject: [docbook-apps] why do user templates generate empty xmlns
attributes?


When on the advice of Bob Stayton's last email
(http://lists.oasis-open.org/archives/docbook-apps/200910/msg00021.html)
I created a custom template for my customization layer , I notice
something strange.



</head><body><p xmlns=""><b>Hi Mom!</b></p><div class="chapter"
title="Would Kafka have kept a weblog?"><div
class="titlepage"><div><div><h1 class="title"><a
xmlns:saxon="http://icl.com/saxon"; id="nt001"/>Would Kafka have kept a
weblog? </h1></div></div></div>

Two questions:

1)why does <p xmlns=""> show an empty value. (That actually makes the
code invalid and the resulting .epub invalid as well).

2)what is going on here: <a xmlns:saxon="http://icl.com/saxon";> Why
is this namespace value there in the first place?

I notice that these kinds of weirdness/errors pop up all the time
whenever I try to put an xsl:template statement in my customization
layer file. I could live with the second error, but not the first.
Any idea what is causing this to happen?



My customization layer is pretty vanilla. It's for epub/chunked html
output.

********************
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
<xsl:import


href="http://docbook.sourceforge.net/release/xsl/1.75.2/epub/docbook.xsl"/>
<xsl:param name="epub.metainf.dir">META-INF/</xsl:param>
<xsl:param name="epub.oebps.dir">OEBPS/</xsl:param>
<xsl:param name="use.id.as.filename">1</xsl:param>
<xsl:param name="html.stylesheet">first.css</xsl:param>
<!--<xsl:param name="show.comments">1</xsl:param>-->
<xsl:param name="label.from.part" select="0"></xsl:param>
<xsl:param name="chapter.autolabel">0</xsl:param>
<xsl:param name="part.autolabel">0</xsl:param>
<xsl:param name="img.src.path">images/</xsl:param>
<xsl:template name="user.header.content">
<p><b>Hi Mom!</b></p>
</xsl:template>
</xsl:stylesheet>
*******************

--
Robert Nagle
htpt://www.robertnagle.info

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]










---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to