=?ISO-8859-1?Q?Re:_[xml]_Warning:_complex_type_'type_subelement':_The_con?= =?ISO-8859-1?Q?tent_model_is=09not_determinist.?=



Hi,

Von: "Wetzler, Thomas" <thomas wetzler siemens com>
Datum: Tue, 2 Aug 2005 15:59:47 +0200

Hi there,
 
I've developed a schema-definition with the tool "XML-Spy" on my
workstation. It works fine without any failures:

W3C XML Schema is challenging to implement - XML-Spy might
have a flaw here.
If you want to be sure that your schema is valid, then try
validating it with various processors like Xerces, XSV,
MSXML, etc. If they report different results - and they do
often - then consult the schema mailing lists, or your
mighty company's schema consultant - Siemens should have
one ;-)

[...]
        <xs:complexType name="type_subelement">
                <xs:choice>
                        <xs:sequence>
                                <xs:element name="header" type="columns"
fixed="AN"/>
                                <xs:element name="content"
type="type_an"/>
                        </xs:sequence>
                        <xs:sequence>
                                <xs:element name="header" type="columns"
fixed="PN"/>
                                <xs:element name="content"
type="type_pn"/>
                        </xs:sequence>
                </xs:choice>
        </xs:complexType>
[...]

      Warning: complex type 'type_subelement': The content model is
not determinist. in
/wir/searchservertest/src/load_db/xml_parser/FtcinCreator.php on line 37
       
      Warning: Invalid Schema in
/wir/searchservertest/src/load_db/xml_parser/FtcinCreator.php on line 37
      Validate FAILED

The library seems to have difficulties with the <xs:choice><xs:sequence>
combination. XML-Spy has no problem with that.

Does anyone have an idear?

Your schema seems to be invalid.
Xerces 2.7.1 reports:

groups-nested-1.xsd:7,48: (Error) cos-element-consistent: Error for type
'type_subelement'. Multiple elements with name 'content', with different
types, appear in the model group.

groups-nested-1.xsd:7,48: (Error) cos-nonambig: header and header (or
elements from their substitution group) violate "Unique Particle
Attribution". During validation against this schema, ambiguity would be
created for those two particles.

Although XSV does not bark at it, I would trust the results of
Xerces here, since, AFAIK, XSV already tries to implement a way of
unique particle attribution (UPA), which would probably fit for the
next version of the XML Schema spec.

It seems that you want to implement something like (pseudo code):

if (header == "AN") then
  content.type = type_an
else if (header == "PN") then
  content.type = type_pn

This is not possible with XML Schema, which is in turn revealed by
XSV with the following example instance:

<element xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xsi:noNamespaceSchemaLocation="groups-nested-1.xsd">
        <subelement>
                <header>PN</header>
                <content>1000</content>
        </subelement>
</element>

XSV 2.10-1 reports:
groups-nested-1.xml:5,3: fixed value did not match: PN!=AN

A <choice> in XML Schema is usable at the element QName level
only, i.e. processors will not try other "choices" if the node's
content or attributes are invalid, but just reject the instance.

Have a look at RelaxNG or Schematron. I don't know both of them
much; maybe they provide the mechanisms you need. Or, once again,
consult your mighty company's schema consultant.

Cheers,

Kasimier



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]