名称空间xml文件中元素中的属性

名称空间xml文件中元素中的属性,xml,xsd,xml-namespaces,Xml,Xsd,Xml Namespaces,我想知道是否可以在元素内的属性中添加名称空间。 这是我的XSD: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://fooschema.com" xmlns="http://fooschema.com" elementFormDefault="qualified"

我想知道是否可以在元素内的属性中添加名称空间。 这是我的XSD:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://fooschema.com"
        xmlns="http://fooschema.com"
        elementFormDefault="qualified"
        version="1.0">    

    <xs:element name = "class">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="student" type="StudentType" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:complexType name = "StudentType">
        <xs:sequence>
            <xs:element name = "firstname" type = "xs:string"/>
        </xs:sequence>
        <xs:attribute name = "rollno" type = "xs:positiveInteger"/>
    </xs:complexType>
</xs:schema>

解决方案是添加:

attributeFormDefault="unqualified"
作为XSD定义的一部分

<xs:student xs:rollno="393">
attributeFormDefault="unqualified"