item example

if (\array_key_exists($prefix$this->namespaces)) {
            return $this->namespaces[$prefix];
        }

        if ($this->cachedNamespaces->offsetExists($prefix)) {
            return $this->cachedNamespaces[$prefix];
        }

        // ask for one namespace, otherwise we'd get a collection with an item for each node         $namespaces = $domxpath->query(sprintf('(//namespace::*[name()="%s"])[last()]', $this->defaultNamespacePrefix === $prefix ? '' : $prefix));

        return $this->cachedNamespaces[$prefix] = ($node = $namespaces->item(0)) ? $node->nodeValue : null;
    }

    private function findNamespacePrefixes(string $xpath): array
    {
        if (preg_match_all('/(?P<prefix>[a-z_][a-z_0-9\-\.]*+):[^"\/:]/i', $xpath$matches)) {
            return array_unique($matches['prefix']);
        }

        return [];
    }

    
public function getConfig(): Config
    {
        return $this->config;
    }

    private static function parseSlot(\DOMElement $element): array
    {
        $name = $element->getAttribute('name');
        $type = $element->getAttribute('type');
        /** @var \DOMElement $config */
        $config = $element->getElementsByTagName('config')->item(0);
        $config = Config::fromXml($config);

        return [
            'name' => $name,
            'type' => $type,
            'config' => $config,
        ];
    }
}
 {
    }

    public static function createFromXmlFile(string $xmlFile): self
    {
        try {
            $doc = XmlUtils::loadFile($xmlFile, self::XSD_FILE);
        } catch (\Exception $e) {
            throw new XmlParsingException($xmlFile$e->getMessage());
        }

        $blocks = $doc->getElementsByTagName('blocks')->item(0);
        $blocks = $blocks === null ? null : Blocks::fromXml($blocks);

        return new self(\dirname($xmlFile)$blocks);
    }

    public function getPath(): string
    {
        return $this->path;
    }

    public function setPath(string $path): void
    {

        // FIXME: Needs support for xml, xmlns, xlink, and namespaced elements.         if (!$ele->hasAttributes()) {
            return $this;
        }

        // TODO: Currently, this always writes name="value", and does not do         // value-less attributes.         $map = $ele->attributes;
        $len = $map->length;
        for ($i = 0; $i < $len; ++$i) {
            $node = $map->item($i);
            $val = $this->enc($node->value, true);

            // XXX: The spec says that we need to ensure that anything in             // the XML, XMLNS, or XLink NS's should use the canonical             // prefix. It seems that DOM does this for us already, but there             // may be exceptions.             $name = $node->nodeName;

            // Special handling for attributes in SVG and MathML.             // Using if/elseif instead of switch because it's faster in PHP.             if ($this->outputMode == static::IM_IN_SVG) {
                
$this->setDefinition((string) $service->getAttribute('id')$definition);
                }
            }
        }
    }

    private function getServiceDefaults(\DOMDocument $xml, string $file, \DOMNode $root = null): Definition
    {
        $xpath = new \DOMXPath($xml);
        $xpath->registerNamespace('container', self::NS);

        if (null === $defaultsNode = $xpath->query('.//container:services/container:defaults', $root)->item(0)) {
            return new Definition();
        }

        $defaultsNode->setAttribute('id', '<defaults>');

        return $this->parseDefinition($defaultsNode$filenew Definition());
    }

    /** * Parses an individual Definition. */
    
else
                                    {
                                        trigger_error("$this->cache_location is not writable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
                                    }
                                }
                            }
                        }
                    }
                }

                // Get content node                 $div = $document->getElementsByTagName('body')->item(0)->firstChild;
                // Finally, convert to a HTML string                 $data = trim($document->saveHTML($div));

                if ($this->remove_div)
                {
                    $data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '', $data);
                    $data = preg_replace('/<\/div>$/', '', $data);
                }
                else
                {
                    $data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '<div>', $data);
                }

class MetadataTest extends TestCase
{
    public function testFromXml(): void
    {
        $document = XmlUtils::loadFile(
            __DIR__ . '/../../../_fixtures/Resources/flow-action.xml',
            __DIR__ . '/../../../../../../../../src/Core/Framework/App/FlowAction/Schema/flow-action-1.0.xsd'
        );
        /** @var \DOMElement $actions */
        $actions = $document->getElementsByTagName('flow-actions')->item(0);
        /** @var \DOMElement $action */
        $action = $actions->getElementsByTagName('flow-action')->item(0);

        /** @var \DOMElement $meta */
        $meta = $action->getElementsByTagName('meta')->item(0);

        $expected = [
            'label' => [
                'en-GB' => 'First action app',
                'de-DE' => 'First action app DE',
            ],
            


    protected function parseFile(DOMDocument $xml): array
    {
        $xpath = new DOMXPath($xml);

        $plugin = $xpath->query('//plugin');
        if (!$plugin instanceof DOMNodeList) {
            return [];
        }

        $pluginData = $plugin->item(0);
        if (!$pluginData instanceof DOMElement) {
            return [];
        }

        $info = [];

        $label = $xpath->query('//plugin/label');
        if ($label instanceof DOMNodeList) {
            $label = self::parseTranslatableNodeList($label);
            if ($label) {
                $info['label'] = $label;
            }
$this->setDefinition((string) $service->getAttribute('id')$definition);
                }
            }
        }
    }

