Olaf Buwen | 4 Jan 15:55
Picon

Attributes with dashes

Hi,

in one of my projects, I found that
"tal:attributes='foo-bar data/foo/bar'" does not work, although XML 
allows attributes with dashes.

As a workaround, I modified the regular expression in
Petal/Canonicalizer/XML.pm, line 547 from
     /^\s*((?:\w|\:)+)\s+(.*?)\s*$/
to
     /^\s*((?:[-\w]|\:)+)\s+(.*?)\s*$/
so that dashes now are recognized.

Is there any interest for this patch to be included in the next release?

Regards

Chris Croome | 4 Jan 16:23
Picon
Favicon

Re: Attributes with dashes

Hi

On Tue 04-Jan-2005 at 03:55:35PM +0100, Olaf Buwen wrote:
> 
> in one of my projects, I found that
> "tal:attributes='foo-bar data/foo/bar'" does not work, although XML 
> allows attributes with dashes.
> 
> As a workaround, I modified the regular expression in
> Petal/Canonicalizer/XML.pm, line 547 from
>     /^\s*((?:\w|\:)+)\s+(.*?)\s*$/
> to
>     /^\s*((?:[-\w]|\:)+)\s+(.*?)\s*$/
> so that dashes now are recognized.
> 
> Is there any interest for this patch to be included in the next release?

As long as it doesn't break anything I think this would be a good
reason for a new release :-)

Chris

--

-- 
Chris Croome                               <chris@...>
web design                             http://www.webarchitects.co.uk/ 
web content management                               http://mkdoc.com/   

Bruno Postle | 4 Jan 18:33
X-Face

Re: Attributes with dashes

On Tue 04-Jan-2005 at 15:55 +0100, Olaf Buwen wrote:
>
> "tal:attributes='foo-bar data/foo/bar'" does not work, although XML 
> allows attributes with dashes.
>
> As a workaround, I modified the regular expression in
> Petal/Canonicalizer/XML.pm, line 547 from

>      /^\s*((?:\w|\:)+)\s+(.*?)\s*$/
> to
>      /^\s*((?:[-\w]|\:)+)\s+(.*?)\s*$/

It would be nice if either regex matched the XML specification for 
attribute names.  Petal could generate attributes like these which 
I'm sure are not within the XML spec:

      -foo="whatever"
      --bar="whatever"

This might also cause trouble with the "--value" system for passing 
arguments to methods.

Also I think this is a valid XML attribute:

    foo_2.BAR="whatever"

So the regex needs to look something like this:

     /^\s*([A-Za-z_:][A-Za-z0-9_:.-]*)\s+(.*?)\s*$/

(Continue reading)

William McKee | 4 Jan 19:48
Favicon

Re: Attributes with dashes

On Tue, Jan 04, 2005 at 05:33:24PM +0000, Bruno Postle wrote:
> Comments?  I'm no regular expression guru.

I'm not regex pro either but I think trying to make Petal more closely
work with the XML specs is worthwhile. Speaking of which, does anyone
have a link to this spec?

William

--

-- 
Knowmad Services Inc.
http://www.knowmad.com

Olaf Buwen | 4 Jan 20:51
Picon

Re: Attributes with dashes


from the specs:

http://w3c.org/TR/2004/REC-xml-20040204/#sec-common-syn

2.3 Common Syntactic Constructs
[Definition: A Name is a token beginning with a letter or one of a few
punctuation characters, and continuing with letters, digits, hyphens,
underscores, colons, or full stops, together known as name characters.]

Names beginning with the string "xml", or with any string which would
match (('X'|'x') ('M'|'m') ('L'|'l')), are reserved for standardization
in this or future versions of this specification.

...
[4]   	NameChar	   ::=   	Letter | Digit | '.' | '-' | '_' | ':' |
CombiningChar | Extender
[5]   	Name	   ::=   	(Letter | '_' | ':') (NameChar)*

