Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help with a simple schema

    Description of attachments:
    - xml.txt - my xml document
    - xsd.txt - the schema for my xml document
    - diagram.jpeg - a visual display of how I want my data stored

    I am just starting to study XML and have run into a small roadblock. I created an xml file to store films, books and cds.

    For some reason, I don't think that my schema is correct, but I'm not sure what's wrong. I have followed the w3schools tutorials and think I'm doing everything correctly.

    Would anyone be willing to take a look and let me know if I'm not understanding something really basic?

    Thanks in advance!
    Attached Thumbnails Attached Thumbnails Need help with a simple schema-diagram.jpg  
    Attached Files Attached Files

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by seventonecoder View Post
    Description of attachments:
    - xml.txt - my xml document
    - xsd.txt - the schema for my xml document
    - diagram.jpeg - a visual display of how I want my data stored

    I am just starting to study XML and have run into a small roadblock. I created an xml file to store films, books and cds.

    For some reason, I don't think that my schema is correct, but I'm not sure what's wrong. I have followed the w3schools tutorials and think I'm doing everything correctly.

    Would anyone be willing to take a look and let me know if I'm not understanding something really basic?

    Thanks in advance!
    this is the schema generated with trang after your xml:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
      <xs:element name="media">
        <xs:complexType>
          <xs:sequence>
            <xs:element ref="films"/>
            <xs:element ref="books"/>
            <xs:element ref="cds"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="films">
        <xs:complexType>
          <xs:sequence>
            <xs:element maxOccurs="unbounded" ref="film"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="film">
        <xs:complexType>
          <xs:sequence>
            <xs:element ref="title"/>
            <xs:element ref="director"/>
            <xs:element ref="rating"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="director" type="xs:string"/>
      <xs:element name="rating" type="xs:NCName"/>
      <xs:element name="books">
        <xs:complexType>
          <xs:sequence>
            <xs:element maxOccurs="unbounded" ref="book"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="book">
        <xs:complexType>
          <xs:sequence>
            <xs:element ref="title"/>
            <xs:element ref="author"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="author" type="xs:string"/>
      <xs:element name="cds">
        <xs:complexType>
          <xs:sequence>
            <xs:element maxOccurs="unbounded" ref="cd"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="cd">
        <xs:complexType>
          <xs:sequence>
            <xs:element ref="title"/>
            <xs:element ref="artist"/>
            <xs:element ref="genre"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="artist" type="xs:string"/>
      <xs:element name="genre" type="xs:string"/>
      <xs:element name="title" type="xs:string"/>
    
    </xs:schema>
    you don't use the w3c schema, mising namespace but use a string type( from w3c schema? or one of your own?)
    in rest seems ok but only a application could tell if is really ok or not.

    best regards

  • #3
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for your reply!

    The URI I used was ficticious and was just something using my organizations domain name.

    Fixing the namespace declaration (I'm still learning about this ) as per your example fixed my original problem of the invalid schema root element.

    Now I recieve a different error. I should probably tell you what I'm trying to accomplish here....

    I am programming in Microsoft Visual FoxPro 9 and am using the XmlAdapter class, anyways when I use the LoadXml function I get the errors as pictured in the attached. I am convinced that there must be something wrong with my schema yet instead of my Visual FoxPro code as I only get the error when I use the xml and schema in my original post.

    Thanks again!

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    
      <xs:element name="media">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="films">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="film" type="xs:filmType" minOccurs="0" maxOccurs="unbounded" />
                </xs:sequence>
              </xs:complexType>
            </xs:element>
            <xs:element name="books">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="book" type="xs:bookType" minOccurs="0" maxOccurs="unbounded" />
                </xs:sequence>
              </xs:complexType>
            </xs:element>
            <xs:element name="cds">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="cd" type="xs:cdType" minOccurs="0" maxOccurs="unbounded" />
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    
      <xs:complexType name="filmType">
        <xs:sequence>
          <xs:element name="title" type="xs:string" minOccurs="1" maxOccurs="1" />
          <xs:element name="director" type="xs:string" minOccurs="1" maxOccurs="1" />
          <xs:element name="rating" type="xs:string" minOccurs="1" maxOccurs="1" />
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="bookType">
        <xs:sequence>
          <xs:element name="title" type="xs:string" minOccurs="1" maxOccurs="1" />
          <xs:element name="author" type="xs:string" minOccurs="1" maxOccurs="1" />
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="cdType">
        <xs:sequence>
          <xs:element name="title" type="xs:string" minOccurs="1" maxOccurs="1" />
          <xs:element name="artist" type="xs:string" minOccurs="1" maxOccurs="1" />
          <xs:element name="genre" type="xs:string" minOccurs="1" maxOccurs="1" />
        </xs:sequence>
      </xs:complexType>
    </xs:schema>
    Attached Thumbnails Attached Thumbnails Need help with a simple schema-error_a.jpg   Need help with a simple schema-error_b.jpg  

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    last time when I work with foxpro was not visual and not owned by microsoft,
    unfortunately I can't say what's wrong because I have no idea. My guess is that is a problem with some xpath expression.
    the attributes names must match with what you have in test.xsd.

    Edit: in second pictures you have @name = 'cd' and must be @name = 'cdType'. Also there is a 'cds' there, that could be wrong

    Edit: sorry, I'm wrong I miss that both 'cd' and 'cds' are in your file

    best regards
    Last edited by oesxyl; 10-14-2008 at 12:13 AM.

  • #5
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    I don't know if this could change something but try to replace "'" with &apos; in your xml file.
    If ms don't change the meaning of an adapter there must be a way to serialize the data and save the schema of a table/database so you can try first to create the database/table in foxpro and then to get the xml and schema and see the difference with what you done.( just ignore if what I said is stupid, )

    best regards
    .

  • #6
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'll give it a try. Thanks again for your time and assistance with this.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •