1

Topic: xsd, with namespace

Hello.
Prompt please how in xsd to declare  which in xml is specified with a name space?
For example

<msg:Header>... </msg:Header>
<xs:element name = "msg:Header">

does not work.
In advance thanks.

2

Re: xsd, with namespace

;
The decision from this article to repeat it did not turn out

<xs:element name = "Header" type = "msg:mes">
<xs:complexType type = "mes"]

wrote:

Attribute ' type ' cannot appear in element ' complexType '.

ps mes as I understood is made up

3

Re: xsd, with namespace

Design error

<xs:element name = "Header" type = "msg:mes">
<xs:complexType type = "mes">

4

Re: xsd, with namespace

<xs:complexType name = "mes">

too tried, the same error.

5

Re: xsd, with namespace

smoyk;

<xs:element name = "Header" type = "mes">

?

6

Re: xsd, with namespace

mage.lan;
And probably even without type

7

Re: xsd, with namespace

One XSD the circuit can declare elements only in one name space. This name space is set by attribute targetNamespace an element xsd:schema . If you need to describe XML, containing elements from several name spaces you need to create a little XSD circuits with different targetNamespace , and then to unite them in one by means of an element xsd:import

8

Re: xsd, with namespace

mage.lan;
Also what it will be? To me "msg" the name space needs to be set.
_Vasilisk _;
I while also need one, and yes, I declared targetNamespace, at me it is impossible to set further a name space, an error produces.

9

Re: xsd, with namespace

smoyk wrote:

I while also need one, and yes, I declared targetNamespace, at me it is impossible to set further a name space, an error produces.

Let's talk the code. What is, what is necessary, what it is impossible?

10

Re: xsd, with namespace

_Vasilisk _;
In xml a file there is element Header with the specified name space msg. I do not know how to specify this name space at an element in xsd to the circuit.
Variant

<xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema" xmlns:sql = "urn:schemas-microsoft-com:mapping-schema" xmlns:msg = "http://www.1c.ru/SSL/Exchange/Message" targetNamespace = "http://www.1c.ru/SSL/Exchange/Message">
<xs:annotation>
<xs:appinfo>
<sql:relationship name = "MessageObject" parent = "import. Messages" parent-key = "OriginFileName" child = "import. Objects" child-key = "OriginFileName"/>
</xs:appinfo>
</xs:annotation>
<xs:element name = "Message">
<xs:complexType>
<xs:sequence>
<xs:element name = "Header" type = "msg:mes" sql:relation = "import. Messages" sql:relationship = "MessageObject">
<xs:complexType name = "mes">
<xs:sequence>
<xs:element name = "CreationDate" sql:datatype = "datetime"/>
.........

Does not work

wrote:

Attribute ' name ' cannot appear in element ' complexType '.

11

Re: xsd, with namespace

smoyk wrote:

In xml a file there is element Header

Result XML

smoyk wrote:

with the specified name space msg.

It not a name space, and  name spaces
I.e., as I understood, you in XML have elements which belong to two to name spaces. One name space on-default (empty), and the second "http://www.1c.ru/SSL/Exchange/Message". Proceeding from it, your phrase

smoyk wrote:

I while also need one

does not represent the facts. And it is necessary for you, as I already spoke
[quote = _ Vasilisk _] you need to create a little XSD circuits with different targetNamespace , and then to unite them in one by means of an element xsd:import