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

Tara Athan
Sun Feb 13 20:32:38 CST 2011


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





More information about the oXygen-user mailing list