命名空间 xml 文件内元素中的属性
namespace an attribute in an element inside of an xml file
我想知道是否可以将命名空间添加到元素内的属性。
这是我的 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>
这是我的例子 xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:class xmlns:xs = "http://fooschema.com">
<xs:student rollno="393">
<xs:firstname>Dinkar</xs:firstname>
</xs:student>
</xs:class>
现在有没有办法将 xs
命名空间声明添加到 rollno
属性,如下所示:
<xs:student xs:rollno="393">
解决方法是添加:
attributeFormDefault="unqualified"
作为 XSD 定义的一部分。
我想知道是否可以将命名空间添加到元素内的属性。 这是我的 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>
这是我的例子 xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:class xmlns:xs = "http://fooschema.com">
<xs:student rollno="393">
<xs:firstname>Dinkar</xs:firstname>
</xs:student>
</xs:class>
现在有没有办法将 xs
命名空间声明添加到 rollno
属性,如下所示:
<xs:student xs:rollno="393">
解决方法是添加:
attributeFormDefault="unqualified"
作为 XSD 定义的一部分。