Re: [xsl] enclosing attribute in single quote

Subject: Re: [xsl] enclosing attribute in single quote
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 27 Apr 2009 17:52:35 -0400
Dr Sperberg-McQueen,

At 11:45 PM 4/26/2009, you wrote:
On 21 Apr 2009, at 16:48 , Wendell Piez wrote:
I take it the recipient of the data knows that by requiring XML with
only single quotes used as attribute value delimiters, they are
asking for XML-that-is-not-XML?

Well, that's kind of harsh, isn't it? XML does allow single quotes to be used, so <a x='y'/> is every bit as much a conforming XML document as <a x="y"/>.

Yes, I suppose it's a bit harsh, but only a bit. Maybe not XML-that-is-not-XML, but hyper-XML.


If memory serves, ISO 8879 referred to rules of this kind as
"application conventions".  So they have always been part of the
story of generic markup.

Indeed, and I recognize the usefulness of application conventions (I hope my Balisage paper gets accepted); in fact I advocate them all the time.


But there's also a big difference between such a convention with respect to application semantics (where indeed such conventions are the grist of the mill) and such a convention that does nothing for semantics, but only restricts the tools that can be used.

I also acknowledge that there may be good reasons for such conventions (desperate hackers included), which is why I try to be nice (I do!). But (as you know) they should be well-controlled and carefully scoped, or they will bite you. The very fact that the OP had to ask XSL-List how to get a serializer to impose a non-standard syntactic restriction is an indication of something.

Frankly, if the naming and design rules for prominent XML
vocabularies can require the use of specific namespace prefixes
for specific namespaces, and expect to elicit conformance instead
of incredulous laughter, well, then I guess application conventions
are alive and well and living among us. (I confess that my response
was incredulous laughter, but that didn't persuade them to change
the rules.)

Don't get me started on the confusion sown by namespaces into this area. (Which isn't meant as a criticism of namespaces, as I don't have an alternative to suggest. Just an observation.)


There may well be SAX serializers which accept an invocation-time
parameter to prefer single quotes when emitting attribute values
(I've never looked so I don't know).  If there aren't, it really
shouldn't be too very hard to write one, to pair it with a SAX
parser, and to put together a filter that will normalize any
XML input by emitting it with single quotes only around attributes.

Or, as I said to the OP, write yourself a hyper-XML-syntax serializer that does what you want using the XSLT output method="text".


Start with Evan Lenz's XML-to-string converter (http://www.xmlportfolio.com/xml-to-string/), which will save you some work. Isn't this monstrous? (See, I can be pragmatic too. :-)

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