Hi Yoann,

It seems you are getting the desired behavior, i.e. the type assigned to 
the element is xs:error. Since xs:error is just a special simple type 
definition, whose name is error in the XSD namespace, Xerces-J is throwing 
the right error message (no attributes are allowed for simple types). You 
are looking for a specific message, which in these case is an invalid 
value for an attribute. You would need to use assertions to specify that 
your attribute can only be of two values and you would probably get an 
error message telling you that the assertion failed. 

Regards,
Khaled





From:
Michael Glavassevich/Toronto/i...@ibmca
To:
j-users@xerces.apache.org
Date:
05/03/2010 01:41 PM
Subject:
Re: XSD1.1 alternative test and errors



Hi Yoann,

Are you using a binary built from the XML Schema 1.1 development branch 
[1]? We're still working on implementing these features. It's possible 
support for xs:error isn't there yet or isn't correct. I haven't looked at 
this much though. Khaled, Mukul and/or Hiranya would probably have more 
insight.

Thanks.

[1] http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrgla...@ca.ibm.com
E-mail: mrgla...@apache.org

yoann moranville <yoann.moranvi...@gmail.com> wrote on 05/03/2010 09:03:45 
AM:

> Dear all,
> 
> I am facing an issue while validating using XSD1.1.
> I want to decide on the type of an element depending on one of its
> attribute value:
> 
> <xs:element name="myElement">
>     <xs:alternative test="@attribute = 'value1'" type="myElement.value1" 
/>
>     <xs:alternative test="@attribute = 'value2'" type="myElement.value2" 
/>
> </xs:element>
> 
> Now that works, both types "myElement.value1" and "myElement.value2"
> are complex types.
> 
> However, I realized that if I have @attribute = 'value3', no errors
> are being thrown so I wanted to add a new alternative rule:
>     <xs:alternative test="(@attribute ne 'value1') or (@attribute ne
> 'value2')" type="xs:error" />
> 
> But when that occurs, the validation error begin thrown are not what I
> am waiting for, it says that my attributes are not correct since the
> type of myElement is of simple type.
> 
> So how could I throw an error saying that my @attribute is not of
> correct values?
> 
> Thank you,
> Yoann
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org
> For additional commands, e-mail: j-users-h...@xerces.apache.org

Reply via email to