IMHO, a full regexp to check attribute names is a little bit of
overkill; look for "B Character Classes" in the mentioned document to
see what I mean.

a regexp of the form (no production quality code, just a starting point!)
/([_:a-z][-_\.a-z0-9]*)/i
should be sufficient for most cases.

just my 2 cents

William McKee schrieb:
(Continue reading)

Olaf Buwen | 4 Jan 21:04
Picon

Re: Attributes with dashes

you are right; your example

 > So the regex needs to look something like this:
 >
 >     /^\s*([A-Za-z_:][A-Za-z0-9_:.-]*)\s+(.*?)\s*$/
 >

is rather close to the "perfect" solution, just escape the "." to
	/^\s*([A-Za-z_:][A-Za-z0-9_:\.-]*)\s+(.*?)\s*$/

Bruno Postle schrieb:
> On Tue 04-Jan-2005 at 15:55 +0100, Olaf Buwen wrote:
> 
>>
>> "tal:attributes='foo-bar data/foo/bar'" does not work, although XML 
>> allows attributes with dashes.
>>
>> As a workaround, I modified the regular expression in
>> Petal/Canonicalizer/XML.pm, line 547 from
> 
> 
>>      /^\s*((?:\w|\:)+)\s+(.*?)\s*$/
>> to
>>      /^\s*((?:[-\w]|\:)+)\s+(.*?)\s*$/
> 
> 
> It would be nice if either regex matched the XML specification for 
> attribute names.  Petal could generate attributes like these which I'm 
> sure are not within the XML spec:
> 
(Continue reading)

William McKee | 4 Jan 21:20
Favicon

Re: Attributes with dashes

On Tue, Jan 04, 2005 at 09:04:37PM +0100, Olaf Buwen wrote:
> is rather close to the "perfect" solution, just escape the "." to
> 	/^\s*([A-Za-z_:][A-Za-z0-9_:\.-]*)\s+(.*?)\s*$/

I'm pretty sure that's not necessary inside of []. See Camel p.64 (2nd
ed).

  "Note that most other metacharacters lose their meta-ness inside
  square brackets."

William

--

-- 
Knowmad Services Inc.
http://www.knowmad.com

Olaf Buwen | 4 Jan 23:08
Picon

Re: Attributes with dashes

Oops, I really missed that point, you are right!

William McKee schrieb:
> On Tue, Jan 04, 2005 at 09:04:37PM +0100, Olaf Buwen wrote:
> 
>>is rather close to the "perfect" solution, just escape the "." to
>>	/^\s*([A-Za-z_:][A-Za-z0-9_:\.-]*)\s+(.*?)\s*$/
> 
> 
> I'm pretty sure that's not necessary inside of []. See Camel p.64 (2nd
> ed).
> 
>   "Note that most other metacharacters lose their meta-ness inside
>   square brackets."
> 
> 
> William
> 

Simon McCaughey | 5 Jan 09:55

[OT] UK based hosting

Hi

Sorry for the OT post, but someone on here may be able to help :)

I am looking for a UK host who will provide mod_perl, to host my petal based
site, or other recommendations

I currently have 2 accounts, one with xcalibre, whose servers seem slow, and
their support appear to be asleep. The other is with web-mania, they are
cheep, and their servers are so fast that the Petal disk cache is fast
enough, but thy give occasional 500 errors, which are definitely not my
fault, so I need an alternative. I like these 2 hosts because they provide
full ssh access

Thanks

Simon

Chris Croome | 5 Jan 11:56
Picon
Favicon

Re: [OT] UK based hosting

Hi

This is this list of people doing mod_perl hosting:

  http://theory.uwinnipeg.ca/modperl/help/isps.html

Chris

--

-- 
Chris Croome                               <chris@...>
web design                             http://www.webarchitects.co.uk/ 
web content management                               http://mkdoc.com/   


Gmane