Solved

XML Schema for child and parent node the same

Posted on 2006-10-24
9
293 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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 

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 200 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Cordova Camera plugin fails 2 166
Customizing XML with Powershell 2 32
customizing windows 10 taskbar and startmenu 2 39
XSL for-each loop - Excluding specific text 4 17
Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa‚Ķ
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
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:
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

733 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