Beispiel #1
0
 public function testGenericXinclude()
 {
     $type_schema_path = __DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'extensive_type_schema_include.xml';
     $document = new Document('1.0', 'utf-8');
     $document->load($type_schema_path);
     $document->xinclude();
     $xpath = new Xpath($document);
     $xml_base_nodes = $xpath->query('//@xml:base', $document);
     $this->assertEquals(0, $xml_base_nodes->length);
 }
 protected function createDomDocument($type_schema_file)
 {
     if (!is_readable($type_schema_file)) {
         throw new FileSystemException("Unable to read file at path '{$type_schema_file}'.");
     }
     // @todo more xml error handling
     $document = new Document('1.0', 'utf-8');
     if (!$document->load($type_schema_file)) {
         throw new ParseException("Failed loading the given type-schema.");
     }
     $document->xinclude();
     if (!$document->schemaValidate($this->xsd_schema_file)) {
         throw new ParseException("Schema validation for the given type-schema failed.");
     }
     return $document;
 }
 public function testOneNestedOptions()
 {
     $dom_document = new Document('1.0', 'utf-8');
     $dom_document->loadXML('<random_container xmlns="http://berlinonline.net/trellis/1.0/schema">
             <option name="types">
                 <option>VotingStats</option>
             </option>
         </random_container>');
     $xpath = new Xpath($dom_document);
     $parser = new OptionDefinitionXpathParser();
     $option_definitions = $parser->parse($xpath, array('context' => $dom_document->documentElement));
     $types_option = $option_definitions[0];
     $types_options_value = $types_option->getValue();
     $this->assertInstanceOf('Trellis\\CodeGen\\Schema\\OptionDefinitionList', $option_definitions);
     $this->assertInstanceOf('Trellis\\CodeGen\\Schema\\OptionDefinitionList', $types_option->getValue());
     $this->assertEquals(1, $option_definitions->getSize());
     $this->assertEquals('VotingStats', $types_options_value[0]->getValue());
 }
Beispiel #4
0
 public function testAlreadyExistentNamespacePrefix()
 {
     // Document has already a namespace prefixed as 'dt' (the default Xpath prefix, if not specified in construtor)
     // 'Namespaced' value should not be retrieved; its prefix
     //      will be the same as the already defined in the parents
     // 'Conflicting' should not be retrieved as well
     //      cause 'dt' will corresponds to two namespaces
     $dom_document = new Document('1.0', 'utf-8');
     $dom_document->loadXML('<any_container
             xmlns="http://berlinonline.net/trellis/1.0/schema"
             xmlns:on="urn:other:namespace"
             xmlns:dt="urn:conflicting:prefix:namespace">
             <dt:option name="types">
                 <option>Namespaced</option>
                 <on:option>OtherNamespace</on:option>
                 <dt:option>Conflicting</dt:option>
                 <option xmlns="">NonNamespaced</option>
             </dt:option>
         </any_container>');
     $xpath = new Xpath($dom_document);
     $xpath->registerNamespace('dt', 'urn:conflicting:prefix:namespace');
     $options_nodelist = $xpath->query('/any_container/dt:option/option', $dom_document->documentElement);
     $this->assertEquals(0, $options_nodelist->length);
 }