locked
xml validation issue RRS feed

  • Question

  •  

    hi guys,

    I have the following xml schema:

     

    <?xml version="1.0" encoding="utf-8"?>
    <xs:schema id="SqlTableSchema"
      targetNamespace="http://tempuri.org/SqlTableSchema.xsd"
      elementFormDefault="qualified"
      xmlns="http://tempuri.org/SqlTableSchema.xsd"
      xmlns:mstns="http://tempuri.org/SqlTableSchema.xsd"
      xmlns:xs="http://www.w3.org/2001/XMLSchema">
     <xs:element name="table">
      <xs:complexType>
       <xs:sequence>
        <xs:element name="tableName"></xs:element>
        <xs:element name ="primaryKey">
         <xs:complexType>      
          <xs:attribute name="columnName" type ="xs:string" use="required"></xs:attribute>
          <xs:attribute name="isIdentity" type ="xs:string" use="required"></xs:attribute>
         </xs:complexType>
        </xs:element>
        <xs:element name="column" maxOccurs ="50">
         <xs:complexType>
          <xs:sequence>
           <xs:element name ="name" type ="xs:string" ></xs:element>       
          </xs:sequence>
         </xs:complexType>
        </xs:element>        
       </xs:sequence>
      </xs:complexType>     
     </xs:element>
    </xs:schema>
    
    

    And this document:

    <?xml version="1.0" encoding="utf-8"?>
    <table> 
      <tableName>
        MyTable
      </tableName>
      <primaryKey columnName="tableId" isIdentity="true"></primaryKey>
      <column> tableId </column>
      <column> column1 </column>
      <column> column2 </column>
    </table>
    
    

    When I try to validate it using this site: http://tools.decisionsoft.com/schemaValidate/

    I get this error message: Cannot find the declaration of element 'table'.


    can somebody help me spot the error? I'm new to xml.

    Thanks for any help.


    • Moved by Lie You Monday, July 11, 2011 9:02 AM xml issue, not c# (From:Visual C# General)
    Tuesday, June 28, 2011 9:11 PM

Answers

  • Hi Amokachi,

    Have you resovle this issue? Could you share your solution here, which is very beneficial for other community members who have similar questions. Thanks.

    If not, you can post it to the XML Valiadtor Forum for more helps.

    Here is the link for your reference:

       XML Forum
    Thanks for your understanding and support.


    Best Regards,
    Rocky Yue[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, July 6, 2011 2:37 AM
  • This was moved out of the VC# forum.

    You can ask this in the XML forum (as suggested).

    Or I can move it into a specific MSDN forum if you'd like.

    This is regarding your code:

    <?xml version="1.0" encoding="utf-8"?>
    <xs:schema id="SqlTableSchema"
      targetNamespace="http://tempuri.org/SqlTableSchema.xsd"
      elementFormDefault="qualified"
      xmlns="http://tempuri.org/SqlTableSchema.xsd"
      xmlns:mstns="http://tempuri.org/SqlTableSchema.xsd"
      xmlns:xs="http://www.w3.org/2001/XMLSchema">
     <xs:element name="table">
      <xs:complexType>
       <xs:sequence>
        <xs:element name="tableName"></xs:element>
        <xs:element name ="primaryKey">
         <xs:complexType>      
          <xs:attribute name="columnName" type ="xs:string" use="required"></xs:attribute>
          <xs:attribute name="isIdentity" type ="xs:string" use="required"></xs:attribute>
         </xs:complexType>
        </xs:element>
        <xs:element name="column" maxOccurs ="50">
         <xs:complexType>
          <xs:sequence>
           <xs:element name ="name" type ="xs:string" ></xs:element>       
          </xs:sequence>
         </xs:complexType>
        </xs:element>        
       </xs:sequence>
      </xs:complexType>     
     </xs:element>
    </xs:schema>
    
    
    

     


    Ed Price a.k.a User Ed, Microsoft Experience Program Manager (Blog, Twitter, Wiki)
    Thursday, December 29, 2011 11:03 PM

All replies

  • Did you create xml schema from dataTable?
    Mitja
    Tuesday, June 28, 2011 9:16 PM
  • Hi Mitja,

    I created it manually. It is supposed to conform to the schema.

     

    Tuesday, June 28, 2011 9:21 PM
  • You created xml schema, and then you tried to create a dataTable (dataSet) out of it?

    Did you try that? Does it create it?


    Mitja
    Tuesday, June 28, 2011 9:47 PM
  • yes, that's what i did. created the schema manually and then tried to create manually document that conforms to it. I should be able to do that.

    Tuesday, June 28, 2011 10:04 PM
  • Hi Amokachi,

    Have you resovle this issue? Could you share your solution here, which is very beneficial for other community members who have similar questions. Thanks.

    If not, you can post it to the XML Valiadtor Forum for more helps.

    Here is the link for your reference:

       XML Forum
    Thanks for your understanding and support.


    Best Regards,
    Rocky Yue[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, July 6, 2011 2:37 AM
  • This was moved out of the VC# forum.

    You can ask this in the XML forum (as suggested).

    Or I can move it into a specific MSDN forum if you'd like.

    This is regarding your code:

    <?xml version="1.0" encoding="utf-8"?>
    <xs:schema id="SqlTableSchema"
      targetNamespace="http://tempuri.org/SqlTableSchema.xsd"
      elementFormDefault="qualified"
      xmlns="http://tempuri.org/SqlTableSchema.xsd"
      xmlns:mstns="http://tempuri.org/SqlTableSchema.xsd"
      xmlns:xs="http://www.w3.org/2001/XMLSchema">
     <xs:element name="table">
      <xs:complexType>
       <xs:sequence>
        <xs:element name="tableName"></xs:element>
        <xs:element name ="primaryKey">
         <xs:complexType>      
          <xs:attribute name="columnName" type ="xs:string" use="required"></xs:attribute>
          <xs:attribute name="isIdentity" type ="xs:string" use="required"></xs:attribute>
         </xs:complexType>
        </xs:element>
        <xs:element name="column" maxOccurs ="50">
         <xs:complexType>
          <xs:sequence>
           <xs:element name ="name" type ="xs:string" ></xs:element>       
          </xs:sequence>
         </xs:complexType>
        </xs:element>        
       </xs:sequence>
      </xs:complexType>     
     </xs:element>
    </xs:schema>
    
    
    

     


    Ed Price a.k.a User Ed, Microsoft Experience Program Manager (Blog, Twitter, Wiki)
    Thursday, December 29, 2011 11:03 PM