Create a QNameValue instance fron an XPathNavigator instance
@param XPathNavigator $node
@return QNameValue
494330
public static function fromXPathNavigator( $node )
	{
		return QNameValue::fromQName( new \lyquidity\xml\qname( $node->getPrefix(), $node->getNamespaceURI(), $node->getLocalName() ) );
	}
774305
protected function checkVariable(DOMNode $node, $tag, $qname)
	{
		// Test whether this variable comes from a previous xsl:param or xsl:variable element
		$this->checkVariableDeclaration($node, $tag, 'xsl:param[@name="' . $qname . '"]');
		$this->checkVariableDeclaration($node, $tag, 'xsl:variable[@name="' . $qname . '"]');
	}
173413
protected function getOptionalNodeAttribute(\DOMNode $node, $name, $default = null)
    {
        $attribute = $node->attributes->getNamedItem($name);
        if ($attribute) {
            return $attribute->nodeValue;
        }

        return $default;
    }
1145420
public static function createFromXML( DOMElement $node )
    {
        $newObj = new eZPageBlock();

        if ( $node->hasAttributes() )
        {
            foreach ( $node->attributes as $attr )
            {
                if ( $attr->name == 'id' )
                {
                    $value = explode( '_', $attr->value );
                    $newObj->setAttribute( $attr->name, $value[1] );
                }
                else
                {
                    $newObj->setAttribute( $attr->name, $attr->value );
                }
            }
        }

        foreach ( $node->childNodes as $node )
        {
            if ( $node->nodeType == XML_ELEMENT_NODE && $node->nodeName == 'item' )
            {
                $blockItemNode = eZPageBlockItem::createFromXML( $node );
                $newObj->addItem( $blockItemNode );
            }
            elseif ( $node->nodeType == XML_ELEMENT_NODE && $node->nodeName == 'rotation' )
            {
                $attrValue = array();

                foreach ( $node->childNodes as $subNode )
                {
                    if ( $subNode->nodeType == XML_ELEMENT_NODE )
                        $attrValue[$subNode->nodeName] = $subNode->nodeValue;
                }

                $newObj->setAttribute( $node->nodeName, $attrValue );
            }
            elseif ( $node->nodeType == XML_ELEMENT_NODE && $node->nodeName == 'custom_attributes' )
            {
                $attrValue = array();

                foreach ( $node->childNodes as $subNode )
                {
                    if ( $subNode->nodeType == XML_ELEMENT_NODE )
                        $attrValue[$subNode->nodeName] = $subNode->nodeValue;
                }

                $newObj->setAttribute( $node->nodeName, $attrValue );
            }
            else
            {
                if ( $node->nodeType == XML_ELEMENT_NODE )
                    $newObj->setAttribute( $node->nodeName, $node->nodeValue );
            }
        }

        return $newObj;
    }
334653
public static function getAllValuesByXpath($node, $xpath_query, $namespaces = array())
    {
        $node_list = XMLTool :: getAllElementsByXpath($node, $xpath_query, $namespaces);

        $values = array();

        if (isset($node_list))
        {
            foreach ($node_list as $node_found)
            {
                $values[] = $node_found->nodeValue;
            }
        }

        return $values;
    }
802129
public static function CreateQName( $context, $ns, $qname )
	{
		if ( $ns instanceof Undefined )
		{
			$ns = "";
		}

		$ns = trim( $ns );
		$qname = trim( $qname );

		if ( empty( $ns ) && strpos( $qname, ":" ) )
		{
			throw XPath2Exception::withErrorCodeAndParam( "FOCA0002", Resources::FOCA0002, $qname );
		}

		// $qn = \lyquidity\xml\qname( $ns, $qname );
		if ( strpos( $qname, ":") !== false )
		{
			$parts = explode( ":", $qname );
			$qn = new \lyquidity\xml\qname( $parts[0], $ns, $parts[1] );
		}
		else
		{
			$prefix = $context->NamespaceManager->lookupPrefix( $ns );
			$qn = new \lyquidity\xml\qname( $prefix ? $prefix : "", $ns, $qname );
		}
		return QNameValue::fromQName( $qn );
	}
1187630
private function visitNode(\DOMNode $node)
    {
        if ($this->node !== $node) {
            $this->node->appendChild($node);
        }

        return $node;
    }
37589
protected function nextTagName($node)
    {
        $nextNode = $node->nextSibling;
        while ($nextNode != null) {
            if ($nextNode instanceof DOMElement) {
                break;
            }
            $nextNode = $nextNode->nextSibling;
        }
        $nextTag = '';
        if ($nextNode instanceof DOMElement && $nextNode != null) {
            $nextTag = strtolower($nextNode->nodeName);
        }

        return $nextTag;
    }
760394
final public function getNodeMapper(SchemaQName $qname): NodeMapper
    {
        $key = $qname->toString();

        if (isset($this->mappers[$key])) {
            return $this->mappers[$key];
        }

        if (isset($this->types[$key], $this->types[$key]['mapper_class'])) {
            $class = $this->types[$key]['mapper_class'];
        } else {
            $class = $this->types['default']['mapper_class'];
        }

        if (isset($this->mappers[$class])) {
            return $this->mappers[$key] = $this->mappers[$class];
        }

        return $this->mappers[$key] = $this->mappers[$class] = new $class;
    }
