XSD 文件,从哪里获取 xmlns 参数? [英] XSD file, where to get xmlns argument?

查看:16
本文介绍了XSD 文件,从哪里获取 xmlns 参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="abc" targetNamespace="http://schemas.businessNameHere.com/SoftwareNameHere" 
           elementFormDefault="qualified" 
           xmlns="http://schemas.businessNameHere.com/SoftwareNameHere" 
           xmlns:mstns="http://schemas.businessNameHere.com/SoftwareNameHere" 
           xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="..." type="..." />
<xs:complexType name="...">

我正在开发一个使用 XSD 生成 .cs 文件的项目.我的问题是关于字符串 "http://schemas.businessNameHere.com/SoftwareNameHere" 如果我​​改变它,它不起作用.但是 http://不是一个有效的......背后的逻辑是什么,我在哪里可以找到关于放什么或如何更改它的信息?

I am working on a project using XSD to generate .cs file. My question is concerning the string "http://schemas.businessNameHere.com/SoftwareNameHere" If I change it, it doesn't work. But the http:// is not a valid one... what is the logic behind and where can I can information about what to put there or how to change it?

推荐答案

XSD 命名空间不必是有效的 URI.拥有一个作为 URL 的命名空间字符串并不意味着从 URL 中获取任何内容,或者与 Web 有任何关系——它只是一个与其他字符串一样的字符串.因此,尽管从实际上不指向任何东西的意义上说,URL 可能是无效的,但它仍然是作为命名空间声明的有效字符串.

XSD namespaces do not have to be valid URI's. Having a namespace string that is a URL doesn't mean anything is fetched from the URL, or anything to do with the web at all - it's simply a string like any other. So although the URL may be invalid from the sense that it doesn't actually point to anything, it's still a valid string as a namespace declaration.

您可以阅读一些在命名空间标识符存在的原因这个格式在这里.

使用 URL 作为命名空间标识符有几个原因,但主要是为了方便 - 它是一个唯一标识符,通常对用户具有一定的意义,就像 Java 命名空间经典以com"开头的方式、组织"或网络".

There are several reasons for using URL's as a namespace identifier, but mainly it is for convenience - it's a unique identifier that generally has some meaning attached to it for the users, much like the way Java namespaces classically begin with "com", "org" or "net".

关于为什么命名空间是 URI(技术上,IRI)格式的细节,你可以阅读 W3C 的 XML 命名空间标准.指定 XML 命名空间采用 IRI(国际资源标识符)格式,在 RFC3986.

For the nitty gritty of why namespaces are in URI (technically, IRI) format, you can read the W3C's standards for XML namespaces. The specify that XML Namespaces are in IRI (International Resource Identifier) format, defined in RFC3986.

有关如何正确使用命名空间的更多信息,有很多很棒的演练,like这个.更改命名空间时什么不起作用?

For more information on how to properly use namespaces, there are lots of great walkthroughs, like this one. What isn't working when you change the namespace?

这篇关于XSD 文件,从哪里获取 xmlns 参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