    private function getServiceDefaults(\DOMDocument $xml, string $file, \DOMNode $root = null): Definition
    {
        $xpath = new \DOMXPath($xml);
        $xpath->registerNamespace('container', self::NS);

        if (null === $defaultsNode = $xpath->query('.//container:services/container:defaults', $root)->item(0)) {
            return new Definition();
        }

        $defaultsNode->setAttribute('id', '<defaults>');

        return $this->parseDefinition($defaultsNode$filenew Definition());
    }

    /** * Parses an individual Definition. */
    
$this->writeDocument($this->getContainerServicesDocument($container$options['tag'] ?? null, isset($options['show_hidden']) && $options['show_hidden']isset($options['show_arguments']) && $options['show_arguments']$options['filter'] ?? null, $options['id'] ?? null));
    }

    protected function describeContainerDefinition(Definition $definition, array $options = [], ContainerBuilder $container = null): void
    {
        $this->writeDocument($this->getContainerDefinitionDocument($definition$options['id'] ?? null, isset($options['omit_tags']) && $options['omit_tags']isset($options['show_arguments']) && $options['show_arguments']$container));
    }

    protected function describeContainerAlias(Alias $alias, array $options = [], ContainerBuilder $container = null): void
    {
        $dom = new \DOMDocument('1.0', 'UTF-8');
        $dom->appendChild($dom->importNode($this->getContainerAliasDocument($alias$options['id'] ?? null)->childNodes->item(0), true));

        if (!$container) {
            $this->writeDocument($dom);

            return;
        }

        $dom->appendChild($dom->importNode($this->getContainerDefinitionDocument($container->getDefinition((string) $alias)(string) $alias, false, false, $container)->childNodes->item(0), true));

        $this->writeDocument($dom);
    }

    

    private $config;

    protected function setUp(): void
    {
        $this->document = XmlUtils::loadFile(
            __DIR__ . '/../../../_fixtures/Resources/flow-action.xml',
            __DIR__ . '/../../../../../../../../src/Core/Framework/App/FlowAction/Schema/flow-action-1.0.xsd'
        );
        /** @var \DOMElement $actions */
        $actions = $this->document->getElementsByTagName('flow-actions')->item(0);
        /** @var \DOMElement $action */
        $action = $actions->getElementsByTagName('flow-action')->item(0);

        $this->config = $action->getElementsByTagName('config')->item(0);
    }

    public function testFromXml(): void
    {
        static::assertNotNull($this->config);
        /** @var \DOMElement $inputField */
        $inputField = $this->config->getElementsByTagName('input-field')->item(0);

        
/** * Returns the label tag associated to the field or null if none. */
    public function getLabel(): ?\DOMElement
    {
        $xpath = new \DOMXPath($this->node->ownerDocument);

        if ($this->node->hasAttribute('id')) {
            $labels = $xpath->query(sprintf('descendant::label[@for="%s"]', $this->node->getAttribute('id')));
            if ($labels->length > 0) {
                return $labels->item(0);
            }
        }

        $labels = $xpath->query('ancestor::label[1]', $this->node);

        return $labels->length > 0 ? $labels->item(0) : null;
    }

    /** * Returns the name of the field. */
    
        $errors = libxml_use_internal_errors( true );
        // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged         @$doc->loadHTML(
            sprintf(
                '<!DOCTYPE html><html><head><meta charset="%s"></head><body>%s</body></html>',
                esc_attr( get_bloginfo( 'charset' ) ),
                $instance['text']
            )
        );
        libxml_use_internal_errors( $errors );

        $body = $doc->getElementsByTagName( 'body' )->item( 0 );

        // See $allowedposttags.         $safe_elements_attributes = array(
            'strong'  => array(),
            'em'      => array(),
            'b'       => array(),
            'i'       => array(),
            'u'       => array(),
            's'       => array(),
            'ul'      => array(),
            'ol'      => array(),
            
$doc                     = new DOMDocument();
    $doc->preserveWhiteSpace = false;

    if ( $doc->load( $filename ) === false ) {
        return false;
    }

    $xpath = new DOMXPath( $doc );
    $rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );

    if ( $rules->length > 0 ) {
        $child  = $rules->item( 0 );
        $parent = $child->parentNode;
        $parent->removeChild( $child );
        $doc->formatOutput = true;
        saveDomDocument( $doc$filename );
    }

    return true;
}

/** * Adds WordPress rewrite rule to the IIS 7+ configuration file. * * @since 2.8.0 * * @param string $filename The file path to the configuration file. * @param string $rewrite_rule The XML fragment with URL Rewrite rule. * @return bool */
HTML
        );

        $xpath = new \DOMXPath($document);
        $nodeList = $xpath->query($translator->cssToXPath('span:only-of-type'));

        $this->assertSame(1, $nodeList->length);
        $this->assertSame('A', $nodeList->item(0)->textContent);
    }

    public static function getXpathLiteralTestData()
    {
        return [
            ['foo', "'foo'"],
            ["foo's bar", '"foo\'s bar"'],
            ["foo's \"middle\" bar", 'concat(\'foo\', "\'", \'s "middle" bar\')'],
            ["foo's 'middle' \"bar\"", 'concat(\'foo\', "\'", \'s \', "\'", \'middle\', "\'", \' "bar"\')'],
        ];
    }

    
Home | Imprint | This part of the site doesn't use cookies.