[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: rogue xmlns="" in output xhtml

Subject: RE: rogue xmlns="" in output xhtml
From: "Paul Spence" <paul.spence@xxxxxxxxx>
Date: Sat, 15 Oct 2005 11:20:32 +0100
saxon xhtml
> > The problem is those sporadic random 'xmlns=""'s dotted throughout the
> > document.
> 
> Actually, the problem is that the "title" and "link" elements are in the
> null namespace, not in the XHTML namespace. They are there because that's
> where you put them: without seeing the code that generated these elements,
> it's hard to tell you what you did wrong.

Sorry, since I was not really sure exactly how this is happening, I was not
sure which code to copy.

Here's a summary of my setup:

I have various stylesheet modules in my application. The architecture is a
little complex, because it's an integrated publishing app that tries to cope
with many different input XML structures and produce output within a unified
framework, but I'll do my best to keep it concise.

Firstly, I have what I call a DRIVER stylesheet, that merely contains
'xsl:includes' to other stylesheets:

--------------------------------------------------------------

<?xml version="1.0" ?>
<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:saxon="http://icl.com/saxon"
    xmlns="http://www.w3.org/1999/xhtml"
 	extension-element-prefixes="saxon"
               exclude-result-prefixes="saxon"
                version="1.1">

    <xsl:output method="saxon:xhtml" 
        encoding="UTF-8"
    omit-xml-declaration="yes"
    indent="yes" 
    doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" 
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
/>
    
<!-- GENERAL INCLUDES -->
<xsl:include href="..\common\proj_tpl.xsl" />
<xsl:include href="..\common\proj_vars.xsl" />
<xsl:include href="..\common\proj_key.xsl" />

<!-- INCLUDES COMMON TO MAIN PUBLICATIONS -->
<xsl:include href="..\common\proj_tei_com.xsl" />

<!-- INCLUDES SPECIFIC TO THIS DRIVER -->
<xsl:include href="proj_type01_spec.xsl" />
<xsl:include href="proj_type01_tpkey.xsl" />

--------------------------------------------------------------

One of these modules then tries to produce output:

--------------------------------------------------------------

<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:saxon="http://icl.com/saxon"
    xmlns="http://www.w3.org/1999/xhtml"
 	extension-element-prefixes="saxon"
               exclude-result-prefixes="saxon"
                version="1.1">

<xsl:template match="TEI.2">

   <xsl:document
href="{$outputroot}/{$outswitch}/{$pathcreator}/{$filename}.html"
method="saxon:xhtml">
     <xsl:call-template name="html_tpl">
     </xsl:call-template>
   </xsl:document>

</xsl:template>

--------------------------------------------------------------

This then calls on another module that in turn sets up an HTML 'template'
that populates the different information areas of the output web page. It
looks something like the following:

--------------------------------------------------------------

<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:saxon="http://icl.com/saxon"
    xmlns="http://www.w3.org/1999/xhtml"
 	extension-element-prefixes="saxon"
                version="1.1"
                xmlns:filename="filename.uri"
               exclude-result-prefixes=" saxon filename">

<xsl:template name="html_tpl">

<!-- START HTML -->
   <html xmlns="http://www.w3.org/1999/xhtml" > 
        
<head>

  <xsl:call-template name="ctpl_htmltitle" />

--------------------------------------------------------------

The template called here is in another module, and looks like this:

--------------------------------------------------------------
<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:saxon="http://icl.com/saxon"
    xmlns="http://www.w3.org/1999/xhtml"
               exclude-result-prefixes="saxon"
   xmlns:date="http://exslt.org/dates-and-times"
   extension-element-prefixes=" saxon date"
   version="1.1">

<xsl:template name="ctpl_htmltitle">
    
<!-- Current option: option 1 -->
    <xsl:variable name="htmltitle"
select="/TEI.2/teiHeader/fileDesc/titleStmt/title[1]" />

    <title>
      <xsl:text>PROJFULLNAME</xsl:text>
      <xsl:if test="/TEI.2/teiHeader/fileDesc/titleStmt/title">
               <xsl:text>: </xsl:text>
         <xsl:value-of select="$htmltitle" />
      </xsl:if>  
    </title>

    <link rel="stylesheet" type="text/css"
href="{$linkroot}/Assets/c/global.css" />
    
</xsl:template>
--------------------------------------------------------------

As you may note, I have added a declaration specifying XHTML as the default
namespace to all of the modules since my original post (and everything
*seems* to work fine now):

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

I have added an exclude-result-prefixes attribute to xsl:stylesheet too.

Is this the solution?

I'd also like to make sure I understand what went wrong originally. I have
an intermediate knowledge of XSLT, but start to feel woozy when I try to get
my head round namespaces.

I have been using this code for a few years to create HTML4 without any
problems, so was surprised that it arose when I converted to XHTML. I'm
guessing it has to do with the fact that I added the XTHML namespace to the
code thus:

   <html xmlns="http://www.w3.org/1999/xhtml" >

And the distinction on Qualified names, whereby elements whose names don't
contain a colon belong to the default namespace, whereas attribute names
that don't contain a colon don't belong to any namespace. Has this got
something to do with it? I'm still struggling to see why it happened some of
the time and not all of it.

Thanks,
Paul

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.