XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old August 11th, 2003, 10:15 AM
mgsica mgsica is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2001
Posts: 6 mgsica User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
XML / XML Schema Question

Hello All,

If anyone has any experience with XML Schema's I have a question for you.

I wrote this XML:

Code:
<?xml version="1.0"?>
<content xmlns="http://www.michaelsica.com"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://www.michaelsica.com content.xsd">
   <meta>
      <title>The Title</title>
      <author>Michael Sica</author>
      <date>2003-05-23</date>
   </meta>
   <item>
      <para id="1">
         Here is the first paragraph. 
         It contains a 
         <link address="http://www.google.com" title="Search  
         Engine">link</link> in the second sentence.
      </para>
      <para id="2">
         Here is the second paragraph. 
       <image  align="right">
       http://www.google.com/images/logo.gif</image> 
       It has an image in it. Aligned to the right.
      </para>
      <para id="3">
         Here is the third paragraph. It has both a 
         <link address="">link</link> and an 
          <image align="left">http://www.google.com/images/logo.gif</image> 
          image in it. But this image is aligned to the left. 
      </para>
   </item>
</content>


And I have been trying to write a schema for it. I run into trouble with the "para" tags because they are an element that contians other elements and character data. Here is the schema I wrote...

Code:
<?xml version="1.0"?>
<xs:schema targetNamespace="http://www.michaelsica.com" 
           xmlns="http://www.michaelsica.com" 
           xmlns:xs="http://www.w3.org/2001/XMLSchema" 
           elementFormDefault="qualified">
   <xs:element name="content">
      <xs:complexType>
         <xs:sequence>
            <xs:element name="meta">
               <xs:complexType>
                  <xs:sequence>
                     <xs:element name="title" type="xs:string"/>
                     <xs:element name="author" type="xs:string"/>
                     <xs:element name="date" type="xs:date"/>
                  </xs:sequence>
               </xs:complexType>
            </xs:element>
            
            <xs:element name="item">
               <xs:complexType>
                  <xs:sequence>
                  
                     <xs:element name="para" minOccurs="0" maxOccurs="unbounded">
                        <xs:complexType mixed="true">
                           <xs:sequence>                              
                              <xs:any/>
                           </xs:sequence>                              
                           <xs:attribute name="id" type="xs:integer" use="required"/>
                        </xs:complexType>
                     </xs:element>
                     
                  </xs:sequence>
               </xs:complexType>
            </xs:element>
            
         </xs:sequence>
      </xs:complexType>
   </xs:element>
</xs:schema>


I've tried using a couple of software packages (free trial of XMLSpy and a few others) and they all give me a warning that the "link" tag is used but not declared.

Is this ok or do I have to do more?

I tried using the following,

Code:
<xs:element name="link" minOccurs="0" maxOccurs="unbounded">
   <xs:complexType>
      <xs:simpleContent>
         <xs:extension base="xs:string">
            <xs:attribute name="address" type="xs:anyURI"/>
            <xs:attribute name="title" type="xs:string"/>
         </xs:extension>
      </xs:simpleContent>
   </xs:complexType>
</xs:element>

<xs:element name="image" minOccurs="0" maxOccurs="unbounded">
   <xs:complexType>
      <xs:simpleContent>
         <xs:extension base="xs:anyURI">
            <xs:attribute name="align" type="xs:string"/>
         </xs:extension>
      </xs:simpleContent>
   </xs:complexType>
</xs:element>


But if I put this inside an <xs:all> tag set then I can't have more than 1 occurence of the tags inside the "para" tag.

Have I completly missed something?

Thanks for any help,
-michael.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > XML / XML Schema Question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway