LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-08-2009, 02:17 PM   #1
PatrickNew
Senior Member
 
Registered: Jan 2006
Location: Charleston, SC, USA
Distribution: Debian, Gentoo, Ubuntu, RHEL
Posts: 1,148
Blog Entries: 1

Rep: Reputation: 48
XML Schema Issue


Okay, so I finished the w3schools tutorial on XML Schema, and I still have a question about something. I'm trying to do something like type inheritance. I think a quick example would demonstrate this well:

Code:
<scope>
  <var_decl/>
  <var_decl/>
  <conditional />
  <loop />
</scope>
The idea is that scope should be able to contain an ordered list of statements, where a var_decl is a statement, a condition is a statement, and a loop is a statement.

Relevant XSD snippets of my current attempts are included below:
Code:
<xs:complexType name="statement">
  <xs:choice>
    <xs:element ref="var_decl"/>
    <xs:element ref="conditional"/>
    <xs:element ref="loop"/>
  </xs:choice>
</xs:complexType>
But this doesn't really do what I want. This defines the type 'statement' to be an element that contains a var_decl, conditional, or loop. I want it to define a type that IS either a var_decl, conditional, or loop.

Any ideas?
 
Old 01-10-2009, 01:41 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

Here's a link that discusses what you're trying to do:

ftp://ftp.computer.org/press/outgoin...hipala-xml.pdf

Code:
<xs:complexType name="EmployeeType">
  <xs:sequence>
    <xs:element name="id" type="xs:string"/>
    <xs:element name="name" type="xs:string"/>
    <xs:element name="gender" type="xs:string"/>
  </xs:sequence>
</xs:complexType>
Code:
<xs:complexType name="PermanentEmployeeType">
  <xs:complexContent>
    <xs:extension base="EmployeeType">
      <xs:sequence>
        <xs:element name="salary" type="xs:string"/>
      </xs:sequence>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>
'Hope that helps .. PSM
 
Old 01-12-2009, 09:29 AM   #3
PatrickNew
Senior Member
 
Registered: Jan 2006
Location: Charleston, SC, USA
Distribution: Debian, Gentoo, Ubuntu, RHEL
Posts: 1,148

Original Poster
Blog Entries: 1

Rep: Reputation: 48
That helps a lot. Thanks man!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: An introduction to XML Schema 1.1 LXer Syndicated Linux News 0 12-10-2008 08:30 AM
XML Schema element references Omni Programming 0 09-22-2006 02:07 PM
XML Schema - redifinition of tags Omni Programming 2 09-20-2006 10:48 AM
Need help finding an XML Schema validator Omni Programming 2 09-11-2006 03:10 PM
XML Schema complexType eric.r.turner Programming 1 12-28-2003 04:01 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration