Reputation: 219
I have a framework which parses XML for its configuration. I have removed old 1.0 support and am now trying to parse "validators" config. The content of the validators.xsd
is the same (apart from the keyword validators) as in other parts of the framework, which doesn't have any problems. I am only ever told the content model is not determinist hence am finding it hard to problem-solve. If you could point me in the right direction to getting better errors or "sanity-checks" that would be brilliant.
Here is the XSD configuration along with the matching xml notation being used. I'm not sure what to put here but I am going to give everything cited for clarity.
validators.xsd
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:types="http://framework.youds.com/xml/config/global/types"
xmlns:validators="http://framework.youds.com/xml/config/parts/validators"
targetNamespace="http://framework.youds.com/xml/config/global/envelope"
elementFormDefault="qualified"
version="$Id$">
<xs:import namespace="http://framework.youds.com/xml/config/global/types"
schemaLocation="_types.xsd" />
<xs:import namespace="http://framework.youds.com/xml/config/parts/validators"
schemaLocation="parts/validators.xsd" />
<xs:redefine schemaLocation="_envelope.xsd">
<xs:complexType name="configuration">
<xs:complexContent>
<xs:extension base="configurations">
<xs:group ref="validators:configuration" />
<xs:attributeGroup ref="types:contexts" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:redefine>
</xs:schema>
parts/validators.xsd
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:envelope="http://framework.youds.com/xml/config/global/envelope"
xmlns:types="http://framework.youds.com/xml/config/global/types"
xmlns="http://framework.youds.com/xml/config/parts/validators"
targetNamespace="http://framework.youds.com/xml/config/parts/validators"
elementFormDefault="qualified"
version="$Id$">
<xs:import namespace="http://framework.youds.com/xml/config/global/types"
schemaLocation="../_types.xsd" />
<xs:import namespace="http://framework.youds.com/xml/config/global/envelope"
schemaLocation="../_envelope.xsd" />
<xs:simpleType name="severity">
<xs:restriction base="xs:string">
<xs:enumeration value="info" />
<xs:enumeration value="silent" />
<xs:enumeration value="none" />
<xs:enumeration value="notice" />
<xs:enumeration value="error" />
<xs:enumeration value="critical" />
</xs:restriction>
</xs:simpleType>
<!-- Arguments -->
<xs:complexType name="argument">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" type="types:non_empty_string" use="optional" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="arguments">
<xs:sequence>
<xs:element name="argument" type="argument" minOccurs="0"
maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="base" type="xs:string" use="optional" />
</xs:complexType>
<xs:group name="arguments">
<xs:choice>
<xs:element name="arguments" type="arguments"
minOccurs="0" />
<xs:element name="argument" type="argument"
minOccurs="0" maxOccurs="unbounded" />
</xs:choice>
</xs:group>
<!-- Errors -->
<xs:complexType name="error">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="for" type="types:non_empty_string" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="errors">
<xs:sequence>
<xs:element name="error" type="error"
maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:group name="errors">
<xs:choice>
<xs:element name="errors" type="errors"
minOccurs="0" />
<xs:element name="error" type="error"
minOccurs="0" maxOccurs="unbounded" />
</xs:choice>
</xs:group>
<xs:complexType name="validator">
<xs:sequence maxOccurs="unbounded">
<xs:group ref="envelope:parameters" />
<xs:group ref="arguments"
minOccurs="0"/>
<xs:group ref="errors"
minOccurs="0"/>
<xs:group ref="validators"
minOccurs="0"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="class" type="types:php_class" />
<xs:attribute name="depends" type="xs:string" />
<xs:attribute name="export" type="xs:string" />
<xs:attribute name="method" type="types:php_label_list" />
<xs:attribute name="provides" type="xs:string" />
<xs:attribute name="required" type="types:boolean" />
<xs:attribute name="severity" type="severity" />
<xs:attribute name="source" type="types:php_label" />
<xs:attribute name="translation_domain" type="xs:string" />
</xs:complexType>
<xs:complexType name="validators">
<xs:sequence>
<xs:element name="validator" type="validator"
minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="method" type="types:php_label_list" />
<xs:attribute name="severity" type="severity" />
<xs:attribute name="translation_domain" type="xs:string" />
</xs:complexType>
<xs:group name="validators">
<xs:choice>
<xs:element name="validators" type="validators"
minOccurs="0" />
<xs:element name="validator" type="validator"
minOccurs="0" maxOccurs="unbounded" />
</xs:choice>
</xs:group>
<xs:group name="configuration">
<xs:sequence>
<xs:sequence minOccurs="0" maxOccurs="unbounded" >
<xs:group ref="validators"
minOccurs="0" maxOccurs="unbounded" />
<xs:group ref="validators"
minOccurs="0" />
</xs:sequence>
</xs:sequence>
</xs:group>
</xs:schema>
_types.xsd
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:types="http://framework.youds.com/xml/config/global/types"
targetNamespace="http://framework.youds.com/xml/config/global/types"
version="$Id$">
<xs:simpleType name="environment_list">
<xs:list itemType="xs:string" />
</xs:simpleType>
<xs:attributeGroup name="environments">
<xs:attribute name="environment" type="types:environment_list" use="optional" />
</xs:attributeGroup>
<xs:simpleType name="context_list">
<xs:list itemType="xs:string" />
</xs:simpleType>
<xs:attributeGroup name="contexts">
<xs:attribute name="context" type="types:context_list" use="optional" />
</xs:attributeGroup>
<xs:simpleType name="non_empty_string">
<xs:restriction base="xs:string">
<xs:minLength value="1" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="php_class">
<xs:restriction base="xs:string">
<!--
See Ticket #1132:
We exclude all the useless stuff from the ASCII range: we allow _a-zA-Z0-9 (and _a-zA-Z for the first character) from Unicode u00-u7E plus all the rest defined in Unicode.
Since we're supporting PHP 5.3+, we also allow backslashes from the second character on.
The result is that the UTF-8 representation of such a string matches the regular expression ^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$ (applied to the raw bytes), which is the pattern for a valid PHP "LABEL".
We start at 	, not �, because #0-#8 are invalid XMLChars.
-->
<xs:pattern value="[^	-@\[\\\]^`{|}~][^	-/:-@\[\]^`{|}~]*" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="php_class_list">
<xs:list itemType="types:php_class" />
</xs:simpleType>
<xs:simpleType name="php_label">
<xs:restriction base="types:php_class">
<!-- no \ allowed -->
<xs:pattern value="[^\\]+" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="php_label_list">
<xs:list itemType="types:php_label" />
</xs:simpleType>
<!-- for BC, should be removed after 1.1 or so -->
<xs:simpleType name="identifier">
<xs:restriction base="types:php_label" />
</xs:simpleType>
<!-- for BC, should be removed after 1.1 or so -->
<xs:simpleType name="identifier_list">
<xs:restriction base="types:identifier" />
</xs:simpleType>
<xs:simpleType name="boolean">
<xs:restriction base="xs:string">
<xs:pattern value="([tT][rR][uU][eE]|[fF][aA][lL][sS][eE]|[yY][eE][sS]|[nN][oO]|[oO][nN]|[oO][fF][fF])" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="matched">
<xs:restriction base="types:boolean" />
</xs:simpleType>
</xs:schema>
_envelope.xsd
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:envelope="http://framework.youds.com/xml/config/global/envelope"
xmlns:types="http://framework.youds.com/xml/config/global/types"
xmlns:annotations="http://framework.youds.com/xml/config/global/annotations"
targetNamespace="http://framework.youds.com/xml/config/global/envelope"
elementFormDefault="qualified"
version="$Id$">
<xs:import namespace="http://framework.youds.com/xml/config/global/types"
schemaLocation="_types.xsd" />
<xs:import namespace="http://framework.youds.com/xml/config/global/annotations"
schemaLocation="_annotations.xsd" />
<xs:import namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="vendor/http/www.w3.org/XML/1998/namespace/2009-01.xsd" />
<xs:attribute name="literalize" type="types:boolean" />
<xs:complexType name="sandbox">
<xs:sequence>
<xs:any namespace="##any" processContents="lax"
minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="configuration">
<xs:attributeGroup ref="annotations:match" />
<xs:attributeGroup ref="types:environments" />
<xs:anyAttribute namespace="##any" processContents="lax" />
</xs:complexType>
<xs:complexType name="configurations">
<xs:sequence>
<xs:any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded" />
<xs:element name="sandbox" type="envelope:sandbox"
minOccurs="0" maxOccurs="1" />
<xs:element name="configuration" type="envelope:configuration"
minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="parent" type="xs:string" use="optional" />
<xs:anyAttribute namespace="##any" processContents="lax" />
</xs:complexType>
<xs:complexType name="parameter" mixed="true">
<xs:group ref="envelope:parameters" />
<xs:attribute name="name" type="xs:string" use="optional" />
<xs:attribute ref="xml:space" />
<xs:attribute ref="envelope:literalize" />
</xs:complexType>
<xs:complexType name="parameters">
<xs:sequence>
<xs:element name="parameter" type="envelope:parameter"
minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:group name="parameters">
<xs:choice>
<xs:element name="parameters" type="envelope:parameters"
minOccurs="0" maxOccurs="1" />
<xs:element name="parameter" type="envelope:parameter"
minOccurs="0" maxOccurs="unbounded" />
</xs:choice>
</xs:group>
<xs:element name="configurations" type="envelope:configurations" />
</xs:schema>
test.xml
<ae:configurations
xmlns="http://framework.youds.com/xml/config/parts/validators"
xmlns:ae="http://framework.youds.com/xml/config/global/envelope"
parent="%core.src_dir%/config/defaults/validators.xml"
>
<configuration>
<validators>
<validator class="string">
<arguments>
<argument>test</argument>
</arguments>
<errors>
<error>The test is not successful.</error>
</errors>
<ae:parameters>
<ae:parameter name="min">1</ae:parameter>
</ae:parameters>
</validator>
</validators>
</configuration>
</ae:configurations>
Upvotes: 4
Views: 1295
Reputation: 219
So the problem was with the /parts/validator.xsd
config containing a duplicate element which was causing the "non-determinist" error. For reference, it is my understanding that this message means you are seeing a duplicate entry or rather an entry that isn't clear on how to proceed to the next element. Hence, not determinist.
<xs:group ref="validators"
minOccurs="0" maxOccurs="unbounded" />
<xs:group ref="validators"
minOccurs="0" />
Should be:
<xs:group ref="validators"
minOccurs="0" maxOccurs="unbounded" />
Upvotes: 3