[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] generate XHTML header without causing xmlns attributes in e.g. ?
Subject: RE: [xsl] generate XHTML header without causing xmlns attributes in e.g. <table>?
From: Chris Loschen <loschen@xxxxxxxxxxxxx>
Date: Fri, 17 Oct 2003 10:20:39 -0400


I'm also using xalan-j, and I've used this sort of code to avoid the empty namespace
declaration:


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:oeb="http://openebook.org/namespaces/oeb-document/1.0/"
exclude-result-prefixes="oeb">
...
<xsl:template match="/">
<xsl:element name="html" xmlns="http://openebook.org/namespaces/oeb-document/1.0/">
...
</xsl:template>


...

<xsl:template match="LINK">
<xsl:choose>
<xsl:when test="@TYPE='URL'">
<a xmlns="http://openebook.org/namespaces/oeb-document/1.0/">
<xsl:attribute name="href"><xsl:value-of select="@DEST"/></xsl:attribute>
<xsl:apply-templates />
</a>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>


</xsl:stylesheet>

***

As I understand it, because you've named the XHTML namespace as the null-prefix namespace,
and you've assigned the elements in your stylesheet to that namespace (by not putting a prefix
on them or explicitly assigning them to something), XSLT is concluding that the output elements
belong to that null-prefix namespace. I'm working around that by explicitly assigning them to the
namespace that I'm excluding from my results. I still use the null-prefix namespace declaration in
my output by declaring it in the html element above. You'd just need to replace my uses of oeb
with your uses of XHTML.


I've had good results with this -- hope it helps!


At 09:24 AM 10/17/03, you wrote:
> > But the resulting table tag in XHTML is:
> > <table xmlns="" class="parameters" cellspacing="0"
> > cellpadding="3" border="1">
> >   <thead>
> >     <tr>
> >        ...
> >
> This code looks perfectly correct to me.
>
> This means either:
> * I haven't spotted your error, or
> * There is something odd in a part of the stylesheet you
> haven't shown us, or
> * you are using a buggy XSLT processor (unlikely if you are
> using one of the widely-used ones, but I don't think you told
> us which one it was).
>
> The next thing I would do is to run it against a different
> processor and see if the results are the same.
>

Ahh, Michael,
You were correct in assuming it was an odd behaviour by the XSLT processor.

I've used Xalan-J, up till now...

Here is the <table> tags from Xalan-j and MSXML3 processors

Xalan-J:
<table class="querydef" cellspacing="0" cellpadding="3" border="1">
<table xmlns="" class="parameters" cellspacing="0" cellpadding="3" border="1">

MSXML3:
<table border="1" cellpadding="3" cellspacing="0" class="querydef">
<table border="1" cellpadding="3" cellspacing="0" class="parameters">

Hmm - Looks like Xalan-J misinterprets something, the output in MSXML3 is as I would expect it to be.

However, in MSXML3 I have another unrelated problem.

Even though I specify
<xsl:output method="xml" encoding="ISO-8859-1" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="DTD/xhtml1-strict.dtd" />


The character encoding line in the XHTML generated by MSXML is:
<?xml version="1.0" encoding="UTF-16"?>
As opposed to:
<?xml version="1.0" encoding="ISO-8859-1"?>
In the output from Xalan-J (which is what I expected it to be).

Is there a way to force MSXML to write ISO-8859-1 as character encoding instead - if so, I can use MSXML instead of Xalan-J?

Flemming

XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list

--Chris


----------------------------------------------------------------------------------------
Texterity ~ Digital Delivery Made Simple
----------------------------------------------------------------------------------------
Chris Loschen, XML Developer
Texterity, Inc.
144 Turnpike Road
Southborough, MA 01772 USA
tel: +1.508.804.3033
fax: +1.508.804.3110
email: loschen@xxxxxxxxxxxxx
http://www.texterity.com/



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list




Current Thread
Keywords