I'm trying unsuccessfully to use an xs:assert
to validate based on the values of two attributes. I keep getting
s4s-elt-must-match.1
: The content ofdata
must match(annotation?, (simpleType | complexType)?, (unique | key | keyref)*))
. A problem was found starting at:assert
.
I've looked thru a bunch of questions. I even copied one of the answers given, but even it gives the same error. It's telling me the format of the test is invalid, but I can't find any example that does it differently. Can anyone tell me what I'm doing wrong?
TIA
Here's the answer I copied, with the error inline as a comment:
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
vc:minVersion="1.1">
<xs:element name="data">
<xs:complexType>
<xs:attribute name="min" type="xs:int"/>
<xs:attribute name="max" type="xs:int"/>
</xs:complexType>
<xs:assert test="@min le @max"/>
<!--s4s-elt-must-match.1: The content of 'data' must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*)). A problem was found starting at: assert.-->
</xs:element>
</xs:schema>
Edit: Here it is with the assert inside the complexType, showing a different error.
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
vc:minVersion="1.1">
<xs:element name="data">
<xs:complexType>
<xs:attribute name="min" type="xs:int"/>
<xs:attribute name="max" type="xs:int"/>
<xs:assert test="@min le @max"/>
<!-- s4s-elt-invalid-content.1: The content of '#AnonType_data' is invalid. Element 'assert' is invalid, misplaced, or
occurs too often. -->
</xs:complexType>
</xs:element>
</xs:schema>
Possible issues:
xs:assert
element to within xs:complex
:Change from
<xs:element name="data">
<xs:complexType>
<xs:attribute name="min" type="xs:int"/>
<xs:attribute name="max" type="xs:int"/>
</xs:complexType>
<xs:assert test="@min le @max"/>
</xs:element>
to
<xs:element name="data">
<xs:complexType>
<xs:attribute name="min" type="xs:int"/>
<xs:attribute name="max" type="xs:int"/>
<xs:assert test="@min le @max"/>
</xs:complexType>
</xs:element>