Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Custom discriminators

From: "G. Ken Holman" <gkholman@----------------.--->
To: <xmlschema-dev@--.--->
Date: 12/18/2005 3:05:00 AM
At 2005-12-18 12:07 +0100, Gregor Zeitlinger wrote:
>I was wondering if it is possible to define custom discriminators.
>...
>So I have type="(date|time)". If type="date" there are addional 
>attributes available.
>
>In another situation, there is an element with two discriminator attributes:
>type="(|password)" and multiline="(true|false)".
>I want to assign four different Schema types based on the 
>combinations of those attributes.

You've described the need for co-occurrence constraints and 
co-occurrence constraints are not supported in W3C Schema 1.0.

Such constraints can be expressed in ISO/IEC 19757-2 RELAX-NG 
(example below, I guessed a value for your "type" attribute since 
your example above seems incomplete) and I gather from posts on this 
list that the W3C committee has long been considering how such 
constraints can be introduced into W3C Schema.  RELAX-NG treats both 
attributes and elements as first-class constructs in the content 
model operators.

RELAX-NG is part 2 of Document Schema Definition Languages (DSDL) and 
I gather what is not well known is that the objective of DSDL is to 
be inclusive to be able to incorporate any validation technology by 
reference (including W3C Schema) so that technologies both inside and 
outside of DSDL can be expressed as part of a validation suite.

I hope this helps.

. . . . . . . . . Ken

T:\>type gregor.rnc
datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes"

# test for Gregor

start = element tests { test+ }

test = element test
    {
       (
          attribute type { "abc" },
          attribute multiline { "true" },
          xsd:positiveInteger
       )
       |
       (
          attribute type { "abc" },
          attribute multiline { "false" },
          xsd:string
       )
       |
       (
          attribute type { "password" },
          attribute multiline { "true" },
          xsd:float
       )
       |
       (
          attribute type { "password" },
          attribute multiline { "false" },
          xsd:integer
       )
    }

# end of file

T:\>type gregor.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<tests>
   <!--good-->
   <test type="abc" multiline="false">hello</test>
   <test type="abc" multiline="true">123</test>
   <test type="password" multiline="false">456</test>
   <test type="password" multiline="true">456.78</test>
   <!--bad-->
   <test type="password" multiline="false">456.78</test>
   <test type="abc" multiline="true">hello</test>
   <test type="abc" multiline="true">-123</test>
</tests>
T:\>jing -c gregor.rnc gregor.xml
T:\gregor.xml:9: error: bad character content for element
T:\gregor.xml:10: error: bad character content for element
T:\gregor.xml:11: error: bad character content for element

T:\>

--
Upcoming XSLT/XSL-FO hands-on courses:  Denver,CO March 13-17,2006
World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman@C...
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/x/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05  http://www.CraneSoftwrights.com/x/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


From srivegunta@y... Tue Dec 20 10:18:31 2005
Received: from aji.w3.org ([133.27.228.225])
	by frink.w3.org with esmtp (Ex


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