xsd: any complex type?

Al

Usenet Archive
Joined
Mar 29, 2000
Messages
343
Reaction score
0
Hello,
working on an xsd schema, I'd like it to have a node of which I don't know the content at design time: I want the document instance to identify such node contents, where content should have a complex structure (complex type).
Probably xs:anytype is what I need, but I miss something...

In the following schema, I define a "genericchild" node, which I'd want to be able to contain any (complex type) node I want to put in there:
:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="myroot"> <xs:complexType> <xs:sequence> <xs:element name="genericchild" type="xs:anyType"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>

what I expect, is to build document instances like:

<myroot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\prova.xsd"> <genericchild><node1>string</node1></genericchild> </myroot>

or

<myroot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\prova.xsd"> <genericchild><node2><a>atext</a><bb/></node2></genericchild> </myroot>

Probably, such nodes (node1 & 2) should declare their namespace if I want to validate, and/or should be declared as complex types, but the problem is I get errors because "only text allowed inside element 'genericchild'". Of course, the following validates well:

<myroot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\prova.xsd"> <genericchild>aa</genericchild> </myroot>

Can anybody help?
thank you,
al.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,802
Members
249,594
Latest member
henrywalsh

Latest Threads

Top