[oXygen-user] problems with explicit type validation from Relax NG

George Cristian Bina
Mon Feb 14 15:58:50 CST 2011


Dear Tara,

As you found also on the rng-users list the Relax NG schema does not 
treat specially the xsi:type attributes so they need to be declared in a 
Relax NG schema in order to be validated.

An alternative will be to use a NVDL script to exclude the xsi:type 
attributes from Relax NG validation.

Best Regards,
George
-- 
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

On 2/14/11 4:32 AM, Tara Athan wrote:
> Request Jing bug fix to allow validation of xs:simpleType elements with
> an xsi:type attribute
>
> I am working on a schema where there is a need for an element
> <BuiltInData>  which holds a literal and allows validation against any
> built-in type, and otherwise has no attributes.
> Example (simplified)-
> <?xml version="1.0" encoding="UTF-8"?>
> <wrapper
>      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>      xmlns:xs="http://www.w3.org/2001/XMLSchema"
>      xsi:noNamespaceSchemaLocation="BuiltInDataXSD.xsd">
>      <BuiltInData xsi:type="xs:nonNegativeInteger">123</BuiltInData>
>      <BuiltInData xsi:type="xs:token">Maple St.</BuiltInData>
>      <BuiltInData xsi:type="xs:date">2011-01-30</BuiltInData>
>      <BuiltInData xsi:type="xs:Name">company:Employee</BuiltInData>
> </wrapper>
>
>
> The Relax NG compact schema is fairly straightforward
> start = element wrapper {BuiltInData.type+}
> BuiltInData.type =
>    element BuiltInData {
>      (xsd:duration
>       | xsd:dateTime
>       | xsd:time
>       | xsd:date
>       | xsd:gYearMonth
>       | xsd:gYear
>       | xsd:gMonthDay
>       | xsd:gDay
>       | xsd:gMonth
>       | xsd:boolean
>       | xsd:base64Binary
>       | xsd:hexBinary
>       | xsd:float
>       | xsd:decimal
>       | xsd:double
>       | xsd:anyURI
>       | xsd:QName
>       | xsd:NOTATION
>       | xsd:string)
>    }
> which converts to the XSD
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified">
>    <xs:element name="wrapper">
>      <xs:complexType>
>        <xs:sequence>
>          <xs:element maxOccurs="unbounded" ref="BuiltInData"/>
>        </xs:sequence>
>      </xs:complexType>
>    </xs:element>
>    <xs:element name="BuiltInData">
>      <xs:simpleType>
>        <xs:union memberTypes="xs:duration xs:dateTime xs:time xs:date
> xs:gYearMonth xs:gYear xs:gMonthDay xs:gDay xs:gMonth xs:boolean
> xs:base64Binary xs:hexBinary xs:float xs:decimal xs:double xs:anyURI
> xs:QName xs:QName xs:string"/>
>      </xs:simpleType>
>    </xs:element>
> </xs:schema>
>
> Now the problem is: if I try to validate the XML directly from the Relax
> NG schema, using oXygen, then I get an error.
> *** [Jing] found attribute "xsi:type", but no attributes allowed here.***
>   From my perspective at least, this is a bug in Jing because the XML is
> valid according to the XSD schema but not according to the supposedly
> equivalent Relax NG schema (there is no approximation warning upon
> conversion).
> I can modifed the Relax NG schema by declaring the attribute
>    element BuiltInData {
>      attribute xsi:type { text }?,
> ...
> but that messes up the conversion to XSD.
>
> I don't expect Jing to check that the literal matches the datatype, but
> it should at least ignore the xsi:type attribute, (or better - check
> that the type could be derived from the element's defined datatype.)
>
> So I have 4 options, in reverse order of preference:
> 1. give up on validation directly from the Relax NG schema
> 2. maintain two versions of the RNC schema, one for direct validation
> and one for conversion
> 3. find a method for validating against the Relax NG schema other than
> Jing in oXygen
> 4. request that the validator in oXygen be modified  to allow validation
> of xs:simpleType elements with an xsi:type attribute
>
> So I'll start with #4 - any chance this can happen?
>
> Thanks, Tara
>
>
> _______________________________________________
> oXygen-user mailing list
> 
> http://www.oxygenxml.com/mailman/listinfo/oxygen-user
>



More information about the oXygen-user mailing list