Magento 2 custom xml schema validation












8















This is a follow up of Magento 2 xml validation:

I understood how to map xsi:noNamespaceSchemaLocation in my IDE so I will get real time validation of my xmls.

But what if I have to create my own config file with it's own validation schema?

What value should I put for xsi:noNamespaceSchemaLocation ?



Right now I have this in class.xml:



<?xml version="1.0"?>
<classes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="class.xsd">
....
</classes>


This works nicely, because class.xsd is in the same folder as my class.xml.

But I plan to make my module extensible and actually composed from multiple modules.

Now I use in the additional modules a relative path to the class.xsd file and this seams a bit wrong.



<?xml version="1.0"?>
<classes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Base/etc/umc/class.xsd">
....
</classes>


Obviously I cannot use urn:magento:framework... because my module is not in the framework, and I also cannot use urn:magento:module... because mine is not a core module. Or can I use the latter?

Or should I use a custom urn?

And (last one) if I use a custom urn will this be picked up automatically by the command bin/magento dev:urn-catalog:generate or should I dos something special?










share|improve this question





























    8















    This is a follow up of Magento 2 xml validation:

    I understood how to map xsi:noNamespaceSchemaLocation in my IDE so I will get real time validation of my xmls.

    But what if I have to create my own config file with it's own validation schema?

    What value should I put for xsi:noNamespaceSchemaLocation ?



    Right now I have this in class.xml:



    <?xml version="1.0"?>
    <classes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="class.xsd">
    ....
    </classes>


    This works nicely, because class.xsd is in the same folder as my class.xml.

    But I plan to make my module extensible and actually composed from multiple modules.

    Now I use in the additional modules a relative path to the class.xsd file and this seams a bit wrong.



    <?xml version="1.0"?>
    <classes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Base/etc/umc/class.xsd">
    ....
    </classes>


    Obviously I cannot use urn:magento:framework... because my module is not in the framework, and I also cannot use urn:magento:module... because mine is not a core module. Or can I use the latter?

    Or should I use a custom urn?

    And (last one) if I use a custom urn will this be picked up automatically by the command bin/magento dev:urn-catalog:generate or should I dos something special?










    share|improve this question



























      8












      8








      8


      3






      This is a follow up of Magento 2 xml validation:

      I understood how to map xsi:noNamespaceSchemaLocation in my IDE so I will get real time validation of my xmls.

      But what if I have to create my own config file with it's own validation schema?

      What value should I put for xsi:noNamespaceSchemaLocation ?



      Right now I have this in class.xml:



      <?xml version="1.0"?>
      <classes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="class.xsd">
      ....
      </classes>


      This works nicely, because class.xsd is in the same folder as my class.xml.

      But I plan to make my module extensible and actually composed from multiple modules.

      Now I use in the additional modules a relative path to the class.xsd file and this seams a bit wrong.



      <?xml version="1.0"?>
      <classes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Base/etc/umc/class.xsd">
      ....
      </classes>


      Obviously I cannot use urn:magento:framework... because my module is not in the framework, and I also cannot use urn:magento:module... because mine is not a core module. Or can I use the latter?

      Or should I use a custom urn?

      And (last one) if I use a custom urn will this be picked up automatically by the command bin/magento dev:urn-catalog:generate or should I dos something special?










      share|improve this question
















      This is a follow up of Magento 2 xml validation:

      I understood how to map xsi:noNamespaceSchemaLocation in my IDE so I will get real time validation of my xmls.

      But what if I have to create my own config file with it's own validation schema?

      What value should I put for xsi:noNamespaceSchemaLocation ?



      Right now I have this in class.xml:



      <?xml version="1.0"?>
      <classes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="class.xsd">
      ....
      </classes>


      This works nicely, because class.xsd is in the same folder as my class.xml.

      But I plan to make my module extensible and actually composed from multiple modules.

      Now I use in the additional modules a relative path to the class.xsd file and this seams a bit wrong.



      <?xml version="1.0"?>
      <classes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Base/etc/umc/class.xsd">
      ....
      </classes>


      Obviously I cannot use urn:magento:framework... because my module is not in the framework, and I also cannot use urn:magento:module... because mine is not a core module. Or can I use the latter?

      Or should I use a custom urn?

      And (last one) if I use a custom urn will this be picked up automatically by the command bin/magento dev:urn-catalog:generate or should I dos something special?







      magento2 xml validation






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 4 mins ago







      Marius

















      asked Nov 10 '15 at 15:02









      MariusMarius

      164k28312663




      164k28312663






















          1 Answer
          1






          active

          oldest

          votes


















          8














          It should be urn:magento:module:<Vendor_Module>:<path>
          The command will work since it filters out urns that begin with urn:magento
          https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Developer/Console/Command/XmlCatalogGenerateCommand.php#L118






          share|improve this answer

























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "479"
            };
            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: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            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%2fmagento.stackexchange.com%2fquestions%2f89609%2fmagento-2-custom-xml-schema-validation%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









            8














            It should be urn:magento:module:<Vendor_Module>:<path>
            The command will work since it filters out urns that begin with urn:magento
            https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Developer/Console/Command/XmlCatalogGenerateCommand.php#L118






            share|improve this answer






























              8














              It should be urn:magento:module:<Vendor_Module>:<path>
              The command will work since it filters out urns that begin with urn:magento
              https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Developer/Console/Command/XmlCatalogGenerateCommand.php#L118






              share|improve this answer




























                8












                8








                8







                It should be urn:magento:module:<Vendor_Module>:<path>
                The command will work since it filters out urns that begin with urn:magento
                https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Developer/Console/Command/XmlCatalogGenerateCommand.php#L118






                share|improve this answer















                It should be urn:magento:module:<Vendor_Module>:<path>
                The command will work since it filters out urns that begin with urn:magento
                https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Developer/Console/Command/XmlCatalogGenerateCommand.php#L118







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited May 8 '18 at 16:11









                Ottnorml

                32




                32










                answered Nov 10 '15 at 15:17









                MaddyMaddy

                1,122613




                1,122613






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • 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%2fmagento.stackexchange.com%2fquestions%2f89609%2fmagento-2-custom-xml-schema-validation%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

                    Magento 2 controller redirect on button click in phtml file

                    Polycentropodidae