?
Solved

XML Schema for child and parent node the same

Posted on 2006-10-24
9
Medium Priority
?
295 Views
Last Modified: 2013-11-19
Can someone giv eme some xml schema for this to be valid.

<Shapes>
<Menuitem>
<Menuitem></Menuitem>
</Menuitem>
</Shapes>
0
Comment
Question by:npl77
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 

Author Comment

by:npl77
ID: 17798227
Is this even possible?
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 17798654
Hi npl77,

yes this is possible, no problem
do you want Menuitem to be a nested element at infinite depth?
or do you want one Menuitem to include the other?

Cheers!
0
 

Author Comment

by:npl77
ID: 17798796
when an xml string comes in I check it against an xsd file, but this xml I need to be valid
<Shapes>
<Menuitem>
<Menuitem></Menuitem>
</Menuitem>
</Shapes>

only like that I have a menuitem element in the xsd, but when I say ref=menuitem within the menuitem elment its not taking it

I have in place <shapes> can take menuitems, I need to know how to say menuitems can take 0 or 1 menuitem
0
WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

 

Author Comment

by:npl77
ID: 17798916
heres my menuitem elment:

<xs:element name="menuitem">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="annotation" minOccurs="0" maxOccurs="unbounded" />
      </xs:sequence>
      <xs:anyAttribute processContents="skip" />
    </xs:complexType>
  </xs:element>
0
 

Author Comment

by:npl77
ID: 17798976
Here is a fragment of my shapes element:

 <xs:element name="Shapes">
    <xs:complexType>
      <xs:sequence>
     .
     .
     .
        <xs:element ref="menuitem" minOccurs="0" maxOccurs="unbounded" />
     .
     .
     .
      </xs:sequence>
      <xs:anyAttribute processContents="skip" />
    </xs:complexType>
  </xs:element>
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 800 total points
ID: 17798986
npl77,

this should work for you

    <xs:element name="Menuitem">
        <xs:complexType mixed="true">
            <xs:sequence>
                <xs:element ref="Menuitem" minOccurs="0" maxOccurs="1" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>

A Menuitem can contain zero or one Menuitem
or a string (hence the mixed=true)

cheers

Geert
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 17799026
npl77,

if you do it like this, the nesting is only one level deep

   <xs:element name="Menuitem">
        <xs:complexType mixed="true">
            <xs:sequence>
                <xs:element name="Menuitem" minOccurs="0" maxOccurs="1" />
            </xs:sequence>
            <xs:anyAttribute processContents="skip" />
        </xs:complexType>
    </xs:element>

the difference is that you include a local element instead of a global

cheers
0
 

Author Comment

by:npl77
ID: 17799093
Thanks Geert!

Whooho it worked!
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 17799140
welcome
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question