Re: [xsl] Beginner: adding xmlns:mml attribute

Subject: Re: [xsl] Beginner: adding xmlns:mml attribute
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 8 Jan 2003 16:51:43 GMT
I'm all in favour of sneaking more discussion of MathML onto this
list...

It's best not to think of xmlns:xxx as an attribute as it doesn't
generate an attribute in the Xpath model @* won't see it)
and you can't generate that declaration with xsl:attribute.

the namespace is just part of the element ofr attribute name, which is
just done using a syntax that has a prefix and something that looks like
an attribute for historical reasons.

so...

<HTML XMLNS:m="http://www.w3.org/1998/Math/MathML";>

That is the HTML element in no namespace togetehr with a declaration
that would make child elements prefixed with m: in the mathml namespace.

or it would be except that XML is case sensitive and xmlns has to be
lower case, and its better to make HTML lower case as well
so then you can easily switch to xhtml later when it has to be <xhtml
xmlns="http://www.w3.org/1999/xhtml";> 

so to generate the html element you just want
<html>

don't worry aboy the namespace declaration for MathML: when you add some
elements in the MathML namespace to the result, a suitable namespace
declaration will be added. (Probably not on the html element, you can
fix that although it does't actually matter).

   <html xmlns:m="http://www.w3.org/1998/Math/MathML";>
     <xsl:element name="html" 
namespace="http://www.w3.org/1998/Math/MathML"/>
       <head>
       </head>
     </html>
</xsl:stylesheet>

but that gives me simply
<html>
<head>
</head>
</html>


Are you sure? It looks to me like you are generating nested html elements
in different namespaces and should get something like

<html xmlns:m="http://www.w3.org/1998/Math/MathML";>
<html xmlns="http://www.w3.org/1998/Math/MathML";>
<head xmlns="">
</head>
</html>
</html>

that is

html in no namespace
html in the mathml namespace
head in no namespace


This is assuming that you have not changed the default namespace in the
stylesheet from "no namespace". if you have xmlns="xxx" on your
xsl:stylesheet element then the above snippet should generate

<html xmlns="xxx" xmlns:m="http://www.w3.org/1998/Math/MathML";>
<html xmlns="http://www.w3.org/1998/Math/MathML";>
<head xmlns="xxx">
</head>
</html>
</html>

that is

html in xxx namespace
html in the mathml namespace
head in xxx namespace

Rather than genrate HTML (and use Microsoft's bizare non standard
Namespaces in HTML bindings, which you haven't shown here but will need
for mathplayer) you may prefer to generate xhtml by setting
<xsl;output="xml" and
adding a link to (a local copy of) the stylesheet  described at
http://www.w3.org/math/XSL
this avoids many of the problems and means your document will also work
in mozilla and netscape.

In which case you want

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


<xsl:template match="/">
<xsl:processing-instruction name="xml-stylesheet">type="text/xsl" href="pmathml.xsl"</xsl:processing-instruction>
<html>
....



David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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


Current Thread