1
|
<?php
|
2
|
require_once('objects/types.php');
|
3
|
|
4
|
function isIgnoreType($nodeName) {
|
5
|
global $ignoreTypes;
|
6
|
return $ignoreTypes[$nodeName];
|
7
|
}
|
8
|
|
9
|
function isPrimitiveType($nodeName) {
|
10
|
global $primitiveTypes;
|
11
|
return $primitiveTypes[$nodeName];
|
12
|
}
|
13
|
|
14
|
function isKnownAttribute($attrName) {
|
15
|
global $knownAttributes;
|
16
|
return $knownAttributes[$attrName];
|
17
|
}
|
18
|
|
19
|
function hasImportantNodes($node) {
|
20
|
$nodes = $node->getElementsbyTagName("*");
|
21
|
foreach($nodes as $node) {
|
22
|
$nodeName = preg_replace("/.*:/","",$node->nodeName);
|
23
|
if(!isIgnoreType($nodeName)) {
|
24
|
return true;
|
25
|
}
|
26
|
}
|
27
|
return false;
|
28
|
}
|
29
|
|
30
|
function stringXMLNode($node) {
|
31
|
return $node->ownerDocument->saveXML($node);
|
32
|
}
|
33
|
|
34
|
function findFirstAncestorName($node) {
|
35
|
$xpath = new DOMXPath($node->ownerDocument);
|
36
|
$parentNodes = $xpath->query("parent::*",$node);
|
37
|
$parentNode = $parentNodes->item(0);
|
38
|
$name = $parentNode->getAttribute('name');
|
39
|
if($name != '') {
|
40
|
return $name;
|
41
|
} else {
|
42
|
return findFirstAncestorName($parentNode);
|
43
|
}
|
44
|
}
|
45
|
|
46
|
?>
|