Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/455.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java TargetNamespace与命名空间的区别_Java_Xml_Xsd_Namespaces - Fatal编程技术网

Java TargetNamespace与命名空间的区别

Java TargetNamespace与命名空间的区别,java,xml,xsd,namespaces,Java,Xml,Xsd,Namespaces,我是xsd新手,正在学习名称空间。看到了所有的问题,博客等,但没有人能帮助我以简单的方式理解 到目前为止,我所理解的是,名称空间用于区分具有相同名称的元素。未清除有关targetnamespace的信息 我对名称空间的理解如下 xlmns:foo()="URI" -->Namespace (Its a unique token I would say which is responsible to differentiate elements with this syntax. And t

我是xsd新手,正在学习名称空间。看到了所有的问题,博客等,但没有人能帮助我以简单的方式理解

到目前为止,我所理解的是,名称空间用于区分具有相同名称的元素。未清除有关targetnamespace的信息

我对名称空间的理解如下

xlmns:foo()="URI" -->Namespace (Its a unique token I would say which is responsible to differentiate elements with this syntax. And this synatx given a name and the criteria of making that name is Prefix:ElementName-->Prefix.
我有一个例子

<foo:tag xmlns:foo="http://me.com/namespaces/foofoo"  
         xmlns:bar="http://me.com/namespaces/foobar"  
         >  

  <foo:head>  
    <foo:title>An example document</foo:title>  
  </foo:head>  

  <bar:body>  
    <bar:e1>a simple document</bar:e1>  
    <bar:e2>  
      Another element  
    </bar:e2>  
  </bar:body>  
</foo:tag>
这和java中的情况一样,在一个包中,我们可以有多个类,每个类都有自己的属性,如果是xml,则每个类都有自己的元素。我说得对吗?有人能帮助我理解TargetNamespace吗?

TargetNamespace是将要分配给您正在创建的架构的命名空间,或此架构要针对或验证的命名空间。它是实例用来访问它声明的类型的名称空间

例如:

<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.bestxml.com/jswbook/po">
...
</schema>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.bestxml.com/jswbook/po">
...
</schema>
<purchaseOrder xmlns="http://www.bestxml.com/jswbook/po"
xmlns:addr="http://www.bestxml.com/jwsbook/addr">
  <accountName>Shanita</accountName>
  <accountNumber>123456</accountNumber>
  <addr:street>20 King St</addr:street>
</purchaseOrder>