xmlns 实例分析

<?xml version="1.0" encoding="UTF-8"?>
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor 
    license agreements. See the NOTICE file distributed with this work for additional 
    information regarding copyright ownership. The ASF licenses this file to 
    you under the Apache License, Version 2.0 (the "License"); you may not use 
    this file except in compliance with the License. You may obtain a copy of 
    the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required 
    by applicable law or agreed to in writing, software distributed under the 
    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 
    OF ANY KIND, either express or implied. See the License for the specific 
    language governing permissions and limitations under the License. -->
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:simple="http://cxf.apache.org/simple" xmlns:jaxws="http://cxf.apache.org/jaxws"
    xmlns:soap="http://cxf.apache.org/bindings/soap" xmlns="http://www.springframework.org/schema/beans"
    xsi:schemaLocation="http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
        http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd
        http://cxf.apache.org/simple http://cxf.apache.org/schemas/simple.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">


    <simple:server id="pojoservice12" serviceClass="com.bull.eris.cmn.ds.DSIF" address="/DSWService">
        <simple:serviceBean>
            <bean class="com.bull.eris.cmn.ds.DSImpl" />
        </simple:serviceBean>
    </simple:server>
</beans>

xmlns="http://www.springframework.org/schema/beans"

这个是默认的命名空间(就是没有前缀,这个文档中 <beans /> 和 <bean /> 标签都用这个命名空间)

在schemaLocatoin 中 ,格式都是固定的 k空格v回车 (k&nbsp;v ),表明这个命名空间的语法定义文件在什么位置。

除了默认的命名空间外还有其他的命名空间比如simple ,文档中<simple:server /> 就是用这个,语法定义文件的位置也都表明了。

因为有了默认的和各种其他带前缀的命名空间,文档里的元素就不会混淆了

http://cxf.apache.org/docs/schemas-and-namespaces.html

原文地址:https://www.cnblogs.com/zno2/p/6555238.html