1
嗨,我想強制使用這個屬性在我的XSD
現在這個屬性是可選的強制在XSD屬性的使用
屬性:
<xs:attribute name="namespace" type="xs:string"/>
<xs:attribute name="uri" type="xs:string"/>
<xs:attribute name="beforeMiddleware" type="xs:string"/>
<xs:attribute name="afterMiddleware" type="xs:string"/>
<xs:attribute name="accessLevel" type="xs:string"/>
我的XSD文件:
<?xml version="1.0"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0"
elementFormDefault="qualified"
targetNamespace="grif:route"
>
<xs:element name="routes">
<xs:complexType>
<xs:sequence>
<xs:element name="group" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="route" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:complexContent>
<xs:restriction base="xs:string">
<xs:attribute name="action" type="xs:string"/>
<xs:attribute name="uri" type="xs:string"/>
<xs:attribute name="method" type="methodList" default="GET"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="namespace" type="xs:string"/>
<xs:attribute name="uri" type="xs:string"/>
<xs:attribute name="beforeMiddleware" type="xs:string"/>
<xs:attribute name="afterMiddleware" type="xs:string"/>
<xs:attribute name="accessLevel" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="methodList">
<xs:restriction base="xs:string">
<xs:enumeration value="GET" />
<xs:enumeration value="POST" />
<xs:enumeration value="PUT" />
<xs:enumeration value="HEAD" />
<xs:enumeration value="DELETE" />
<xs:enumeration value="CONNECT" />
<xs:enumeration value="OPTIONS" />
<xs:enumeration value="TRACE" />
</xs:restriction>
</xs:simpleType>
</xs:schema>
而我的示例XML文件是:
<?xml version="1.0" encoding="UTF-8"?>
<routes xmlns="grif:route">
<group uri="/magazine" namespace="\Grif\Beans\BlogBeans" beforeMiddleware="LoginAuth">
<route method="POST" action="[email protected]" uri="/showNews" />
<route method="GET" action="[email protected]" uri="/news" />
</group>
<group uri="/magazine/gallery" namespace="\Grif\Beans\MagazineBeans" accessLevel="ADMIN_ROLE">
<route action="[email protected]" uri="/showGallery" />
</group>
</routes>
如何改變它強制使用屬性???
如何將其更改爲強制使用屬性???
如何將其更改爲強制使用屬性???