private function canonicalizeData($node, $canonicalmethod, $arXPath = null, $prefixList = null)
{
$exclusive = false;
$withComments = false;
switch ($canonicalmethod) {
case 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315':
$exclusive = false;
$withComments = false;
break;
case 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments':
$withComments = true;
break;
case 'http://www.w3.org/2001/10/xml-exc-c14n#':
$exclusive = true;
break;
case 'http://www.w3.org/2001/10/xml-exc-c14n#WithComments':
$exclusive = true;
$withComments = true;
break;
}
if (is_null($arXPath) && $node instanceof DOMNode && $node->ownerDocument !== null && $node->isSameNode($node->ownerDocument->documentElement)) {
/* Check for any PI or comments as they would have been excluded */
$element = $node;
while ($refnode = $element->previousSibling) {
if ($refnode->nodeType == XML_PI_NODE || $refnode->nodeType == XML_COMMENT_NODE && $withComments) {
break;
}
$element = $refnode;
}
if ($refnode == null) {
$node = $node->ownerDocument;
}
}
return $node->C14N($exclusive, $withComments, $arXPath, $prefixList);
}