Exemplo n.º 1
0
 private function appendMetadataElement(\DOMDocument $document, Metadata $metadata)
 {
     $node = $document->createElement('metadata');
     foreach ($metadata->all() as $items) {
         foreach ($items as $item) {
             // $child = $document->createElementNS(NamespaceRegistry::NAMESPACE_DC, $item->name, $item->value);
             $child = $document->createElement(sprintf('%s:%s', NamespaceRegistry::PREFIX_DC, $item->name), $item->value);
             if ($item->name === 'identifier') {
                 $child->setAttribute('id', 'dcidid');
             }
             foreach ($item->attributes as $attrName => $attrValue) {
                 // if (false !== $pos = strpos($attrName, ':')) {
                 // 	$nsPrefix = substr($attrName, 0, $pos);
                 // 	$attrName = substr($attrName, $pos + 1);
                 // 	$namespace = constant('ePub\NamespaceRegistry::NAMESPACE_' . strtoupper($nsPrefix));
                 // 	$child->setAttributeNS($namespace, $attrName, $attrValue);
                 // } else {
                 $child->setAttribute($attrName, $attrValue);
                 // }
             }
             $node->appendChild($child);
         }
     }
     return $node;
 }
Exemplo n.º 2
0
 private function processMetadataElement(SimpleXMLElement $xml, Metadata $metadata)
 {
     foreach ($xml->children(NamespaceRegistry::NAMESPACE_DC) as $child) {
         $item = new MetadataItem();
         $item->name = $child->getName();
         $item->value = trim((string) $child);
         $item->attributes = $this->getXmlAttributes($child);
         $metadata->add($item);
     }
 }
Exemplo n.º 3
0
 private function processMetadataElement(SimpleXMLElement $xml, Metadata $metadata)
 {
     if ($xml->count() === 0) {
         return;
     }
     foreach ($xml->children(NamespaceRegistry::NAMESPACE_DC) as $child) {
         $item = new MetadataItem();
         $item->name = $child->getName();
         $item->value = trim((string) $child);
         $item->attributes = $this->getXmlAttributes($child);
         $metadata->add($item);
     }
     // Xml with no DC namespace.
     foreach ($xml->children()->meta as $child) {
         $item = new MetadataItem();
         $item->name = (string) $child['name'];
         $item->value = (string) $child['content'];
         $item->attributes = array();
         $metadata->add($item);
     }
 }