Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Xml Laravel Package

veewee/xml

Type-safe, declarative XML toolkit for PHP. Includes DOM helpers, safe error handling, memory-safe reader/writer, XML encode/decode, plus XSD and XSLT utilities. Spec-compliance ready for PHP 8.4+, with maintained v3 for older PHP.

View on GitHub
Deep Wiki
Context7

XSLT Component

The XSLT component can be used to transform an XML document into something else based on XSLT templates.

Example

use VeeWee\Xml\Dom\Document;
use VeeWee\Xml\Xslt\Processor;
use VeeWee\Xml\Xslt\Configurator;

$processor = Processor::fromTemplateDocument(
    Document::fromXmlFile('xml-to-yaml-converter.xslt'),
    Configurator\all_functions(),
    Configurator\parameters([
        'name' => 'Jos',    
    ])
);
$doc = Document::fromXmlFile('data.xml');

echo $processor->transformDocumentToString($doc);

It consists out of following components:

  • Configurators: Specify how you want to process your XSLT templates.
  • Loaders: Determine where the load the XSLT template from.
  • Transformers: Specify what you want to transform to which kind of output.

Configurators

Specify how you want to process your XSLT templates.

all_functions

Registers all known PHP functions to the XSLTProcessor object, allowing you to use php:function('ucfirst',string(uid)) inside your XSLT Template.

use VeeWee\Xml\Dom\Document;
use VeeWee\Xml\Xslt\Processor;
use function VeeWee\Xml\Xslt\Configurator\all_functions;

$processor = Processor::fromTemplateDocument(
    Document::fromXmlFile('xml-to-yaml-converter.xslt'),
    all_functions()
);

functions

Registers specific PHP functions to the XSLTProcessor object, allowing you to use php:function('ucfirst',string(uid)) inside your XSLT Template.

use VeeWee\Xml\Dom\Document;
use VeeWee\Xml\Xslt\Processor;
use function VeeWee\Xml\Xslt\Configurator\functions;

$processor = Processor::fromTemplateDocument(
    Document::fromXmlFile('xml-to-yaml-converter.xslt'),
    functions(['ucfirst' => ucfirst(...)])
);

namespaced_functions

Registers specific namespaced functions to the XSLTProcessor object, allowing you to use prefix:function('ucfirst',string(uid)) inside your XSLT Template.

use VeeWee\Xml\Dom\Document;
use VeeWee\Xml\Xslt\Processor;
use function VeeWee\Xml\Xslt\Configurator\namespaced_functions;

$processor = Processor::fromTemplateDocument(
    Document::fromXmlFile('xml-to-yaml-converter.xslt'),
    namespaced_functions('http://ns', ['ucfirst' => ucfirst(...)])
);

loader

The loader configurator takes a loader to specify the source of the XSLT Template.

use VeeWee\Xml\Xslt\Processor;
use function VeeWee\Xml\Xslt\Configurator\loader;
use function VeeWee\Xml\Xslt\Loader\from_template_document;

$processor = Processor::configure(
    loader(from_template_document($template))
);

parameters

Registers a map of key/value parameters to the XSLTProcessor which can be used inside your template.

use VeeWee\Xml\Dom\Document;
use VeeWee\Xml\Xslt\Processor;
use function VeeWee\Xml\Xslt\Configurator\parameters;

$processor = Processor::fromTemplateDocument(
    Document::fromXmlFile('xml-to-yaml-converter.xslt'),
    parameters([
        'name' => 'Jos'
    ])
);

profiler

Specify a file in which you want to profile the XSLT processor.

use VeeWee\Xml\Dom\Document;
use VeeWee\Xml\Xslt\Processor;
use function VeeWee\Xml\Xslt\Configurator\profiler;

$processor = Processor::fromTemplateDocument(
    Document::fromXmlFile('xml-to-yaml-converter.xslt'),
    profiler('profiler-info.txt')
);

security_preferences

Specify which security preferences you want to use inside the XSLT processor.

use VeeWee\Xml\Dom\Document;
use VeeWee\Xml\Xslt\Processor;
use function VeeWee\Xml\Xslt\Configurator\security_preferences;

$processor = Processor::fromTemplateDocument(
    Document::fromXmlFile('xml-to-yaml-converter.xslt'),
    security_preferences( XSL_SECPREF_DEFAULT )
);

Loaders

Determine where the load the XSLT template from.

from_template_document

use VeeWee\Xml\Dom\Document;
use VeeWee\Xml\Xslt\Processor;

$template = Document::fromXmlFile('xml-to-yaml-converter.xslt');
$processor = Processor::fromTemplateDocument($template, ...$configurators);

Transformers

Specify what you want to transform to which kind of output.

document_to_string

Transforms the input Document based on the selected XSLT template into a string.

use VeeWee\Xml\Dom\Document;
use VeeWee\Xml\Xslt\Processor;

$template = Document::fromXmlFile('xml-to-yaml-converter.xslt');
$document = Document::fromXmlFile('data.xml');

$processor = Processor::fromTemplateDocument($template);
$text = $processor->transformDocumentToString($document);
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor