I Am working on a TCL GUI, and I obtain the Data Tree structure for the GUI from a XML Schema, and I have to validate the entry fields fro the restrictions as in the XML Schema. In the XML Schema I am working with I have the simple types NMTOKEN Name and NCName with pattern restrictions '\c+
' , '\i\c*
' and '[\i-[:]][\c-[:]]*
' respectively.
The code i use to check is
method validatePatternValue { value } {
set patternCheck 1
set pattern "^($patternValue)\$"
set patternCheck [regexp $pattern $value]
if {$patternCheck == 0} {
tk_messageBox -message "Only Characters within range $patternValue for $patternValueType is\
accepted "
return 0
}
return 1
}
and whenever the $pattern is one of these '\c+
' , '\i\c*
' and '[\i-[:]][\c-[:]]*
' my text field does not accept any input and keeps throwing an error exception dialogue.
Just to add some more info, I came across this website, with some good info regarding my question about processing combinations of '\i
' and '\c
'. But is there no other way apart from the one suggested in the following link : XML Schema Character Classes
The \c
escape sequence does not do in Tcl regexp what it does in XML-Schema regexp.
In XML Schema
\c
matches any character that may occur after the first character in an XML name, i.e.[-._:A-Za-z0-9]
In Tcl
\cX
(where X is any character) the character whose low-order 5 bits are the same as those of X, and whose other bits are all zero
It's also clearly stated in the link you sent
Note that the \c shorthand syntax conflicts with the control character syntax used in many other regex flavors.
You should try using [-.:\w]
instead of \c
The same is true for \i
, it's not doing the same in Tcl and in XML
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With