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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Trouble with XML/XSD validation

    Hi everyone, XML newb here.

    I'm working on a MS Exchange ActiveSync Autodiscover proxy. The proxy receives XML as input from an Exchange client. I need to validate this XML against an XSD file that Microsoft publishes here:

    http://msdn.microsoft.com/en-us/libr...exchg.80).aspx

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <xs:schema
    xmlns="http://schemas.microsoft.com/exchange/autodiscover/mobilesync/requestschema/2006"
    xmlns:mstns="http://schemas.microsoft.com/exchange/autodiscover/mobilesync/requestschema/2006" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://schemas.microsoft.com/exchange/autodiscover/mobilesync/requestschema/2006"
    elementFormDefault="unqualified" id="requestschema2006">
        <xs:element name="Autodiscover">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="Request" type="RequestType"/>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
        <xs:complexType name="RequestType">
            <xs:sequence>
                <xs:sequence>
                    <xs:element name="EMailAddress" type="xs:string"/>
                    <xs:element name="AcceptableResponseSchema" type="xs:string"/>
                </xs:sequence>
            </xs:sequence>
        </xs:complexType>
    </xs:schema>
    An example of an instance XML is this (which is also published by MS):

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/mobilesync/requestschema/2006">
        <Request>
            <EMailAddress>chris@woodgrovebank.com</EMailAddress>
            <AcceptableResponseSchema>
                http://schemas.microsoft.com/exchange/autodiscover/mobilesync/
                responseschema/2006
            </AcceptableResponseSchema>
        </Request>
    </Autodiscover>
    However, the XML does NOT pass validation against this XSD. I've used Visual Studio and online XSD testers to check and some of the error messages I get include:

    Code:
    Cvc-complex-type.2.4.a: Invalid Content Was Found Starting With Element 'Request'. One Of '{Request}' Is Expected..
    and

    Code:
    The element 'Autodiscover' in namespace 'http://schemas.microsoft.com/exchange/autodiscover/mobilesync/requestschema/2006' has invalid child element 'Request' in namespace 'http://schemas.microsoft.com/exchange/autodiscover/mobilesync/requestschema/2006'. List of possible elements expected: 'Request'.
    Keep in mind that both the XML and XSD are provided by Microsoft themselves so I don't understand why it's not validating. Can anyone please shed some light on this? I've been stuck on this for days. Any help would be greatly appreciated!

  • #2
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It's strange because if I add the attribute xml="" to the <Request> element in the XML, then it validates fine..

  • #3
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,453
    Thanks
    1
    Thanked 21 Times in 19 Posts
    Which validator are you using? (I'm just curious. I don't know the answer to your problem.)
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog

  • #4
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Alex Vincent View Post
    Which validator are you using? (I'm just curious. I don't know the answer to your problem.)
    VS2010 gives me error messages, but I've also used:
    http://www.freeformatter.com/xml-validator-xsd.html

    and

    http://www.xmlforasp.net/schemavalidator.aspx


  •  

    Posting Permissions

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