Changeset 2581
- Timestamp:
- 07/07/08 04:38:07 (6 months ago)
- Location:
- branches/david-xml_only_config_system/src/config
- Files:
-
- 2 modified
-
AgaviXmlConfigParser.class.php (modified) (8 diffs)
-
dom/AgaviXmlConfigDomDocument.class.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/david-xml_only_config_system/src/config/AgaviXmlConfigParser.class.php
r2572 r2581 47 47 */ 48 48 public static $agaviEnvelopeNamespaces = array( 49 self::AGAVI_ENVELOPE_NAMESPACE_1_0 => 'a e10',49 self::AGAVI_ENVELOPE_NAMESPACE_1_0 => 'agavi_envelope_1_0', 50 50 ); 51 51 … … 74 74 */ 75 75 protected $xpath = null; 76 77 /** 78 * Test if the given document looks like an Agavi config file. 79 * 80 * @param DOMDocument The document to test. 81 * 82 * @return bool True, if it is an Agavi config document, false otherwise. 83 * 84 * @author David Zülke <david.zuelke@bitextender.com> 85 * @since 1.0.0 86 */ 87 public static function isAgaviConfigurationDocument(DOMDocument $doc) 88 { 89 return $doc->documentElement && $doc->documentElement->localName == 'configurations' && self::isAgaviEnvelopeNamespace($doc->documentElement->namespaceURI); 90 } 76 91 77 92 /** … … 117 132 // make sure it (still) is a <configurations> file with the proper agavi namespace 118 133 if($isAgaviConfigFormat) { 119 $isAgaviConfigFormat = $doc->documentElement && $doc->documentElement->localName == 'configurations' && self::isAgaviEnvelopeNamespace($doc->documentElement->namespaceURI);134 $isAgaviConfigFormat = self::isAgaviConfigurationDocument($doc); 120 135 } 121 136 … … 161 176 162 177 $configurationOrder = array( 163 'count(self::node()[ not(@environment) and not(@context)])',164 'count(self::node()[@ environment and not(@context)])',165 'count(self::node()[ not(@environment) and @context])',166 'count(self::node()[@ environment and @context])',178 'count(self::node()[@agavi_envelope_1_0:matched and not(@environment) and not(@context)])', 179 'count(self::node()[@agavi_envelope_1_0:matched and @environment and not(@context)])', 180 'count(self::node()[@agavi_envelope_1_0:matched and not(@environment) and @context])', 181 'count(self::node()[@agavi_envelope_1_0:matched and @environment and @context])', 167 182 ); 168 183 $testAttributes = array( … … 175 190 foreach($configurationElements as &$element) { 176 191 if($element->ownerDocument->xpath->evaluate($xpath, $element)) { 177 foreach($testAttributes as $attributeName => $attributeValue) {178 // TODO: move that method or something179 if($element->hasAttribute($attributeName) && !self::testPattern($element->getAttribute($attributeName), $attributeValue)) {180 continue 2;181 }182 }183 192 $importedNode = $retval->importNode($element, true); 184 193 $retval->documentElement->appendChild($importedNode); … … 241 250 libxml_clear_errors(); 242 251 243 $this->doc = new DOMDocument();252 $this->doc = new AgaviXmlConfigDomDocument(); 244 253 $this->doc->load($path); 245 254 … … 302 311 303 312 /** 304 * Prepare the configuration file, resolve XIncludes, and validate embedded 305 * XML Schemas. 313 * Prepare the configuration file: resolve XIncludes, validate against XML 314 * Schema instances declared on the document, and set processing information 315 * flags on <configuration> elements. 306 316 * 307 317 * @author David Zülke <dz@bitxtender.com> … … 393 403 } 394 404 $this->validateXmlschemaSource($schemas); 405 } 406 407 if($this->doc->isAgaviConfiguration()) { 408 $testAttributes = array( 409 'context' => $this->context, 410 'environment' => $this->environment, 411 ); 412 413 foreach($this->doc->getConfigurationElements() as $configuration) { 414 $matched = true; 415 foreach($testAttributes as $attributeName => $attributeValue) { 416 if($configuration->hasAttribute($attributeName)) { 417 $matched = $matched && self::testPattern($configuration->getAttribute($attributeName), $attributeValue); 418 } 419 } 420 if($matched) { 421 $configuration->setAttributeNS(self::AGAVI_ENVELOPE_NAMESPACE_LATEST, 'matched', 'true'); 422 } 423 } 395 424 } 396 425 } -
branches/david-xml_only_config_system/src/config/dom/AgaviXmlConfigDomDocument.class.php
r2482 r2581 135 135 public function isAgaviConfiguration() 136 136 { 137 return AgaviXmlConfigParser::isAgavi EnvelopeNamespace($this->documentElement->namespaceURI);137 return AgaviXmlConfigParser::isAgaviConfigurationDocument($this); 138 138 } 139 139 … … 166 166 $retval = array(); 167 167 168 if($this->isAgaviConfiguration File()) {168 if($this->isAgaviConfiguration()) { 169 169 $agaviNs = $this->getAgaviEnvelopeNamespace(); 170 170

