Thank you for the response W dniu poniedziałek, 9 maja 2011, 19:17:40 UTC+2 użytkownik Christophe COEVOET napisał: > > Le 09/05/2011 18:13, Alan Gabriel Bem a écrit : > The namespace is used to identify the configuration used by this extension. > This is mandatory to be able to use an XML config file. > The XSD is not mandatory. You just don't have the XSD validation if it is > not provided. > > Requiring to have an XSD would mean that each bundle developer providing a > semantic configuration would have to provide an XSD file. But this requires > knowing the XSD syntax and writing it for XML users whereas using > validations rules in a Configuration class is more powerful: it works also > for YAML config, it validates the merged configuration (a required key is > not required in *all* files but in the merged config). XSD validation is > definetly not the better solution when merging some configuration files. >
I didn't write anything about requiring XSD. Maybe I was unclear - sorry about that. What I meant is that XML Schema validation proceed somewhat magically and it occures only when schemaLocation is defined for validated namespace. Here's sample: # config1.xml <?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" > <framework:config secret="%secret%" charset="%kernel.charset%"> <framework:csrf-protection enabled="true" /> <framework:router resource="%kernel.root_dir%/config/routing.xml" /> <framework:validation enabled="true" annotations="true" /> <framework:templating> <framework:engine>twig</framework:engine> </framework:templating> <framework:session default-locale="%locale%" lifetime="3600" auto-start="true" /> </framework:config> </container> # config2.xml <?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/symfonyhttp://symfony.com/schema/dic/symfony/symfony-1.0.xsd" > <framework:config secret="%secret%" charset="%kernel.charset%"> <framework:csrf-protection enabled="true" /> <framework:router resource="%kernel.root_dir%/config/routing.xml" /> <framework:validation enabled="true" annotations="true" /> <framework:templating> <framework:engine>twig</framework:engine> </framework:templating> <framework:session default-locale="%locale%" lifetime="3600" auto-start="true" /> </framework:config> </container> framework namespace in config2.xml won't be validated againstFrameworkBundles' xsd file (symfony-1.0.xsd), on the other hand in config1.xml it will be. Why? Because XmlConfigLoader takes http://symfony.com/schema/dic/symfony/symfony-1.0.xsd from schemaLocationsattribute and translates to local xsd filepath. Which is odd for me. Extensions can provide this path on their own. Why would it be done in the loader ? > Because *only* XmlConfigLoader lookup extensions by their namespaces. *Only *there you can see something like that: $this->container->getExtension('http://symfony.com/schema/dic/symfony'); The loader is about loading a config file, not about handling DI extensions. > Yes, but container and its extensions are not about xml configuration... yet, namespace lookup in ContainerBuilder and Extension::getNamespace() exist. > > Thus, the loader does not call the extension directly. it adds the > configuration values in the ContainerBuilder which will then call the > extensions with *all* configurations values. > Only difference here and for instance in YmlConfigLoader is that XmlConfigLoader uses namespace URI instead of alias while performing those actions. > Moving it to an XmlFileLoader would mean that you cannot import a YAML file > from an XML file or the opposite. > I'm sorry, but you are mistaken here. -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/symfony-devs?hl=en
