Re: [xsl] position last and attributes

Subject: Re: [xsl] position last and attributes
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 20 Sep 2012 15:26:10 -0400
Hi John,

On 9/20/2012 2:16 PM, John P. McCaskey wrote:
Could you characterize where in your algorithms you find the order of
nodes along the attribute axis important or useful?
An example right now is a stylesheet that renders TEI documents in a
browser. The attributes of an element are listed in two places,
displayed differently. I'd prefer they get displayed in the same order
in both places.

You can always, if you prefer, sort them into the order you wish them to be displayed in. This is trivial to do if ordering them alphabetically by name is acceptable, less so (but still doable) if you want some other kind of canonical order.

And since I know that encoders in this community, by habit and tool,
enter attributes in a certain order, I'd like the displayed order to be
document order.

By "document order" I take it you mean the order in which they happen to be represented in the XML (syntax) instance being parsed.

As this thread has stated (and it seems to be the only thing agreed on here), the document order given to and in XSLT processing has no necessary relation to the order of appearance of attributes in their tags in the instance. Your parser might happen to build documents that look this way, but another might not.

This means that XSLT can't actually render an XML document with "tag fidelity", but this is already true in other ways. For example, you can't know where CDATA marked sections may have been used in your source XML instance.

You can ameliorate this, if it's a problem, by supplementing your XSLT with another pre-process (not XSLT) that amends the document coming in to give the necessary information in some way that the subsequent process can then read. But mostly people don't find the requirement for perfect tag fidelity to be that pressing.

Right now, I'm just guessing that the processor will use document order,
and so far I've been right. Fortunately, if it doesn't, nothing
catastrophic happens. So I'm not bothering with any hoop jumping on this

This is probably wise. I'm sure that rendering TEI you have more interesting things to worry about. :-)


Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.      
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
  Mulberry Technologies: A Consultancy Specializing in SGML and XML

Current Thread