Click to See Complete Forum and Search --> : Attributes order after XSLT transformation


Mr. Tomaszek
April 20th, 2005, 01:53 AM
Hi - this is my another problem wyth xslt transformation

I'm using XSLT below

<xsl:output method="xml" version="1.0" encoding="utf-8" omit-xml-declaration="no"/>

<xsl:template match="/">

<xsl:element name="ofe:ofe" namespace="urn:ofe">
<xsl:attribute name="wersja">
<xsl:text>1.0</xsl:text>
</xsl:attribute>
</xsl:element>


and I'm getting result:


<?xml version="1.0"?>
<ofe:ofe wersja="1.0" xmlns:ofe="urn:ofe"/>


which it's ok but order of parameters is not correct
it should be


<?xml version="1.0"?>
<ofe:ofe xmlns:ofe="urn:ofe" wersja="1.0" />

Please help - what I have to do to change it?
Big thanx in advance.

khp
April 20th, 2005, 04:51 AM
It would surprise me if that was possible. At least not consistently.
In XML attributes may not be assigned an order.

Most likely the XSL processor stores the 2 attributes in a hash table before outputting them, thus their order depends on the order of their hash key values, which could be anything.

I'am sorry this was probably not the answer you wanted. :cry:

Mr. Tomaszek
April 20th, 2005, 05:32 AM
Hi,
maybe I can add one attribute and later (in loop or something) add another assuring in that way correct order of them? Do you think it will be possible?

khp
April 20th, 2005, 06:53 AM
No, there's a limit to how much later you can add more attributes to an element in XSL. As soon as you begin producing element content you cannot add more attributes.

Mr. Tomaszek
April 20th, 2005, 07:39 AM
I'am sorry this was probably not the answer you wanted. :cry:
Yes - really. Anyway; thanx for your time. If anything sometime comes to your mind please post it it here. Thanx.