Solved

XML Schema for child and parent node the same

Posted on 2006-10-24
9
289 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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 …
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
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:
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

708 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

20 Experts available now in Live!

Get 1:1 Help Now