惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
The GitHub Blog
The GitHub Blog
Vercel News
Vercel News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
F
Fortinet All Blogs
Jina AI
Jina AI
I
InfoQ
T
The Blog of Author Tim Ferriss
P
Proofpoint News Feed
博客园 - 三生石上(FineUI控件)
G
Google Developers Blog
V
Visual Studio Blog
L
LangChain Blog
WordPress大学
WordPress大学
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
T
Tor Project blog
GbyAI
GbyAI
MongoDB | Blog
MongoDB | Blog
V
V2EX
Stack Overflow Blog
Stack Overflow Blog
H
Help Net Security
Recorded Future
Recorded Future
N
News and Events Feed by Topic
云风的 BLOG
云风的 BLOG
Martin Fowler
Martin Fowler
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
O
OpenAI News
Google DeepMind News
Google DeepMind News
S
Schneier on Security
C
Check Point Blog
N
Netflix TechBlog - Medium
The Register - Security
The Register - Security
aimingoo的专栏
aimingoo的专栏
TaoSecurity Blog
TaoSecurity Blog
T
Tenable Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Hugging Face - Blog
Hugging Face - Blog
Cyberwarzone
Cyberwarzone
月光博客
月光博客
The Last Watchdog
The Last Watchdog
B
Blog
有赞技术团队
有赞技术团队
Blog — PlanetScale
Blog — PlanetScale
T
Tailwind CSS Blog
Hacker News: Ask HN
Hacker News: Ask HN
H
Heimdal Security Blog
美团技术团队

博客园 - Yu

Illegal characters in path 依赖注入的 Singleton、Scoped、Transient vs2015 编译报错:The project references NuGet package(s) that are missing on this computer... discuz 迁移 uc_server 报错 The timeout period elapsed prior to completion of the operation or the server is not responding. 微信小程序笔记 Ubuntu64 apache2+lvs+Keepalived NPOI CellStyle 设置 mysql --initialize specified but the data directory has files in it select2 多选设置默认值 VS 2015 IDE 不支持 MS SQL 2000 生成 dbml Ajax 如何执行 Response.Redirect ng 发生 Error: ELOOP: too many symbolic links encountered... jquery call cross-domain webapi owin self-host HtmlAgilityPack 使用 微信 oauth2 两次回调 EF 热加载 Winform/Asp.net vs2015 使用 Eazfuscator.NET 3.3 The requested page cannot be accessed because the related configuration data for the page is invalid.
xmlns 与 targetNamespace 的解释
Yu · 2018-03-13 · via 博客园 - Yu
test.xsd文件:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema elementFormDefault="qualified" 
targetNamespace="http://xxx/myxml"
xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns="http://xxx/myxml">
    <xs:element name="my-document">
        <xs:complexType>
            <xs:choice>
                <xs:element name="my-mn"/>
                <xs:element name="my-case"/>
            </xs:choice>
            </xs:complexType>
    </xs:element>
    <xs:element name="my-mn"/>
    <xs:element name="my-case">
        <xs:complexType>
            <xs:choice>
                <xs:element ref="my-mn"/>
            </xs:choice>
        </xs:complexType>
    </xs:element>
</xs:schema>

test.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<my-document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://xxx/myxml" 
xsi:schemaLocation="http://xxx/myxml test.xsd">
<my-case>
<my-mn>
</my-mn>
</my-case>
</my-document>

targetNamespace 是一个被xml文件某些元素的xmlns或xmlns:xxx属性引用的目标命名空间值,其值通常以URI形式存在. 它也可以被自身xsd文件schema元素的xmlns属性引用.(红色字体部分) xmlns或xmlns:xxx决定了某元素的归属问题,也包括 ref 所指向的值, 如:<xs:element ref="my-mn"/>中的 my-mn. 这里的问题就是: xsd文件中红色字体部分: xmlns="http://xxx/myxml" 是否一定要出现? 答案是:不一定. 在这个xsd中,它是一定要出现的, 否则 <xs:element ref="my-mn"/> 中的 my-mn 找不到命名空间, 如果把它改成 <xs:element name="my-mn"/> ,则可以不出现. 在xml文件中,如果使用的 xsd 定义的元素(无前缀),则 xmlns="http://xxx/myxml" 必须出现在xml文件中,且跟targetNamespace 的值保持一致. 而 xsi:schemaLocation 则是该 xsd文件的真实地址(每两个值为一对,取自第二个值), 否则无法通过 schema 验证.