1339425
protected function traverseNode(Node $node) : Node
    {
        foreach ($node->getSubNodeNames() as $name) {
            $subNode =& $node->$name;

            if (\is_array($subNode)) {
                $subNode = $this->traverseArray($subNode);
                if ($this->stopTraversal) {
                    break;
                }
            } elseif ($subNode instanceof Node) {
                $traverseChildren = true;
                foreach ($this->visitors as $visitor) {
                    $return = $visitor->enterNode($subNode, $traverseChildren);
                    if (null !== $return) {
                        if ($return instanceof Node) {
                            $subNode = $return;
                        } elseif (self::DONT_TRAVERSE_CHILDREN === $return) {
                            $traverseChildren = false;
                        } elseif (self::STOP_TRAVERSAL === $return) {
                            $this->stopTraversal = true;
                            break 2;
                        } else {
                            throw new \LogicException(
                                'enterNode() returned invalid value of type ' . gettype($return)
                            );
                        }
                    }
                }

                if ($traverseChildren) {
                    $subNode = $this->traverseNode($subNode);
                    if ($this->stopTraversal) {
                        break;
                    }
                }

                foreach ($this->visitors as $visitor) {
                    $return = $visitor->leaveNode($subNode);
                    if (null !== $return) {
                        if ($return instanceof Node) {
                            $subNode = $return;
                        } elseif (self::STOP_TRAVERSAL === $return) {
                            $this->stopTraversal = true;
                            break 2;
                        } elseif (\is_array($return)) {
                            throw new \LogicException(
                                'leaveNode() may only return an array ' .
                                'if the parent structure is an array'
                            );
                        } else {
                            throw new \LogicException(
                                'leaveNode() returned invalid value of type ' . gettype($return)
                            );
                        }
                    }
                }
            }
        }

        return $node;
    }
1179094
public static function PrefixFromQName( $qname )
	{
		if ( $qname instanceof Undefined )
		{
			return $qname;
		}

		if ( ! $qname instanceof QNameValue )
		{
			throw XPath2Exception::withErrorCodeAndParams( "XPTY0004", Resources::XPTY0004,
				array(
					SequenceType::WithTypeCodeAndCardinality( SequenceType::GetXmlTypeCodeFromObject( $qname ), XmlTypeCardinality::One ),
					"QName"
				)
			);
		}

		/**
		 * @var QNameValue $qnameValue
		 */
		$qnameValue = $qname;

		return $qnameValue->Prefix == ""
			? Undefined::getValue()
			: $qnameValue->Prefix;
	}
868662
protected function getSortkeyValue(Node $node) {
    // if no role is defined for a or b, the sortkey is
    // determined from the type of the reference node
    $defaultRole = $this->referenceNode->getType();
    $referenceMapper = $this->referenceNode->getMapper();
    $mapper = $node->getMapper();

    if ($referenceMapper && $mapper) {

      $referenceRole = $defaultRole;
      // get the sortkey of the node for the relation to the reference node,
      // if a role is defined
      $oidStr = $node->getOID()->__toString();
      if (isset($this->oidRoleMap[$oidStr])) {
        $nodeRole = $this->oidRoleMap[$oidStr];
        $relationDesc = $referenceMapper->getRelation($nodeRole);
        $referenceRole = $relationDesc->getThisRole();
      }
      $sortkeyDef = $mapper->getSortkey($referenceRole);
      return $node->getValue($sortkeyDef['sortFieldName']);
    }
    return 0;
  }
333145
protected function htmlFromNode($node)
    {
        $domDocument = new \DOMDocument();
        $newNode = $domDocument->importNode($node, true);
        $domDocument->appendChild($newNode);

        return $domDocument->saveHTML();
    }
1159030
public function mutate(Node $node)
    {
        $node->value = new Node\Expr\BinaryOp\Greater($node->key, $node->value, $node->getAttributes());
        $node->key = null;

        return $node;
    }
1267477
private function PrepareValue( $value )
	{
		if ( is_null( $value ) )
			return Undefined::getValue();

		if ( $value instanceof \DOMNode )
		{
			$nav = new DOM\DOMXPathNavigator( $value );
			return $nav;
		}

		if ( $value instanceof XPath2NodeIterator )
		{
			return $value;
		}

		if ( is_array( $value ) || $value instanceof \ArrayIterator )
		{
			return new NodeIterator( function() use( $value ) { return $this->CreateIterator( $value ); } );
		}

		return $value;
	}
607482
public static QName fromNode(final Node nd) {
    String ns = nd.getNamespaceURI();

    if (ns == null) {
      /* It appears a node can have a NULL namespace but a QName has a zero length
       */
      ns = "";
    }

    return new QName(ns, nd.getLocalName());
  }
1067691
public static function ToXmlNode( $nav )
	{
		if ( $nav instanceof \DOMNode ) return $nav;

		if ( $nav instanceof XPathNavigator ) return $nav->getUnderlyingObject();

		return null;
	}