【问题标题】:attributeGroup in xsd and its representation in xmlxsd 中的属性组及其在 xml 中的表示
【发布时间】:2012-10-17 18:09:40
【问题描述】:

鉴于此 XSD 来自 this document

<xs:element name="jdbc-user-service" substitutionGroup="security:any-user-service">
    <xs:annotation> .. etc </xs:annotation>
    <xs:complexType>
        <xs:attribute name="id" type="xs:token"></xs:attribute>
        <xs:attributeGroup ref="security:jdbc-user-service.attlist"/>
    </xs:complexType>
</xs:element>

<xs:attributeGroup name="jdbc-user-service.attlist">
    <xs:attribute name="data-source-ref" use="required" type="xs:token">
    </xs:attribute>
    <xs:attribute name="cache-ref" type="xs:token">
    </xs:attribute>
    <xs:attribute name="users-by-username-query" type="xs:token">
    </xs:attribute>
    <xs:attribute name="authorities-by-username-query" type="xs:token">
    </xs:attribute>
    <xs:attribute name="group-authorities-by-username-query" type="xs:token">     
    </xs:attribute>
    <xs:attribute name="role-prefix" type="xs:token">
    </xs:attribute>
</xs:attributeGroup>

那为什么eclipse给我这个错误

cvc-complex-type.2.4.a:发现以元素“jdbc-user-service”开头的无效内容。 '{"http:// 之一 www.springframework.org/schema/security":user}' 是预期的。

当我提供以下 XML 时?

<jdbc-user-service
    data-source-ref="dataSource"
    users-by-username-query="SELECT u.uname, u.upwd, u.enabled FROM ucsdb.users u WHERE u.uname = ?"/>

【问题讨论】:

    标签: xml eclipse spring xsd spring-security


    【解决方案1】:

    我认为你把事情搞混了。您可能从 another XML 收到此错误。根据 XSD,您发布的 XML(假设命名空间是正确的,请参见下文以防万一)有效

    <jdbc-user-service xmlns="http://www.springframework.org/schema/security" data-source-ref="dataSource" users-by-username-query="SELECT u.uname, u.upwd, u.enabled FROM ucsdb.users u WHERE u.uname = ?"/>
    

    发布的 XSD 中唯一的“用户”元素来自此元素:

    <xs:element name="user-service" substitutionGroup="security:any-user-service">
        <xs:annotation>
            <xs:documentation>Creates an in-memory UserDetailsService from a properties file or a list of "user" child elements. Usernames are converted to lower-case internally to allow for case-insensitive lookups, so this should not be used if case-sensitivity is required.</xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element minOccurs="0" maxOccurs="unbounded" name="user">
                    <xs:annotation>
                        <xs:documentation>Represents a user in the application.</xs:documentation>
                    </xs:annotation>
                    <xs:complexType>
                        <xs:attributeGroup ref="security:user.attlist"/>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
            <xs:attribute name="id" type="xs:token">
                <xs:annotation>
                    <xs:documentation>A bean identifier, used for referring to the bean elsewhere in the context.</xs:documentation>
                </xs:annotation>
            </xs:attribute>
            <xs:attributeGroup ref="security:properties-file"/>
        </xs:complexType>
    </xs:element>
    

    因此,您必须验证使用“用户服务”标签的 XML。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-27
      • 1970-01-01
      • 2012-10-16
      • 2021-03-23
      相关资源
      最近更新 更多