Re: [xsl] XML tags as map keys and impact on XSLT/XPath

Subject: Re: [xsl] XML tags as map keys and impact on XSLT/XPath
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 21 Jun 2010 12:19:39 -0400
Hi,

At 06:14 AM 6/18/2010, Mike wrote:
On 18/06/2010 07:28, Wolfgang Laun wrote:
Every now and then, people (not me) want to represent a Map<K,V> in XML by using
s.th. like
<map>
<k1>v1</k1>
<k2>v2</k2>
...
</map>
with ki from K and vi from V. Apart from the obvious limitation for K's values, I feel that this is somehow violating the spirit of XML....

I agree: in general it's a poor way of using XML, and it makes it more difficult to process using XSLT.

I agree with everything said in this thread so far (including Mike's analysis of where the system-level problems are in naming elements after values), but I hasten to add that the problems suggested for the XSLT may be overstated, at least if you allow for a little creativity:


<xsl:key name="value-by-key" match="map/*" use="local-name()"/>

While I wouldn't recommend this, I don't see it as entirely illegitimate either, especially if you allow that the format Wolfgang offers has a kind of bizarre elegance for the non-XML savvy user. Which is arguable, I know. :-)

And sometimes it's the job of implementors to indulge the whims of designers.

That being said, I'd probably go with a variant of Andrew's suggestion:

<entry key="k1">v1</entry>
<entry key="k2">v2</entry>
<entry key="k3">v3</entry>

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 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