[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: single quotes instead of double

Subject: Re: single quotes instead of double
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 21 Nov 2011 07:41:41 -0500
Re:  single quotes instead of double
At 2011-11-21 11:44 +0000, Andrew Welch wrote:
On 21 November 2011 11:35, Szabo, Patrick (LNG-VIE)
<patrick.szabo@xxxxxxxxxxxxx> wrote:
> Hi,
>
> I'm currently working together with external developers and they sent me
> a stylesheet that has the following code in it:
>
> <xsl:when test="$mode = 'versionbranch'">
>         <xsl:value-of select='$documentid'/>
> </xsl:when>
>
> As you can see there are single quotes where normally at least i would
> write double quotes.
>
> I'm wondering if that could make any difference in any circumstances.

No but while it's technically legal it's inconsistent with the line
above, and with xslt style in general.

I disagree with making this generalization.


The general rule is - use double quotes.

It is purely a matter of convenience for the writer of the expression. And an XSLT processor can choose either quote to use as an attribute literal delimiter.


I feel *obliged* to use single quotes for an attribute in XSLT that uses the "url()" syntax in an XSL-FO stylesheet because of the allowed characters in a URI:

<external-graphic src='url("{$uri}")'/>

Because a single quote is allowed in a valid URI, double quotes inside the url() are necessary.

Of course I could have written the above as:

external-graphic src="url(&#34;{$uri}&#34;)"

or:

external-graphic src="url(&#x22;{$uri}&#x22;)"

and used double quotes for the attribute delimiter, but I think this is harder to maintain down the road for someone reading the numeric character entities.

For someone reading XML, the attribute delimiter chosen should be irrelevant because it is, syntactically, irrelevant. So use whatever you want and don't bother imposing a style.

I find I simply use as the closing delimiter whichever quote I happened to type for the opening delimiter, which is not always a double-quote. Sure, it usually is, but since it doesn't have to be I don't force myself.

I hope this helps.

. . . . . . . . . . . Ken

--
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour video lecture: XSLT/XPath 1.0 & 2.0 http://ude.my/t37DVX
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.