Reputation: 101
The Schema :
<xs:complexType>
<xs:sequence>
<xs:element ref="FileCreationList"/>
<xs:element ref="DivestedExample"/>
</xs:sequence>
<xs:attribute name="mylns:xsi" type="xs:string"/>
<xs:attribute name="xsi:schemaLocation" type="xs:string"/>
</xs:complexType>
The error:
Multiple annotations found at this line:
- s4s-att-invalid-value: Invalid attribute value for 'name' in element 'attribute'. Recorded reason: cvc-datatype-valid.1.2.1: 'mylns:xsi' is not a valid
value for 'NCName'.
- src-attribute.3.1: One of 'ref' or 'name' must be present in a local attribute declaration.
- s4s-elt-invalid-content.1: The content of '#AnonType_File' is invalid. Element 'attribute' is invalid, misplaced, or occurs too often.
Upvotes: 3
Views: 12620
Reputation: 163352
Generally, if you want to declare an element that uses attributes in a different namespace, then you need to (a) declare those attributes in a separate XSD document, with a different targetNamespace, (b) use xs:import to import that XSD document, and (c) reference the attribute declarations using <xs:attribute ref="somens:localname"/>
.
However:
(i) Namespace declarations (xmlns:xx="uri") are not considered to be attributes and do not need to be declared (indeed, must not be declared) in the schema
(ii) Attributes in the "xsi" namespace are special - they are automatically allowed on every element, and should not be declared in the schema.
Upvotes: 0
Reputation: 111620
Attribute name declarations must be NCNames (non-colonized names):
NCName ::= (Letter | '_') (NCNameChar)* /* An XML Name, minus the ":" */
Remove the colons from mylns:xsi
and xsi:schemaLocation
to eliminate the error.
Notes:
Do not declare xsi:schemaLocation
as an attribute in an XSD; declare
and reference the http://www.w3.org/2001/XMLSchema-instance
namespace:
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.com/name try.xsd"/>
Upvotes: 3