public function RestWSFormatRDF::addToXML in RESTful Web Services 7.2
Same name and namespace in other branches
- 7 restws.formats.inc \RestWSFormatRDF::addToXML()
Adds the data of the given wrapper to the given XML element.
1 call to RestWSFormatRDF::addToXML()
- RestWSFormatRDF::viewResource in ./
restws.formats.inc - Gets the representation of a resource.
File
- ./
restws.formats.inc, line 741 - RESTful web services module formats.
Class
- RestWSFormatRDF
- A simple formatter for RDF. Requires the RDF module for the mapping.
Code
public function addToXML(DOMDocument $doc, DOMNode $parent, $wrapper) {
$filtered = restws_property_access_filter($wrapper);
foreach ($filtered as $name => $property) {
try {
if ($property instanceof EntityDrupalWrapper) {
// For referenced entities only return the URI.
if ($id = $property
->getIdentifier()) {
$element = $this
->addRdfElement($doc, $wrapper, $name);
$parent
->appendChild($element);
$this
->addReference($doc, $element, $property
->type(), $id);
}
}
elseif ($property instanceof EntityValueWrapper) {
$element = $this
->addRdfElement($doc, $wrapper, $name);
$parent
->appendChild($element);
$element->nodeValue = $property
->value();
}
elseif ($property instanceof EntityListWrapper || $property instanceof EntityStructureWrapper) {
$element = $this
->addRdfElement($doc, $wrapper, $name);
$parent
->appendChild($element);
$node = $doc
->createElementNS($this->namespaces['rdf'], 'rdf:Description');
$element
->appendChild($node);
$this
->addToXML($doc, $node, $property);
}
} catch (EntityMetadataWrapperException $e) {
// A property causes problems - ignore that.
}
}
}