XSD targetNamespace does not override element namespace?What does elementFormDefault do in XSD?How to reference element in other XSD's namespace?What is this XSD import namespace for?XML + Schema + Namespaces. No matching global declaration available for the validation rootWhere is the XSD file for “http://www.w3.org/2001/XMLSchema-instance”?Intellij IDEA : How to validate XML SCHEMA 1Parsing XSD Schema with XSOM in Java. How to access attributes in another namespaceXMLSchema and XMLSchema-instance namespaces without schemaLocationError: The namespace of element schema must be from schema namespace http://www.w3.org/2001/XMLSchemaXSD error: References from this schema to components in no namespace are not allowedHow to use XSD 1.1 in Netbeans 8.2?How does an XML Validator know where to find the schema instance declared in an xml document in order to parse and use the xsd?

Planar regular languages

Is there a real-world mythological counterpart to WoW's "kill your gods for power" theme?

How do EVA suits manage water excretion?

What is a realistic time needed to get a properly trained army?

Can you add polynomial terms to multiple linear regression?

Make 1998 using the least possible digits 8

Will the UK home office know about 5 previous visa rejections in other countries?

Why don't Wizards use wrist straps to protect against disarming charms?

Sort files in a given folders and provide as a list

How major are these paintwork & rust problems?

getting syntax error in simple bash script

Were Roman public roads build by private companies?

Can I conceal an antihero's insanity - and should I?

What is my breathable atmosphere composed of?

What officially disallows US presidents from driving?

Is low emotional intelligence associated with right-wing and prejudiced attitudes?

How are aircraft depainted?

What is the mathematical notation for rounding a given number to the nearest integer?

What organs or modifications would be needed for a life biological creature not to require sleep?

In Germany, how can I maximize the impact of my charitable donations?

What exactly is a marshrutka (маршрутка)?

2000s space film where an alien species has almost wiped out the human race in a war

Bash, import output from command as command

What is and what isn't ullage in rocket science?



XSD targetNamespace does not override element namespace?


What does elementFormDefault do in XSD?How to reference element in other XSD's namespace?What is this XSD import namespace for?XML + Schema + Namespaces. No matching global declaration available for the validation rootWhere is the XSD file for “http://www.w3.org/2001/XMLSchema-instance”?Intellij IDEA : How to validate XML SCHEMA 1Parsing XSD Schema with XSOM in Java. How to access attributes in another namespaceXMLSchema and XMLSchema-instance namespaces without schemaLocationError: The namespace of element schema must be from schema namespace http://www.w3.org/2001/XMLSchemaXSD error: References from this schema to components in no namespace are not allowedHow to use XSD 1.1 in Netbeans 8.2?How does an XML Validator know where to find the schema instance declared in an xml document in order to parse and use the xsd?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I have an XSD that defines an complex type and has the targetNamespace attribute set. Is it correct that the TestElement will not gain the namespace set by targetNamespace? It should gain the namespace from the complex type afn:ElementType and therefore http://anotherfancy.namespace, right?



 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:sfn="http://somefancy.namespace"
xmlns:afn="http://anotherfancy.namespace"
attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://somefancy.namespace"
version="1.0">
<xs:import namespace="http://anotherfancy.namespace" schemaLocation="..."/>
<xs:element name="MyComplexType">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="TestElement" type="afn:ElementType">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>









