Hi Vinícius,
    If you see the source code here,
https://svn.apache.org/repos/asf/xerces/java/branches/xml-schema-1.1-dev/samples/jaxp/SourceValidator.java

it does the same thing you're trying to do. This source code may be used,
for learning how to use XercesJ2 's XSD 1.1 JAXP API implementation. Also
as far as I know, the current schema 1.1 code base in XercesJ2 SVN would
not have issues using your provided XSD and XML samples in this thread. You
may try the XercesJ2 schema 1.1 SVN code base, if you would like to. I
suspect, the XercesJ2 schema 1.1 beta release, may have few issues using
the XSD 1.1 <assert> element.


I hope this helps.


On Wed, Jan 29, 2014 at 11:27 PM, Vinícius Lopes <
vinicius.lopes.silv...@gmail.com> wrote:

> I've been testing Xerces with some schemas 1.1, more specifically, those
> with assertions. Xerces do not complain when I use a valid XML with a given
> Schema. However, if I use an invalid XML, it doesn't complain either. I
> used many samples, but I will show a simple case.
>
> Below is a simple Schema 1.1.
>
> <?xml version="1.0"?>
> <schema xmlns="http://www.w3.org/2001/XMLSchema";
>         elementFormDefault="qualified">
>
>     <element name="Example">
>         <complexType>
>             <sequence>
>                 <element name="even-integer">
>                     <simpleType>
>                         <restriction base="integer">
>                             <assertion test="$value mod 2 = 0" />
>                          </restriction>
>                     </simpleType>
>                 </element>
>             </sequence>
>         </complexType>
>     </element>
>
> </schema>
>
> I tested the following XML using the schema above:
>
> <?xml version="1.0" encoding="utf-8"?>
> <Example xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>          xsi:noNamespaceSchemaLocation="even-integers_v1.xsd">
>
>     <even-integer>21</even-integer>
>
> </Example>
>
> To test this, I'm instantiating an SchemaFactory using the following line:
> schemaFactory = SchemaFactory.newInstance("
> http://www.w3.org/XML/XMLSchema/v1.1";);
>
> So, I'm using the Schema 1.1 in my code, and the parser doesn't generate
> any error when it parses the XML above, using the above schema. In Xerces
> main page, it says assertions are supported, so I believe I may be doing
> something wrong, but I haven't been able to find the mistake. Do you have
> any suggestions ?
>
> Thanks,
>             Vinícius
>



-- 
Regards,
Mukul Gandhi

Reply via email to