/** * @param $arguments * @return mixed * @throws \Genkgo\Xsl\Schema\Exception\UnknownSequenceItemException */ public static function call(...$arguments) { return XsSequence::fromArray($arguments); }
/** * @param $elements * @param $position * @param null $length * @return XsSequence * @throws \Genkgo\Xsl\Schema\Exception\UnknownSequenceItemException */ public static function subsequence($elements, $position, $length = null) { return XsSequence::fromArray(array_slice($elements, $position - 1, $length)); }
/** * @param $haystack * @param $needle * @return bool|int */ public static function indexOf($haystack, $needle) { if (is_string($haystack)) { $position = strpos($haystack, $needle); if ($position === false) { return false; } return $position + 1; } $index = 1; $sequence = XsSequence::fromArray($haystack); foreach ($sequence->documentElement->childNodes as $childNode) { if ($needle === $childNode->nodeValue) { return $index; } $index++; } return false; }
/** * @param $elements * @return DOMDocument */ public static function inScopePrefixes($elements) { Assert::assertArray($elements); $listOfPrefixes = []; foreach ($elements as $element) { $listOfPrefixes = array_merge($listOfPrefixes, array_keys(FetchNamespacesFromNode::fetch($element))); } return XsSequence::fromArray($listOfPrefixes); }
/** * @param $first * @param $last * @return mixed * @throws \Genkgo\Xsl\Schema\Exception\UnknownSequenceItemException */ public static function call($first, $last) { return XsSequence::fromArray(range($first, $last)); }