xml won't validate, having trouble with namespaces









up vote
1
down vote

favorite












I'm about to pull my hair out trying to figure out why this won't validate. I keep getting the error




cvc-elt.1: Cannot find the declaration of element 'ret'. [13]




Before I was getting the error on schemaLocation and it was telling me the URIs needed to be the same length or something but I fixed that by making schemaLocation, target, and targetNamespace the same.



But it still can't find my "ret" element declaration and I can't find out why. Now I'm not very good at namespaces, I don't understand them as well as everything else.



Any help would be much appreciated to figure out how to fix this error.



Oh also my .xsd file is named "ret" and so is my first element. I don't think that's causing an issue but so it doesn't confuse anyone. It's just a requirement I have.



<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:My.Namespace"
xmlns:target="urn:My.Namespace ret.xsd"
elementFormDefault="qualified"
>

<xs:element name="ret">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="feed" />
<xs:element ref="doc-copyright" />
</xs:sequence>
<xs:attribute fixed="1.0" name="version" type="xs:string" />
<xs:attribute name="date" type="xs:string" use="required" />
</xs:complexType>
</xs:element>


This is part of my .xsd file



<?xml version="1.0" encoding="UTF-8"?>

<ret
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.w3schools.com"
xsi:schemaLocation="urn:My.Namespace ret.xsd">
</ret>


This is the part of the xml file that won't validate. If I need to post more I can. It is pretty long though. I'm wondering if this error is because My.Namespace isn't a valid namespace? I just don't understand.










