xsd: any complex type?

Discussion in 'XML' started by AL, Jan 8, 2004.

  1. AL

    AL Guest

    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.
    AL, Jan 8, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Markus
    Replies:
    1
    Views:
    1,077
    Markus
    Nov 22, 2005
  2. Rick Razzano

    XSD document for XSD defintion

    Rick Razzano, Sep 26, 2003, in forum: XML
    Replies:
    1
    Views:
    462
    C. M. Sperberg-McQueen
    Sep 26, 2003
  3. Peter Aberline

    xsd:any as a child of xsd:all

    Peter Aberline, Apr 5, 2004, in forum: XML
    Replies:
    0
    Views:
    770
    Peter Aberline
    Apr 5, 2004
  4. Stanimir Stamenkov
    Replies:
    2
    Views:
    732
    Stanimir Stamenkov
    Oct 25, 2005
  5. Robert Mark Bram
    Replies:
    0
    Views:
    670
    Robert Mark Bram
    Feb 4, 2007
Loading...

Share This Page