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

推荐订阅源

GbyAI
GbyAI
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Microsoft Security Blog
Microsoft Security Blog
S
SegmentFault 最新的问题
Y
Y Combinator Blog
Google DeepMind News
Google DeepMind News
Last Week in AI
Last Week in AI
博客园 - 聂微东
Attack and Defense Labs
Attack and Defense Labs
T
Tailwind CSS Blog
阮一峰的网络日志
阮一峰的网络日志
月光博客
月光博客
SecWiki News
SecWiki News
Microsoft Azure Blog
Microsoft Azure Blog
小众软件
小众软件
S
Secure Thoughts
C
Check Point Blog
WordPress大学
WordPress大学
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Google Online Security Blog
Google Online Security Blog
MongoDB | Blog
MongoDB | Blog
Schneier on Security
Schneier on Security
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Spread Privacy
Spread Privacy
IT之家
IT之家
美团技术团队
罗磊的独立博客
Google DeepMind News
Google DeepMind News
博客园 - 叶小钗
Recent Announcements
Recent Announcements
云风的 BLOG
云风的 BLOG
V
Vulnerabilities – Threatpost
Security Latest
Security Latest
博客园 - 司徒正美
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
TaoSecurity Blog
TaoSecurity Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V2EX - 技术
V2EX - 技术
Vercel News
Vercel News
有赞技术团队
有赞技术团队
J
Java Code Geeks
博客园 - 【当耐特】
Project Zero
Project Zero
NISL@THU
NISL@THU
P
Privacy & Cybersecurity Law Blog
The Last Watchdog
The Last Watchdog
aimingoo的专栏
aimingoo的专栏
S
Securelist
The Cloudflare 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 验证.