xsl-list
[Top] [All Lists]

RE: [xsl] empty namespace added on elements E.g. <h4 xmlns="">

2010-01-12 06:03:27

You're creating an <html> element in the XHTML namespace, and then you
create an <h4> element in no namespace: to prevent the h4 element going into
the XHTML namespace, Saxon has to generate the xmlns="" declaration. If you
want the h4 element to be in the XHTML namespace, which I guess you do, then
say so by coding it as <h4 xmlns="http://www.w3.org/1999/xhtml";>.

(A literal result element is copied literally from the stylesheet to the
result document. There's no magic process whereby the namespace of the
element is changed to match that of its new parent.)

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 



-----Original Message-----
From: Robby Pelssers [mailto:robby(_dot_)pelssers(_at_)ciber(_dot_)com] 
Sent: 12 January 2010 11:42
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Cc: Robby Pelssers
Subject: [xsl] empty namespace added on elements E.g. <h4 xmlns=""> 

Hi all,

The snippet below is an extract of a stylesheet which 
transforms a DITA
map and it's topics into a xhtml page.    I stripped off most of the
stylesheet and left in the template responsible for 
transforming  a p-topic title into a xhtml <h4>.

However... I tried to validate the generated xhtml page and 
somehow the snippet below gets generated....
 
<h4 xmlns="">4.   Marking</h4>

Can someone explain what could be causing Saxon to add an 
empty namespace attribute to the <h4> tag??  I'm using Saxon 8.7.


Kind regards,
Robby Pelssers


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

<?xml version="1.0" encoding="UTF-8"?>
<!--
  Author: Robby Pelssers
  This stylesheet transforms the generated DITA map/topics 
into 1 single xhtml page
-->

<xsl:stylesheet version="2.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:xs="http://www.w3.org/2001/XMLSchema";
  exclude-result-prefixes="xs">
  
  <xsl:param name="contextPath"/>
  
  <xsl:output method="xml" version="1.0" encoding="UTF-8" 
indent="yes"/>

  <xsl:template match="/">
    <html xmlns="http://www.w3.org/1999/xhtml";>
      <head>
        <meta http-equiv="Content-Type"
content="text/html;charset=UTF-8" />     
          <title>Datasheet <xsl:value-of 
select="Datasheet/@id"/> preview SPIDER</title>
        <link type="text/css" rel="stylesheet"
href="resource/external/css/styles.css"/>

      </head>
      <body class="yui-skin-sam">
        <div class="preview">
          <h2 class="p-application-title"><xsl:value-of
select="Datasheet/@id"/></h2>
          <xsl:apply-templates select="Datasheet/map"/>
        </div>   
      </body>
    </html>
  </xsl:template>


  <xsl:template match="p-topic/title">
    <xsl:variable name="numberOfPrecidingTopics"
select="count(parent::p-topic/preceding-sibling::p-topic)"/>
    <h4><xsl:value-of select="concat($numberOfPrecidingTopics + 1, '.
', .)"/></h4>
  </xsl:template>


  <!-- copy all nodes and attributes which are not processed 
by one of available templates -->
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>
--------------------------------------------------------------
----------
---------------

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--