You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Peter Verhage <pe...@ibuildings.nl> on 2000/10/04 15:33:44 UTC

Attribute order

I have an xml page which get transformed into a html document (with a
xslt).
But because of the way Cocoon (Xerces really...) handles the order of
attributes the
attributes of a meta tag get ordered wrong, so that it does not work
anymore (at least not in Netscape, did not try Explorer).

The input is:
<meta http-equiv="refresh" content="15;URL=include.xml#bottom"/>

The output is:
<meta content="15;URL=#bottom" http-equiv="refresh">

That won't work... If I see it correctly Xerces alphabetically orders
the attributes or something similar like that. As you can understand I
don't want that, at least not when I use certain tags like the meta tag.

How can I prevent Xerces from doing this? I don't want to edit source
code, I just want to change something to the input, that will make sure
I get the correct output...

I also asked this question at the Xerces mailinglist, but I don't think
I'm the first one who is having this problem. So maybe already knows the
answer, and if not, it can also be usefull to learn :)

With best regards,

Peter



-- 
Peter Verhage       <pe...@ibuildings.nl>
ibuildings.nl BV - information technology
http://www.ibuildings.nl -  0118 41 50 54

Re: Attribute order

Posted by Berin Loritsch <bl...@infoplanning.com>.
----- Original Message ----- 
From: "Peter Verhage" <pe...@ibuildings.nl>
To: <co...@xml.apache.org>
Sent: Wednesday, October 04, 2000 9:33 AM
Subject: Attribute order


> I have an xml page which get transformed into a html document (with a
> xslt).
> But because of the way Cocoon (Xerces really...) handles the order of
> attributes the
> attributes of a meta tag get ordered wrong, so that it does not work
> anymore (at least not in Netscape, did not try Explorer).
> 
> The input is:
> <meta http-equiv="refresh" content="15;URL=include.xml#bottom"/>
> 
> The output is:
> <meta content="15;URL=#bottom" http-equiv="refresh">

Actually, this has to do with going through Xalan.  There is no real
order for the attributes as in XML it doesn't matter--they are implemented
with something like a Hashtable.

I have successfully placed all my meta tags in the XSLT sheet, and they
get generated correctly.  The problem comes when you use any of the
following methods to generate attributes:

<xsp:attribute name="foo">bar</xsp:attribute>
<xsl:attribute name="bar">baz</xsl:attribute>

However if you use the following construct in your XSLT it should work:

<xsl:template select="root-element">
  <html>
    <head>
      <xsl:if test="however you mark it">
        <meta http-equiv="refresh" content="15;URL=#bottom"/>
      </xsl:if>
    </head>
    <body>
      <xsl:apply-templates/>
    </body>
   </html>
</xsl:template>