Solved

XML Schema for child and parent node the same

Posted on 2006-10-24
9
291 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
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: 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

773 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