CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2007
    Posts
    19

    why is this XML not validating?

    Have the following XSD:

    <?xml version="1.0"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.org/mytypes" xmlns:tns="http://example.org/mytypes">

    <xsd:complexType name="personinfo2">
    <xsd:sequence>
    <xsd:element name="lastname" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>

    <xsd:element name="employee" type="tnsersoninfo2"/>

    </xsd:schema>

    and the following XML file:
    <employee xmlns='http://example.org/mytypes'><lastname>smith</lastname></employee>


    why is it failing validation with this message?:

    "The element 'employee' in namespace 'http://example.org/mytypes' has invalid child element 'lastname' in namespace 'http://example.org/mytypes'. List of possible elements expected: 'lastname'."

  2. #2
    Join Date
    Mar 2000
    Location
    Vancouver, BC, Canada
    Posts
    278

    Re: why is this XML not validating?

    this might not be an issue HERE, but check the fact that you're using single quotes instead of proper quotation marks in you XML file when you declare your namespace.
    David Meikle
    Quantum Unit Solutions, LLC
    www.quantumunit.com

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured