I am writing a schema to validate an xml document that can contain an attribute that is a logical expression. i.e. test="@a empty and @b empty and @c is keyword" (@x are "reference ids" that refer to elements in the schema that are being tested). I'm using patterns for this and have several that work.
<!-- @refid is | is not keyword -->
<xs:pattern value="@(?:[a-zA-Z0-9_])+ is \b(not )\b{0,1}(?:[kw1|kw2|kw3])+" />
<!-- @refid operater literal in single qoutes -->
<xs:pattern value="@(?:[a-zA-Z0-9_])+ (?:[eq|ne|gt|lt|ge|le])* '[^']*'" />
<!-- @refid operator literal in double qoutes -->
<xs:pattern value='@(?:[a-zA-Z0-9_])+ (?:[eq|ne|gt|lt|ge|le])* "[^"]*"' />
<!-- @refid empty | notempty -->
<xs:pattern value="@(?:[a-zA-Z0-9_])+ (?:[empty|notempty])*" />
<!-- @refid operator @refid -->
<xs:pattern value="@(?:[a-zA-Z0-9_])+ (?:[eq|ne|gt|lt|ge|le])* @(?:[a-zA-Z0-9_])+" />
What I haven't been able to figure out is how to handle multiple operators. What I need is the ability to allow the patterns to repeat. Is this possible? What I need to do is pretty close to what the @test attribute in an XSL transform does.