gpt4 book ai didi

xsd - xmln :tns and targetNamespace

转载 作者:行者123 更新时间:2023-12-03 11:51:11 25 4
gpt4 key购买 nike

我看到一些 XSD 架构文档声明了 targetNamespace和一个 xmlns:tns属性在他们的顶部 schema元素。例如。以下是拍的from here .它们似乎也具有相同的字符串值。我了解targetNamespace的作用但什么是 xmlns:tns除此之外呢?

<?xml version="1.0" encoding="UTF-8"?>
<schema
xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/Product"
xmlns:tns="http://www.example.org/Product"
elementFormDefault="qualified">
...

最佳答案

它允许您稍后在架构中引用命名空间。例如,如果您声明了一个命名类型,然后还想声明该类型的元素

<complexType name="someType">
<!-- ... -->
</complexType>

<element name="someElement" type="tns:someType" />

简单地说 type="someType"不起作用,因为那将指的是(不存在的) someTypehttp://www.w3.org/2001/XMLSchema命名空间(架构文件的 xmlns="...")而不是 http://www.example.org/Product 中的命名空间命名空间。

关于xsd - xmln :tns and targetNamespace,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17295588/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com