share|improve this question



























    up vote
    1
    down vote

    favorite












    I'm about to pull my hair out trying to figure out why this won't validate. I keep getting the error




    cvc-elt.1: Cannot find the declaration of element 'ret'. [13]




    Before I was getting the error on schemaLocation and it was telling me the URIs needed to be the same length or something but I fixed that by making schemaLocation, target, and targetNamespace the same.



    But it still can't find my "ret" element declaration and I can't find out why. Now I'm not very good at namespaces, I don't understand them as well as everything else.



    Any help would be much appreciated to figure out how to fix this error.



    Oh also my .xsd file is named "ret" and so is my first element. I don't think that's causing an issue but so it doesn't confuse anyone. It's just a requirement I have.



    <?xml version="1.0" encoding="UTF-8"?>

    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="urn:My.Namespace"
    xmlns:target="urn:My.Namespace ret.xsd"
    elementFormDefault="qualified"
    >

    <xs:element name="ret">
    <xs:complexType>
    <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="feed" />
    <xs:element ref="doc-copyright" />
    </xs:sequence>
    <xs:attribute fixed="1.0" name="version" type="xs:string" />
    <xs:attribute name="date" type="xs:string" use="required" />
    </xs:complexType>
    </xs:element>


    This is part of my .xsd file



    <?xml version="1.0" encoding="UTF-8"?>

    <ret
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://www.w3schools.com"
    xsi:schemaLocation="urn:My.Namespace ret.xsd">
    </ret>


    This is the part of the xml file that won't validate. If I need to post more I can. It is pretty long though. I'm wondering if this error is because My.Namespace isn't a valid namespace? I just don't understand.










    share|improve this question

























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I'm about to pull my hair out trying to figure out why this won't validate. I keep getting the error




      cvc-elt.1: Cannot find the declaration of element 'ret'. [13]




      Before I was getting the error on schemaLocation and it was telling me the URIs needed to be the same length or something but I fixed that by making schemaLocation, target, and targetNamespace the same.



      But it still can't find my "ret" element declaration and I can't find out why. Now I'm not very good at namespaces, I don't understand them as well as everything else.



      Any help would be much appreciated to figure out how to fix this error.



      Oh also my .xsd file is named "ret" and so is my first element. I don't think that's causing an issue but so it doesn't confuse anyone. It's just a requirement I have.



      <?xml version="1.0" encoding="UTF-8"?>

      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="urn:My.Namespace"
      xmlns:target="urn:My.Namespace ret.xsd"
      elementFormDefault="qualified"
      >

      <xs:element name="ret">
      <xs:complexType>
      <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" ref="feed" />
      <xs:element ref="doc-copyright" />
      </xs:sequence>
      <xs:attribute fixed="1.0" name="version" type="xs:string" />
      <xs:attribute name="date" type="xs:string" use="required" />
      </xs:complexType>
      </xs:element>


      This is part of my .xsd file



      <?xml version="1.0" encoding="UTF-8"?>

      <ret
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://www.w3schools.com"
      xsi:schemaLocation="urn:My.Namespace ret.xsd">
      </ret>


      This is the part of the xml file that won't validate. If I need to post more I can. It is pretty long though. I'm wondering if this error is because My.Namespace isn't a valid namespace? I just don't understand.










      share|improve this question















      I'm about to pull my hair out trying to figure out why this won't validate. I keep getting the error




      cvc-elt.1: Cannot find the declaration of element 'ret'. [13]




      Before I was getting the error on schemaLocation and it was telling me the URIs needed to be the same length or something but I fixed that by making schemaLocation, target, and targetNamespace the same.



      But it still can't find my "ret" element declaration and I can't find out why. Now I'm not very good at namespaces, I don't understand them as well as everything else.



      Any help would be much appreciated to figure out how to fix this error.



      Oh also my .xsd file is named "ret" and so is my first element. I don't think that's causing an issue but so it doesn't confuse anyone. It's just a requirement I have.



      <?xml version="1.0" encoding="UTF-8"?>

      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="urn:My.Namespace"
      xmlns:target="urn:My.Namespace ret.xsd"
      elementFormDefault="qualified"
      >

      <xs:element name="ret">
      <xs:complexType>
      <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" ref="feed" />
      <xs:element ref="doc-copyright" />
      </xs:sequence>
      <xs:attribute fixed="1.0" name="version" type="xs:string" />
      <xs:attribute name="date" type="xs:string" use="required" />
      </xs:complexType>
      </xs:element>


      This is part of my .xsd file



      <?xml version="1.0" encoding="UTF-8"?>

      <ret
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://www.w3schools.com"
      xsi:schemaLocation="urn:My.Namespace ret.xsd">
      </ret>


      This is the part of the xml file that won't validate. If I need to post more I can. It is pretty long though. I'm wondering if this error is because My.Namespace isn't a valid namespace? I just don't understand.







      xml xsd






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 10 at 7:32









      marc_s

      567k12810961246




      567k12810961246










      asked Nov 10 at 3:45









      Saiba

      336




      336






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          In your schema, you said that your elements will be bound to the urn:My.Namespace when you have @targetNamespace="urn:My.Namespace".



          But your instance XML document has a "ret" element that is bound to the http://www.w3schools.com namespace.



          In order for it to be schema valid, it must be bound to the urn:Ny.Namespace namespace.



          Change it to:



          <ret 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns="urn:My.Namespace"
          xsi:schemaLocation="urn:My.Namespace ret.xsd">
          </ret>


          and then deal with the other validation issues (no feed, doc-copyright, @version, or @date)






          share|improve this answer




















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53235833%2fxml-wont-validate-having-trouble-with-namespaces%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote



            accepted










            In your schema, you said that your elements will be bound to the urn:My.Namespace when you have @targetNamespace="urn:My.Namespace".



            But your instance XML document has a "ret" element that is bound to the http://www.w3schools.com namespace.



            In order for it to be schema valid, it must be bound to the urn:Ny.Namespace namespace.



            Change it to:



            <ret 
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns="urn:My.Namespace"
            xsi:schemaLocation="urn:My.Namespace ret.xsd">
            </ret>


            and then deal with the other validation issues (no feed, doc-copyright, @version, or @date)






            share|improve this answer
























              up vote
              0
              down vote



              accepted










              In your schema, you said that your elements will be bound to the urn:My.Namespace when you have @targetNamespace="urn:My.Namespace".



              But your instance XML document has a "ret" element that is bound to the http://www.w3schools.com namespace.



              In order for it to be schema valid, it must be bound to the urn:Ny.Namespace namespace.



              Change it to:



              <ret 
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xmlns="urn:My.Namespace"
              xsi:schemaLocation="urn:My.Namespace ret.xsd">
              </ret>


              and then deal with the other validation issues (no feed, doc-copyright, @version, or @date)






              share|improve this answer






















                up vote
                0
                down vote



                accepted







                up vote
                0
                down vote



                accepted






                In your schema, you said that your elements will be bound to the urn:My.Namespace when you have @targetNamespace="urn:My.Namespace".



                But your instance XML document has a "ret" element that is bound to the http://www.w3schools.com namespace.



                In order for it to be schema valid, it must be bound to the urn:Ny.Namespace namespace.



                Change it to:



                <ret 
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns="urn:My.Namespace"
                xsi:schemaLocation="urn:My.Namespace ret.xsd">
                </ret>


                and then deal with the other validation issues (no feed, doc-copyright, @version, or @date)






                share|improve this answer












                In your schema, you said that your elements will be bound to the urn:My.Namespace when you have @targetNamespace="urn:My.Namespace".



                But your instance XML document has a "ret" element that is bound to the http://www.w3schools.com namespace.



                In order for it to be schema valid, it must be bound to the urn:Ny.Namespace namespace.



                Change it to:



                <ret 
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns="urn:My.Namespace"
                xsi:schemaLocation="urn:My.Namespace ret.xsd">
                </ret>


                and then deal with the other validation issues (no feed, doc-copyright, @version, or @date)







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 10 at 5:14









                Mads Hansen

                43.6k1093119




                43.6k1093119



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53235833%2fxml-wont-validate-having-trouble-with-namespaces%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Use pre created SQLite database for Android project in kotlin

                    Darth Vader #20

                    Ondo