Re: Handling documents with Namespaces

From
Jens Stavnstrup <>
Date
2003-09-25T06:59:34+00:00
ID
Thread
Re: Handling documents with Namespaces
I forgot the examples, here they are

On Thu, 25 Sep 2003, Jens Stavnstrup wrote:

All,

I have defined an extension to docbook representing a special purpose 
database, which I merge with a normal docbook document. As long as my 
element was different from the DocBook elements, I had no problems, but 
with the upcoming DTD v. 4.3, I have identifed elements introduced in 4.3, 
so now I am considering using namespace, but how,

AI have experimented quite a bit, but havn't yet figured out so here is a 
simple example. in the form of a XHTML document and and XST stylesheet.

The result is an exact copy of the input document? 

Apparently the template for P is considered belonging to a different 
namespace than all the elements in the document.

It will work if I e.g. define a prefix for the xhtml namespace, and add 
this prefix on each template

   <xsl:template match="xhtml:p">
     ...

There got to be a better way ?


--------------------------
demo.xml
--------------------------

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	              "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


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


<body>

<p>Some text</p>

</body>

</html>


--------------------------
demo.xsl
--------------------------

<?xml version="1.0" encoding="ISO-8859-1"?>

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


<xsl:template match="p">
  <p><strong>
    <xsl:apply-templates/>
  </strong></p>
</xsl:template>


<xsl:template match="@*|node()">
  <xsl:copy>
    <xsl:apply-templates select="@*"/> 
    <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

</xsl:stylesheet>




Regards,

Jens