Solved

XML Schema for child and parent node the same

Posted on 2006-10-24
9
290 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
  • 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
 

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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Vb.net XML Read all nodes and 4 73
Coldfusion- Create and save form elements in Database 7 61
Word files to Wordpress Posts 2 43
Facebook React and SyntheticEvents 6 49
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now