Changeset 2641
- Timestamp:
- 08/01/08 13:06:36 (5 months ago)
- Location:
- branches/david-xml_only_config_system/src/config
- Files:
-
- 10 modified
-
AgaviConfigCache.class.php (modified) (1 diff)
-
AgaviConfigParser.class.php (modified) (2 diffs)
-
AgaviFactoryConfigHandler.class.php (modified) (1 diff)
-
AgaviXmlConfigParser.class.php (modified) (11 diffs)
-
rng/_common.rng (modified) (4 diffs)
-
rng/factories.rng (modified) (1 diff)
-
util/dom/AgaviXmlConfigDomDocument.class.php (modified) (2 diffs)
-
util/dom/AgaviXmlConfigDomElement.class.php (modified) (2 diffs)
-
xsl/_common.xsl (modified) (1 diff)
-
xsl/factories.xsl (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/david-xml_only_config_system/src/config/AgaviConfigCache.class.php
r2634 r2641 112 112 $data = $handler->execute($doc); 113 113 } catch(AgaviException $e) { 114 throw new $e(sprintf("Comp liation of configuration file '%s' failed for the following reason(s):\n\n%s", $config, $e->getMessage()));114 throw new $e(sprintf("Compilation of configuration file '%s' failed for the following reason(s):\n\n%s", $config, $e->getMessage())); 115 115 } 116 116 } else { -
branches/david-xml_only_config_system/src/config/AgaviConfigParser.class.php
r2632 r2641 84 84 { 85 85 foreach($nodes as $node) { 86 if($node->nodeType == XML_ELEMENT_NODE && (!$node->namespaceURI || $node->namespaceURI == AgaviXmlConfigParser:: AGAVI_ENVELOPE_NAMESPACE_0_11)) {86 if($node->nodeType == XML_ELEMENT_NODE && (!$node->namespaceURI || $node->namespaceURI == AgaviXmlConfigParser::NAMESPACE_AGAVI_ENVELOPE_0_11)) { 87 87 $vh = new AgaviConfigValueHolder(); 88 88 $nodeName = $this->convertEncoding($node->localName); … … 91 91 92 92 foreach($node->attributes as $attribute) { 93 if((!$attribute->namespaceURI || $attribute->namespaceURI == AgaviXmlConfigParser:: AGAVI_ENVELOPE_NAMESPACE_0_11)) {93 if((!$attribute->namespaceURI || $attribute->namespaceURI == AgaviXmlConfigParser::NAMESPACE_AGAVI_ENVELOPE_0_11)) { 94 94 $vh->setAttribute($this->convertEncoding($attribute->localName), $this->convertEncoding($attribute->nodeValue)); 95 95 } -
branches/david-xml_only_config_system/src/config/AgaviFactoryConfigHandler.class.php
r2633 r2641 33 33 class AgaviFactoryConfigHandler extends AgaviXmlConfigHandler 34 34 { 35 const NAMESPACE = 'http://agavi.org/agavi/config/ factories/1.0';35 const NAMESPACE = 'http://agavi.org/agavi/config/item/factories/1.0'; 36 36 37 37 /** -
branches/david-xml_only_config_system/src/config/AgaviXmlConfigParser.class.php
r2634 r2641 32 32 class AgaviXmlConfigParser 33 33 { 34 const AGAVI_ENVELOPE_NAMESPACE_0_11 = 'http://agavi.org/agavi/1.0/config'; 35 36 const AGAVI_ENVELOPE_NAMESPACE_1_0 = 'http://agavi.org/agavi/config/1.0'; 37 38 const AGAVI_ENVELOPE_NAMESPACE_LATEST = self::AGAVI_ENVELOPE_NAMESPACE_1_0; 34 const NAMESPACE_AGAVI_ENVELOPE_0_11 = 'http://agavi.org/agavi/1.0/config'; 35 36 const NAMESPACE_AGAVI_ENVELOPE_1_0 = 'http://agavi.org/agavi/config/envelope/1.0'; 37 38 const NAMESPACE_AGAVI_ENVELOPE_LATEST = self::NAMESPACE_AGAVI_ENVELOPE_1_0; 39 40 const NAMESPACE_AGAVI_ANNOTATION_1_0 = 'http://agavi.org/agavi/config/annotation/1.0'; 41 42 const NAMESPACE_AGAVI_ANNOTATION_LATEST = self::NAMESPACE_AGAVI_ANNOTATION_1_0; 39 43 40 44 const VALIDATION_TYPE_XMLSCHEMA = 'xml_schema'; … … 44 48 const VALIDATION_TYPE_SCHEMATRON = 'schematron'; 45 49 46 const SCHEMATRON_ISO_NAMESPACE= 'http://purl.oclc.org/dsdl/schematron';47 48 const SVRL_ISO_NAMESPACE= 'http://purl.oclc.org/dsdl/svrl';49 50 const XSL_NAMESPACE_1999 = 'http://www.w3.org/1999/XSL/Transform';50 const NAMESPACE_SCHEMATRON_ISO = 'http://purl.oclc.org/dsdl/schematron'; 51 52 const NAMESPACE_SVRL_ISO = 'http://purl.oclc.org/dsdl/svrl'; 53 54 const NAMESPACE_XSL_1999 = 'http://www.w3.org/1999/XSL/Transform'; 51 55 52 56 /** … … 55 59 */ 56 60 public static $agaviEnvelopeNamespaces = array( 57 self:: AGAVI_ENVELOPE_NAMESPACE_0_11 => 'agavi_envelope_0_11',58 self:: AGAVI_ENVELOPE_NAMESPACE_1_0 => 'agavi_envelope_1_0',61 self::NAMESPACE_AGAVI_ENVELOPE_0_11 => 'agavi_envelope_0_11', 62 self::NAMESPACE_AGAVI_ENVELOPE_1_0 => 'agavi_envelope_1_0', 59 63 ); 60 64 61 65 /** 66 * @var array A list of all XML namespaces that are used internally by 67 * the configuration parser. 68 */ 69 public static $agaviNamespaces = array( 70 self::NAMESPACE_AGAVI_ENVELOPE_0_11 => 'agavi_envelope_0_11', 71 self::NAMESPACE_AGAVI_ENVELOPE_1_0 => 'agavi_envelope_1_0', 72 73 self::NAMESPACE_AGAVI_ANNOTATION_1_0 => 'agavi_annotation_1_0' 74 ); 75 76 /** 62 77 * @var string Path to the config file we're parsing in this instance. 63 78 */ … … 107 122 { 108 123 return isset(self::$agaviEnvelopeNamespaces[$namespaceUri]); 124 } 125 126 /** 127 * Check if a given namespace URI is a valid Agavi namespace. 128 * 129 * @param string The namespace URI. 130 * 131 * @return bool True if the given URI is a valid namespace URI, 132 * false otherwise. 133 * 134 * @author Noah Fontes <noah.fontes@bitextender.com> 135 * @since 1.0.0 136 */ 137 public static function isAgaviNamespace($namespaceUri) 138 { 139 return isset(self::$agaviNamespaces[$namespaceUri]); 109 140 } 110 141 … … 120 151 * @since 1.0.0 121 152 */ 122 public static function getAgavi EnvelopePrefix($namespaceUri)123 { 124 if(self::isAgavi EnvelopeNamespace($namespaceUri)) {125 return self::$agavi EnvelopeNamespaces[$namespaceUri];153 public static function getAgaviNamespacePrefix($namespaceUri) 154 { 155 if(self::isAgaviNamespace($namespaceUri)) { 156 return self::$agaviNamespaces[$namespaceUri]; 126 157 } 127 158 return null; 159 } 160 161 /** 162 * Register Agavi namespace prefixes in a given document. 163 * 164 * @param AgaviXmlConfigDomDocument The document. 165 * 166 * @author Noah Fontes <noah.fontes@bitextender.com> 167 * @since 1.0.0 168 */ 169 public static function registerAgaviNamespaces(AgaviXmlConfigDomDocument $document) 170 { 171 $xpath = $document->getXpath(); 172 173 foreach(self::$agaviNamespaces as $namespaceUri => $prefix) { 174 $xpath->registerNamespace($prefix, $namespaceUri); 175 } 176 177 /* Register the latest namespaces. */ 178 $xpath->registerNamespace('agavi_envelope_latest', self::NAMESPACE_AGAVI_ENVELOPE_LATEST); 179 $xpath->registerNamespace('agavi_annotation_latest', self::NAMESPACE_AGAVI_ANNOTATION_LATEST); 128 180 } 129 181 … … 176 228 if($isAgaviConfigFormat) { 177 229 // if it is an Agavi config, we'll create a new document with all files' <configuration> blocks inside 178 $retval->appendChild(new AgaviXmlConfigDomElement('configurations', null, self:: AGAVI_ENVELOPE_NAMESPACE_LATEST));230 $retval->appendChild(new AgaviXmlConfigDomElement('configurations', null, self::NAMESPACE_AGAVI_ENVELOPE_LATEST)); 179 231 180 232 // reverse the array - we want the parents first! … … 201 253 // generic <configuration> first, then those with an environment attribute, then those with context, then those with both 202 254 $configurationOrder = array( 203 'count(self::node()[@agavi_ envelope_1_0:matched and not(@environment) and not(@context)])',204 'count(self::node()[@agavi_ envelope_1_0:matched and @environment and not(@context)])',205 'count(self::node()[@agavi_ envelope_1_0:matched and not(@environment) and @context])',206 'count(self::node()[@agavi_ envelope_1_0:matched and @environment and @context])',255 'count(self::node()[@agavi_annotation_latest:matched and not(@environment) and not(@context)])', 256 'count(self::node()[@agavi_annotation_latest:matched and @environment and not(@context)])', 257 'count(self::node()[@agavi_annotation_latest:matched and not(@environment) and @context])', 258 'count(self::node()[@agavi_annotation_latest:matched and @environment and @context])', 207 259 ); 208 260 … … 424 476 if($matched) { 425 477 // if all was fine, we set the attribute. the element will then be kept in the merged result doc later 426 $configuration->setAttributeNS(self:: AGAVI_ENVELOPE_NAMESPACE_LATEST, 'agavi:matched', 'true');478 $configuration->setAttributeNS(self::NAMESPACE_AGAVI_ANNOTATION_LATEST, 'agavi_annotation_latest:matched', 'true'); 427 479 } 428 480 } … … 697 749 698 750 // is it an ISO Schematron file? 699 if(!$sch->documentElement || $sch->documentElement->namespaceURI != self:: SCHEMATRON_ISO_NAMESPACE) {751 if(!$sch->documentElement || $sch->documentElement->namespaceURI != self::NAMESPACE_SCHEMATRON_ISO) { 700 752 throw new AgaviParseException(sprintf('Schematron validation of configuration file "%s" failed because schema file "%s" is invalid', $this->path, $href)); 701 753 } … … 709 761 710 762 // it transformed fine. but did we get a proper stylesheet instance at all? wrong namespaces can lead to empty docs that only have an XML prolog 711 if(!$schema->documentElement || $schema->documentElement->namespaceURI != self:: XSL_NAMESPACE_1999) {763 if(!$schema->documentElement || $schema->documentElement->namespaceURI != self::NAMESPACE_XSL_1999) { 712 764 throw new AgaviParseException(sprintf('Schematron validation of configuration file "%s" failed because schema file "%s" resulted in an invalid stylesheet', $this->path, $href)); 713 765 } … … 730 782 // validation ran okay, now we need to look at the result document to see if there are errors 731 783 $xpath = $result->getXpath(); 732 $xpath->registerNamespace('svrl', self:: SVRL_ISO_NAMESPACE);784 $xpath->registerNamespace('svrl', self::NAMESPACE_SVRL_ISO); 733 785 734 786 $results = $xpath->query('//svrl:failed-assert | //svrl:successful-report'); -
branches/david-xml_only_config_system/src/config/rng/_common.rng
r2632 r2641 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <grammar xmlns="http://relaxng.org/ns/structure/1.0" 3 xmlns:agavi="http://agavi.org/agavi/config/1.0" 4 ns="http://agavi.org/agavi/config/1.0" 3 xmlns:envelope_1_0="http://agavi.org/agavi/config/envelope/1.0" 4 xmlns:annotation_1_0="http://agavi.org/agavi/config/annotation/1.0" 5 ns="http://agavi.org/agavi/config/envelope/1.0" 5 6 datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> 6 7 … … 43 44 <!-- XXX: Here, or no? --> 44 45 <optional> 45 <attribute name="a gavi:matched">46 <attribute name="annotation_1_0:matched"> 46 47 <ref name="data-matched" /> 47 48 </attribute> … … 149 150 <nsName /> 150 151 <nsName ns="" /> 151 <nsName ns="http://agavi.org/agavi/config/1.0" /> 152 <nsName ns="http://agavi.org/agavi/config/envelope/1.0" /> 153 <nsName ns="http://agavi.org/agavi/config/annotation/1.0" /> 152 154 </except> 153 155 </anyName> … … 164 166 <nsName /> 165 167 <nsName ns="" /> 166 <nsName ns="http://agavi.org/agavi/config/1.0" /> 168 <nsName ns="http://agavi.org/agavi/config/envelope/1.0" /> 169 <nsName ns="http://agavi.org/agavi/config/annotation/1.0" /> 167 170 </except> 168 171 </anyName> -
branches/david-xml_only_config_system/src/config/rng/factories.rng
r2632 r2641 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <grammar xmlns="http://relaxng.org/ns/structure/1.0" 3 xmlns:factories ="http://agavi.org/agavi/config/factories/1.0"4 ns="http://agavi.org/agavi/config/ factories/1.0"3 xmlns:factories_1_0="http://agavi.org/agavi/config/item/factories/1.0" 4 ns="http://agavi.org/agavi/config/item/factories/1.0" 5 5 datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> 6 6 -
branches/david-xml_only_config_system/src/config/util/dom/AgaviXmlConfigDomDocument.class.php
r2632 r2641 102 102 103 103 if($this->isAgaviConfiguration()) { 104 /* Register Agavi namespace prefixes. */ 105 foreach(AgaviXmlConfigParser::$agaviEnvelopeNamespaces as $namespaceUri => $prefix) { 106 $this->xpath->registerNamespace($prefix, $namespaceUri); 107 } 108 109 /* Register the default envelope namespace. */ 110 $this->xpath->registerNamespace('agavi_envelope_latest', AgaviXmlConfigParser::AGAVI_ENVELOPE_NAMESPACE_LATEST); 104 AgaviXmlConfigParser::registerAgaviNamespaces($this); 111 105 } 112 106 … … 154 148 155 149 if($this->isAgaviConfiguration()) { 156 /* Register Agavi namespace prefixes. */ 157 foreach(AgaviXmlConfigParser::$agaviEnvelopeNamespaces as $namespaceUri => $prefix) { 158 $this->xpath->registerNamespace($prefix, $namespaceUri); 159 } 160 161 /* Register the default envelope namespace. */ 162 $this->xpath->registerNamespace('agavi_envelope_latest', AgaviXmlConfigParser::AGAVI_ENVELOPE_NAMESPACE_LATEST); 150 AgaviXmlConfigParser::registerAgaviNamespaces($this); 163 151 } 164 152 -
branches/david-xml_only_config_system/src/config/util/dom/AgaviXmlConfigDomElement.class.php
r2640 r2641 268 268 269 269 if($this->ownerDocument->isAgaviConfiguration()) { 270 $elements = $this->getChildren('parameters', AgaviXmlConfigParser:: AGAVI_ENVELOPE_NAMESPACE_LATEST);270 $elements = $this->getChildren('parameters', AgaviXmlConfigParser::NAMESPACE_AGAVI_ENVELOPE_LATEST); 271 271 272 272 foreach($elements as $element) { … … 280 280 } 281 281 282 if($element->hasChildren('parameters', AgaviXmlConfigParser:: AGAVI_ENVELOPE_NAMESPACE_LATEST)) {282 if($element->hasChildren('parameters', AgaviXmlConfigParser::NAMESPACE_AGAVI_ENVELOPE_LATEST)) { 283 283 $result[$key] = isset($result[$key]) && is_array($result[$key]) ? $result[$key] : array(); 284 284 $result[$key] = $element->getAgaviParameters($result[$key], $literalize); -
branches/david-xml_only_config_system/src/config/xsl/_common.xsl
r2632 r2641 4 4 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 5 5 xmlns:envelope_0_11="http://agavi.org/agavi/1.0/config" 6 xmlns:envelope_1_0="http://agavi.org/agavi/config/ 1.0">6 xmlns:envelope_1_0="http://agavi.org/agavi/config/envelope/1.0"> 7 7 8 8 <xsl:variable name="envelope_0_11" select="'http://agavi.org/agavi/1.0/config'" /> 9 <xsl:variable name="envelope_1_0" select="'http://agavi.org/agavi/config/ 1.0'" />9 <xsl:variable name="envelope_1_0" select="'http://agavi.org/agavi/config/envelope/1.0'" /> 10 10 11 11 <xsl:template match="envelope_0_11:configurations | envelope_0_11:configuration | envelope_0_11:sandbox | envelope_0_11:parameters | envelope_0_11:parameter"> -
branches/david-xml_only_config_system/src/config/xsl/factories.xsl
r2632 r2641 4 4 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 5 5 xmlns:envelope_0_11="http://agavi.org/agavi/1.0/config" 6 xmlns:factories_1_0="http://agavi.org/agavi/config/ factories/1.0"6 xmlns:factories_1_0="http://agavi.org/agavi/config/item/factories/1.0" 7 7 > 8 8 <!--xmlns:factories_1_1="http://agavi.org/agavi/1.1/config/factories"--> … … 12 12 <xsl:include href="_common.xsl" /> 13 13 14 <xsl:variable name="factories_1_0" select="'http://agavi.org/agavi/config/ factories/1.0'" />14 <xsl:variable name="factories_1_0" select="'http://agavi.org/agavi/config/item/factories/1.0'" /> 15 15 <!--<xsl:variable name="factories11" select="'http://agavi.org/agavi/1.1/config/factories'" />--> 16 16

