Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: xhtml.xsd error?

From: "Pete Cordell" <petexmldev@--------------.--->
To: <xmlschema-dev@--.--->
Date: 8/9/2006 10:32:00 AM
Hi Lu=EDs,

I tried this pattern on Perl and the expression does match 100.5%.  See [=
1]
for more.

I think the wording of the paragraph you quote is sub-optimal!  Where is
says "When one pattern completely matches, ..." I think it means "If a ma=
tch
for the complete pattern is found, ..." as opposed to just the one
sub-expression.

The pattern shown is something like C?(A|BD?E).  Even though A does match=
 a
portion of the target 100.5%, C?A does not match the entire pattern, so t=
he
regular expression engine back tracks and tries C?BD?E.

Regards,

Pete.

[1]
Perl code:
#!/usr/bin/perl -w

@vals = qw( 100 100.0 100% 100.0% +100 +100.0 +100% +100.0%
            -100 -100.0 -100% -100.0% 100.5% );

foreach $v (@vals) {
    if( $v =~ /^[-+]?(\d+|\d+(\.\d+)?%)$/ ) {    # Added in ^ and $
        print "$v - It matches\n";
    }
    else {
        print "$v - No match\n";
    }
}

Result:
100 - It matches
100.0 - No match
100% - It matches
100.0% - It matches
+100 - It matches
+100.0 - No match
+100% - It matches
+100.0% - It matches
-100 - It matches
-100.0 - No match
-100% - It matches
-100.0% - It matches
100.5% - It matches
--
==========================
====================
Pete Cordell
Tech-Know-Ware Ltd
                         for XML to C++ data binding visit
                         http://www.tech-know-ware.com/lmx
                         (or http://www.xml2cpp.com)
==========================
====================

----- Original Message ----- 
From: "Lu=EDs Fernando Heckler" <lfheckler@i...>
To: "Michael Kay" <mike@s...>
Cc: <xmlschema-dev@w...>
Sent: Tuesday, August 08, 2006 2:10 PM
Subject: Re: xhtml.xsd error?



Thanks Michael !

All right, this make sense, but the original Regular Expression
"[-+]?(\d+|\d+(\.\d+)?%)" doesn't match values like "100.5%".

At http://docs.python.org/lib/re-syntax.html we can read:
"|A|B|, where A and B can be arbitrary REs, creates a regular expression
that will match either A or B. An arbitrary number of REs can be
separated by the "|" in this way. This can be used inside groups (see
below) as well. As the target string is scanned, REs separated by "|"
are tried from left to right. When one pattern completely matches, that
branch is accepted. This means that once |A| matches, |B| will not be
tested further, even if it would produce a longer overall match. In
other words, the "|" operator is never greedy."

So, the original expression match the substring "100" first and stop.

An alternative could be: "[-+]?(\d+(\.\d+)?%|\d+)"
This recognize:

100
100%
100.0%
+100
+100%
+100.0%
-100
-100%
-100.0%

But also recognize strings like "1000000000.3332%" ... this is correct,
but weird.


Lu=EDs Fernando Heckler



Michael Kay escreveu:
> This picture allows a decimal point only if there is a "%", which seems
> reasonable, because you can't have a fractional number of pixels.
>
> Michael Kay
> http://www.saxonica.com/
>
>
>
>> -----Original Message-----
>> From: xmlschema-dev-request@w... [mailto:xmlschema-dev-request@w...=
g] 
>> On Behalf Of Luis Fernando Heckler
>> Sent: 02 August 2006 20:01
>> To: xmlschema-dev@w...
>> Subject: xhtml.xsd error?
>>
>>
>> Hi,
>>
>> I'm using the w3c xhtml.xsd to validate my xhtml document, but I found=
 
>> something wrong:
>>
>> In the simpleType definition named Length (line 203), used to validate=
 de 
>> type of attributes width and heigth of table element for example, we h=
ave 
>> a pattern to validate the type, but this pattern doesn't match witch a=
ll 
>> the expected formats (AFAIK).
>>
>> http://www.w3.org/TR/xhtml-modularization/abstraction.html#dt_
>> Length  say's:
>> "Length - The value may be either in pixels or a percentage of the 
>> available horizontal or vertical space. Thus, the value "50%" means ha=
lf 
>> of the available space."
>>
>> The documentation comment in the xsd say's:
>> "nn for pixels or nn% for percentage length"
>>
>> So, I thing that expected values are:
>> 100
>> 100.0
>> 100%
>> 100.0%
>> +100
>> +100.0
>> +100%
>> +100.0%
>> -100
>> -100.0
>> -100%
>> -100.0%
>>
>> But the original pattern "[-+]?(\d+|\d+(\.\d+)?%)" don't match all thi=
s 
>> length formats.
>>
>> I change to "[-+]?\d+(\.\d+)?%?"
>>
>> This is a error in original w3c xhtml.xsd or I'm wrong about the expec=
ted 
>> length formats?
>>
>> Best wishes
>> Luis Fernando Heckler
>>
>>
>>
>>
>>
>>
>
>
>
>
>




From petexmldev@t... Wed Aug 09 09:15:12 2006
Received: from aji.w3.org ([133.27.228.225])
	by frink.w3.org with esmtp (Exim 4.50)
	id 1GAk9g-0000Ud-L7
	for xmlschema-dev@l...; Wed, 09 Aug 2006 09:15:12 +000


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent