views:

60

answers:

2

Every single time I've read about the meta tags, the attribute where in this order for the description:

<meta name="description" content="..." />

First name, then content. It's also like that in the Google Webmaster documentation. Basically, it's like that everywhere.

Now in a .jsp (in XML notation) I've got the following:

<meta name="description" content="${metadesc}"/>

So it's name first, then content.

Yet on the generated webpage, I get this:

<meta content="...(200 chars or so here making it a very long line)..." name="description"/>

Somehow the attributes have been inversed. Because the content follows the official W3C and Google recommendations, the content is a bit less than 200 characters long, which makes it a major pain to "visually verify" that the name attribute is correctly there (I've got to scroll).

Anyway...

Why are these attribute not appearing in the order defined in the .jsp?

Can I force them to appear in the same order as I wrote them in my .jsp?

I realize the resulting tag may be valid... But I can also imagine a lot of very creative ways to have valid tags which users would be very upset about. Does this make any sense to inverse these attributes?

EDIT wow, just wow... If I invert the attributes in my .jsp (that is, writing them in the "wrong" order), then they appear as I want them to appear in the generated web page. (Tomcat 6.0.26 btw)

+1  A: 

Attribute order is a foreign concept in XML. Either something has an attribute or it does not, there's nothing in XML that states one attribute should (or must) come before another one.

Think of it this way, you have a name, and you have a hair color. Both are attributes of you, but under what condition must you have a hair color before you have a name (or after you have a name).

Elements do permit ordering to some degree, because you can specify the order of nested items within DTDs and XSDs.

Edwin Buck
@Edwin Buck: but you're not answering the question... I stated that I could think about a lot of very creative ways to create completely valid XML which would still upset users. Don't you think it's a reasonable expectation to have attributes appear in the order they were defined in? What if every time you saved an XML document from your text editor your text editor were to invert attributes? Would you think about your hair color analogy or wouldn't you maybe think that there's something weird going on? Honestly?
NoozNooz42
@Edwin Buck: OK +1 and I accept your answer for BalusC is not disagreeing with you and he has enough points :) (+1 to BalusC too) I'm still a bit surprised but oh well...
NoozNooz42
I realize that it might not seem like an answer to the question, but when the standard doesn't support attribute ordering, it doesn't make a lot of sense to talk about out-of-order attributes, even if there are cases where attribute ordering would make sense. Certainly in-order attributes would assist you greatly (due to your logic) but the underlying technology just doesn't guarantee attribute order. When building a solution, you can't fault tools for following the specification, even if it doesn't make sense in some greater context.
Edwin Buck
+1  A: 

Unfortunately, that's the nature of XML. I have never used JSPX, but I can imagine that it's just been parsed by some XML tool, stored in some tree structure in memory and then rendered to HTML. The attribtues might be stored in an unordered datastructure. I don't think that you will have any control about that. I personally wouldn't worry about this that much. JSPX is not the only in this, many other XML based view/template technologies may behave the same. The only who will worry about the generated HTML output are puristic webdevelopers and I don't think that this is the major audience of the website in question, is it? ;)

It absolutely doesn't matter for webbrowsers, webbots, SEO, etc.

BalusC