Magento 2 custom xml schema validation
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
add a comment |
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
add a comment |
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
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
magento2 xml validation
edited 4 mins ago
Marius
asked Nov 10 '15 at 15:02
Marius♦Marius
164k28312663
164k28312663
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
add a comment |
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
add a comment |
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
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
edited May 8 '18 at 16:11
Ottnorml
32
32
answered Nov 10 '15 at 15:17
MaddyMaddy
1,122613
1,122613
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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