Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Excluding values in the xsd

Reply
Thread Tools

Excluding values in the xsd

 
 
Bjoern Hoehrmann
Guest
Posts: n/a
 
      03-24-2007
* Alain Ketterlin wrote in comp.text.xml:
>Regular languages are closed under complementation. So, you can be
>sure it is possible: there _is_ a regular expression that matches
>everything except a finite set of words. If you want to exclude, e.g.,
>"if" and "else", you can go:
>
> ([^i]|i[^f]|if.|[^e]|e[^l]|el[^s]|els[^e]|else.).*
>
>(I'm not sure about the regexp syntax for schemas). It may be a real
>pain. I don't know if there's an easier way to get the same result.


You created not(if) or not(else) which matches if and else, you need to
create not(if) and not(else), i.e. the intersection of two regular ex-
pressions. I suppose there is a painful way in XML Schema to specify
multiple regular expressions a string must match, and inverting a group
is simple (abc -> not(a) .* or a not(b) .* or ab not(c) or abc .+). It
would be better to compute the intersection of the regular expressions.
There may be finite state automata tools that support that. I am about
to release a tool that can do it aswell.
--
Björn Höhrmann · (E-Mail Removed) · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
 
Reply With Quote
 
 
 
 
dick.deneer@donkeydevelopment.com
Guest
Posts: n/a
 
      03-24-2007
On 24 mrt, 08:24, Alain Ketterlin <(E-Mail Removed)-strasbg.fr> wrote:
> (E-Mail Removed) writes:
> >> ([^i]|i[^f]|if.|[^e]|e[^l]|el[^s]|els[^e]|else.).*

> > I tested your expression and it always returns true, whatever
> > (including if and else) I type.
> > Do I miss something?

>
> I did I went to fast. You have to 1) include trailing chars in the
> alternative, 2) group prefixes to exclude, 3) take care of strict
> prefixes. Something like:
>
> ([^ie].*|i|i[^f].*|if.+|e|e[^l].*|el|el[^s].*|els|els[^e].*|else.+)
>
> May get really hairy with lots of keywords. Be careful with common
> prefixes, like "if" and "int":
>
> ([^i].*|i|i[^nf].*|if.+|in[^t].*|int.+)
>
> I stop here, in fear of writing nonsense. The basic idea is simple:
>
> 1) draw a trie (lexicographic tree) containing all the words
> 2) add one alternative for each path to a non leaf node (i,el,els)
> 3) add one alternative for each path out of a node (either
> leaf or non-leaf), i.e., a path that starts "in" the tree and "exits"
> the tree at some point (i[^f].*,if.+ etc.)
>
> (It basically amounts in reverting the output of a deterministic
> finite automaton.)
>
> -- Alain.
>
> P/S: BTW, I just discovered grep --colour... Useful in such cases.


Alain (and Bjoern)

I am convinced.
It is possible but indeed very painfull if your list of reserved words
is big, which is the case for me.
Thanks a lot,
Dick Deneer



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XML + XSD: Is it possible to get all errors against the XSD? Markus Java 1 11-22-2005 02:53 PM
Difference between <import ....xsd> and <xlink:href=.....xsd> ???? Bernd Oninger XML 1 06-30-2004 08:21 AM
xsd:any as a child of xsd:all Peter Aberline XML 0 04-05-2004 03:38 PM
referencing another XSD file within an XSD file JavaDeveloper@nowhere.com XML 1 01-14-2004 05:22 PM
XSD document for XSD defintion Rick Razzano XML 1 09-26-2003 12:41 AM



Advertisments