share|improve this question
































    1















    I have an XSD that defines an complex type and has the targetNamespace attribute set. Is it correct that the TestElement will not gain the namespace set by targetNamespace? It should gain the namespace from the complex type afn:ElementType and therefore http://anotherfancy.namespace, right?



     <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:sfn="http://somefancy.namespace"
    xmlns:afn="http://anotherfancy.namespace"
    attributeFormDefault="unqualified"
    elementFormDefault="qualified"
    targetNamespace="http://somefancy.namespace"
    version="1.0">
    <xs:import namespace="http://anotherfancy.namespace" schemaLocation="..."/>
    <xs:element name="MyComplexType">
    <xs:complexType>
    <xs:sequence>
    <xs:element minOccurs="0" name="TestElement" type="afn:ElementType">
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>









    share|improve this question




























      1












      1








      1








      I have an XSD that defines an complex type and has the targetNamespace attribute set. Is it correct that the TestElement will not gain the namespace set by targetNamespace? It should gain the namespace from the complex type afn:ElementType and therefore http://anotherfancy.namespace, right?



       <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:sfn="http://somefancy.namespace"
      xmlns:afn="http://anotherfancy.namespace"
      attributeFormDefault="unqualified"
      elementFormDefault="qualified"
      targetNamespace="http://somefancy.namespace"
      version="1.0">
      <xs:import namespace="http://anotherfancy.namespace" schemaLocation="..."/>
      <xs:element name="MyComplexType">
      <xs:complexType>
      <xs:sequence>
      <xs:element minOccurs="0" name="TestElement" type="afn:ElementType">
      </xs:element>
      </xs:sequence>
      </xs:complexType>
      </xs:element>
      </xs:schema>









      share|improve this question
















      I have an XSD that defines an complex type and has the targetNamespace attribute set. Is it correct that the TestElement will not gain the namespace set by targetNamespace? It should gain the namespace from the complex type afn:ElementType and therefore http://anotherfancy.namespace, right?



       <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:sfn="http://somefancy.namespace"
      xmlns:afn="http://anotherfancy.namespace"
      attributeFormDefault="unqualified"
      elementFormDefault="qualified"
      targetNamespace="http://somefancy.namespace"
      version="1.0">
      <xs:import namespace="http://anotherfancy.namespace" schemaLocation="..."/>
      <xs:element name="MyComplexType">
      <xs:complexType>
      <xs:sequence>
      <xs:element minOccurs="0" name="TestElement" type="afn:ElementType">
      </xs:element>
      </xs:sequence>
      </xs:complexType>
      </xs:element>
      </xs:schema>






      xml xsd xsd-validation xml-validation






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 12:58









      kjhughes

      71.7k14 gold badges104 silver badges148 bronze badges




      71.7k14 gold badges104 silver badges148 bronze badges










      asked Mar 28 at 10:25









      Jens MarchewkaJens Marchewka

      9031 gold badge8 silver badges22 bronze badges




      9031 gold badge8 silver badges22 bronze badges

























          2 Answers
          2






          active

          oldest

          votes


















          1
















          When xs:schema/elementFormDefault="qualified"



          (As in your case, which is also the recommended and most commonly used setting of elementFormDefault.)



          The elements declared within an XSD must be in the namespace given by the XSD's targetNamespace.



          Therefore, for your XSD, TestElement will have to be in the http://somefancy.namespace for the XML document to be valid. If you instead want it to be in the http://anotherfancy.namespace, declare the element in the imported XSD; storing its type there will not place the element itself in that other namespace. Once TestElement is declared in the imported namespace, it can be used in the original namespace via xs:element/@ref.



          See also How to reference element in other XSD's namespace?



          For rarely needed, and generally not recommended, other variations



          See Michael Kay's answer here and my longer answer to this question: What does elementFormDefault do in XSD?






          share|improve this answer



























          • This isn't the full story; it ignores the difference between local and global element declarations, and the impact of form and elementFormDefault.

            – Michael Kay
            Mar 28 at 13:19











          • @MichaelKay: True, I should have elaborated, or at least mentioned, elementFormDefault et al considerations. Answer updated. Thank you.

            – kjhughes
            Mar 28 at 13:41



















          1
















          The namespace of an element declared in a local element declaration is given in the following rule (XSD 1.1 part 1 §3.3.2.3)



          target namespace

          The appropriate case among the following:
          1 If targetNamespace is present [as an attribute of the xs:element element], then its ·actual value·.
          2 If targetNamespace is not present and one of the following is true
          2.1 form = qualified
          2.2 form is absent and the <schema> ancestor has elementFormDefault = qualified
          then the ·actual value· of the targetNamespace [attribute] of the ancestor <schema> element information item, or ·absent· if there is none.
          3 otherwise ·absent·.


          The targetNamespace attribute of xs:element is new in 1.1, so for 1.0 you can ignore rule 1.



          The form attribute of xs:element is very rarely used, but if the value is qualified then the element goes in the targetNamespace declared on the containing xs:schema, while if it is unqualified then it goes in no namespace. If form is not specified (which is nearly always the case), then it defaults to the value of elementFormDefault on the xs:schema element. This is usually set to qualified, so the element goes in the target namespace of the schema; but the default (unfortunately) is unqualified which means it goes in no namespace.






          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',
            autoActivateHeartbeat: false,
            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/4.0/"u003ecc by-sa 4.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%2f55395269%2fxsd-targetnamespace-does-not-override-element-namespace%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1
















            When xs:schema/elementFormDefault="qualified"



            (As in your case, which is also the recommended and most commonly used setting of elementFormDefault.)



            The elements declared within an XSD must be in the namespace given by the XSD's targetNamespace.



            Therefore, for your XSD, TestElement will have to be in the http://somefancy.namespace for the XML document to be valid. If you instead want it to be in the http://anotherfancy.namespace, declare the element in the imported XSD; storing its type there will not place the element itself in that other namespace. Once TestElement is declared in the imported namespace, it can be used in the original namespace via xs:element/@ref.



            See also How to reference element in other XSD's namespace?



            For rarely needed, and generally not recommended, other variations



            See Michael Kay's answer here and my longer answer to this question: What does elementFormDefault do in XSD?






            share|improve this answer



























            • This isn't the full story; it ignores the difference between local and global element declarations, and the impact of form and elementFormDefault.

              – Michael Kay
              Mar 28 at 13:19











            • @MichaelKay: True, I should have elaborated, or at least mentioned, elementFormDefault et al considerations. Answer updated. Thank you.

              – kjhughes
              Mar 28 at 13:41
















            1
















            When xs:schema/elementFormDefault="qualified"



            (As in your case, which is also the recommended and most commonly used setting of elementFormDefault.)



            The elements declared within an XSD must be in the namespace given by the XSD's targetNamespace.



            Therefore, for your XSD, TestElement will have to be in the http://somefancy.namespace for the XML document to be valid. If you instead want it to be in the http://anotherfancy.namespace, declare the element in the imported XSD; storing its type there will not place the element itself in that other namespace. Once TestElement is declared in the imported namespace, it can be used in the original namespace via xs:element/@ref.



            See also How to reference element in other XSD's namespace?



            For rarely needed, and generally not recommended, other variations



            See Michael Kay's answer here and my longer answer to this question: What does elementFormDefault do in XSD?






            share|improve this answer



























            • This isn't the full story; it ignores the difference between local and global element declarations, and the impact of form and elementFormDefault.

              – Michael Kay
              Mar 28 at 13:19











            • @MichaelKay: True, I should have elaborated, or at least mentioned, elementFormDefault et al considerations. Answer updated. Thank you.

              – kjhughes
              Mar 28 at 13:41














            1














            1










            1









            When xs:schema/elementFormDefault="qualified"



            (As in your case, which is also the recommended and most commonly used setting of elementFormDefault.)



            The elements declared within an XSD must be in the namespace given by the XSD's targetNamespace.



            Therefore, for your XSD, TestElement will have to be in the http://somefancy.namespace for the XML document to be valid. If you instead want it to be in the http://anotherfancy.namespace, declare the element in the imported XSD; storing its type there will not place the element itself in that other namespace. Once TestElement is declared in the imported namespace, it can be used in the original namespace via xs:element/@ref.



            See also How to reference element in other XSD's namespace?



            For rarely needed, and generally not recommended, other variations



            See Michael Kay's answer here and my longer answer to this question: What does elementFormDefault do in XSD?






            share|improve this answer















            When xs:schema/elementFormDefault="qualified"



            (As in your case, which is also the recommended and most commonly used setting of elementFormDefault.)



            The elements declared within an XSD must be in the namespace given by the XSD's targetNamespace.



            Therefore, for your XSD, TestElement will have to be in the http://somefancy.namespace for the XML document to be valid. If you instead want it to be in the http://anotherfancy.namespace, declare the element in the imported XSD; storing its type there will not place the element itself in that other namespace. Once TestElement is declared in the imported namespace, it can be used in the original namespace via xs:element/@ref.



            See also How to reference element in other XSD's namespace?



            For rarely needed, and generally not recommended, other variations



            See Michael Kay's answer here and my longer answer to this question: What does elementFormDefault do in XSD?







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Mar 28 at 13:49

























            answered Mar 28 at 13:04









            kjhugheskjhughes

            71.7k14 gold badges104 silver badges148 bronze badges




            71.7k14 gold badges104 silver badges148 bronze badges















            • This isn't the full story; it ignores the difference between local and global element declarations, and the impact of form and elementFormDefault.

              – Michael Kay
              Mar 28 at 13:19











            • @MichaelKay: True, I should have elaborated, or at least mentioned, elementFormDefault et al considerations. Answer updated. Thank you.

              – kjhughes
              Mar 28 at 13:41


















            • This isn't the full story; it ignores the difference between local and global element declarations, and the impact of form and elementFormDefault.

              – Michael Kay
              Mar 28 at 13:19











            • @MichaelKay: True, I should have elaborated, or at least mentioned, elementFormDefault et al considerations. Answer updated. Thank you.

              – kjhughes
              Mar 28 at 13:41

















            This isn't the full story; it ignores the difference between local and global element declarations, and the impact of form and elementFormDefault.

            – Michael Kay
            Mar 28 at 13:19





            This isn't the full story; it ignores the difference between local and global element declarations, and the impact of form and elementFormDefault.

            – Michael Kay
            Mar 28 at 13:19













            @MichaelKay: True, I should have elaborated, or at least mentioned, elementFormDefault et al considerations. Answer updated. Thank you.

            – kjhughes
            Mar 28 at 13:41






            @MichaelKay: True, I should have elaborated, or at least mentioned, elementFormDefault et al considerations. Answer updated. Thank you.

            – kjhughes
            Mar 28 at 13:41














            1
















            The namespace of an element declared in a local element declaration is given in the following rule (XSD 1.1 part 1 §3.3.2.3)



            target namespace

            The appropriate case among the following:
            1 If targetNamespace is present [as an attribute of the xs:element element], then its ·actual value·.
            2 If targetNamespace is not present and one of the following is true
            2.1 form = qualified
            2.2 form is absent and the <schema> ancestor has elementFormDefault = qualified
            then the ·actual value· of the targetNamespace [attribute] of the ancestor <schema> element information item, or ·absent· if there is none.
            3 otherwise ·absent·.


            The targetNamespace attribute of xs:element is new in 1.1, so for 1.0 you can ignore rule 1.



            The form attribute of xs:element is very rarely used, but if the value is qualified then the element goes in the targetNamespace declared on the containing xs:schema, while if it is unqualified then it goes in no namespace. If form is not specified (which is nearly always the case), then it defaults to the value of elementFormDefault on the xs:schema element. This is usually set to qualified, so the element goes in the target namespace of the schema; but the default (unfortunately) is unqualified which means it goes in no namespace.






            share|improve this answer





























              1
















              The namespace of an element declared in a local element declaration is given in the following rule (XSD 1.1 part 1 §3.3.2.3)



              target namespace

              The appropriate case among the following:
              1 If targetNamespace is present [as an attribute of the xs:element element], then its ·actual value·.
              2 If targetNamespace is not present and one of the following is true
              2.1 form = qualified
              2.2 form is absent and the <schema> ancestor has elementFormDefault = qualified
              then the ·actual value· of the targetNamespace [attribute] of the ancestor <schema> element information item, or ·absent· if there is none.
              3 otherwise ·absent·.


              The targetNamespace attribute of xs:element is new in 1.1, so for 1.0 you can ignore rule 1.



              The form attribute of xs:element is very rarely used, but if the value is qualified then the element goes in the targetNamespace declared on the containing xs:schema, while if it is unqualified then it goes in no namespace. If form is not specified (which is nearly always the case), then it defaults to the value of elementFormDefault on the xs:schema element. This is usually set to qualified, so the element goes in the target namespace of the schema; but the default (unfortunately) is unqualified which means it goes in no namespace.






              share|improve this answer



























                1














                1










                1









                The namespace of an element declared in a local element declaration is given in the following rule (XSD 1.1 part 1 §3.3.2.3)



                target namespace

                The appropriate case among the following:
                1 If targetNamespace is present [as an attribute of the xs:element element], then its ·actual value·.
                2 If targetNamespace is not present and one of the following is true
                2.1 form = qualified
                2.2 form is absent and the <schema> ancestor has elementFormDefault = qualified
                then the ·actual value· of the targetNamespace [attribute] of the ancestor <schema> element information item, or ·absent· if there is none.
                3 otherwise ·absent·.


                The targetNamespace attribute of xs:element is new in 1.1, so for 1.0 you can ignore rule 1.



                The form attribute of xs:element is very rarely used, but if the value is qualified then the element goes in the targetNamespace declared on the containing xs:schema, while if it is unqualified then it goes in no namespace. If form is not specified (which is nearly always the case), then it defaults to the value of elementFormDefault on the xs:schema element. This is usually set to qualified, so the element goes in the target namespace of the schema; but the default (unfortunately) is unqualified which means it goes in no namespace.






                share|improve this answer













                The namespace of an element declared in a local element declaration is given in the following rule (XSD 1.1 part 1 §3.3.2.3)



                target namespace

                The appropriate case among the following:
                1 If targetNamespace is present [as an attribute of the xs:element element], then its ·actual value·.
                2 If targetNamespace is not present and one of the following is true
                2.1 form = qualified
                2.2 form is absent and the <schema> ancestor has elementFormDefault = qualified
                then the ·actual value· of the targetNamespace [attribute] of the ancestor <schema> element information item, or ·absent· if there is none.
                3 otherwise ·absent·.


                The targetNamespace attribute of xs:element is new in 1.1, so for 1.0 you can ignore rule 1.



                The form attribute of xs:element is very rarely used, but if the value is qualified then the element goes in the targetNamespace declared on the containing xs:schema, while if it is unqualified then it goes in no namespace. If form is not specified (which is nearly always the case), then it defaults to the value of elementFormDefault on the xs:schema element. This is usually set to qualified, so the element goes in the target namespace of the schema; but the default (unfortunately) is unqualified which means it goes in no namespace.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 28 at 13:17









                Michael KayMichael Kay

                117k6 gold badges65 silver badges126 bronze badges




                117k6 gold badges65 silver badges126 bronze badges































                    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.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55395269%2fxsd-targetnamespace-does-not-override-element-namespace%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

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript