DOMHelper
in package
DOM parsing, namespace registration, serialization, and XSLT helper.
Tags
Table of Contents
Constants
- NS_AMBER_AMBERDATA : mixed = 'http://schema.slothsoft.net/amber/amberdata'
- NS_ATOM : mixed = 'http://www.w3.org/2005/Atom'
- NS_CRON_INSTRUCTIONS : mixed = 'http://schema.slothsoft.net/cron/instructions'
- NS_EM : mixed = 'http://www.mozilla.org/2004/em-rdf#'
- NS_FARAH_DICTIONARY : mixed = 'http://schema.slothsoft.net/farah/dictionary'
- NS_FARAH_MODULE : mixed = 'http://schema.slothsoft.net/farah/module'
- NS_FARAH_SITES : mixed = 'http://schema.slothsoft.net/farah/sitemap'
- NS_GD : mixed = 'http://schemas.google.com/g/2005'
- NS_HTML : mixed = 'http://www.w3.org/1999/xhtml'
- NS_MEDIA : mixed = 'http://search.yahoo.com/mrss/'
- NS_PHP : mixed = 'http://php.net/xpath'
- NS_SAVEGAME_EDITOR : mixed = 'http://schema.slothsoft.net/savegame/editor'
- NS_SCHEMA_VERSIONING : mixed = 'http://schema.slothsoft.net/schema/versioning'
- NS_SITEMAP : mixed = 'http://www.sitemaps.org/schemas/sitemap/0.9'
- NS_SVG : mixed = 'http://www.w3.org/2000/svg'
- NS_XINCLUDE : mixed = 'http://www.w3.org/2001/XInclude'
- NS_XLINK : mixed = 'http://www.w3.org/1999/xlink'
- NS_XML : mixed = 'http://www.w3.org/XML/1998/namespace'
- NS_XMLNS : mixed = 'http://www.w3.org/2000/xmlns/'
- NS_XSD : mixed = 'http://www.w3.org/2001/XMLSchema'
- NS_XSI : mixed = 'http://www.w3.org/2001/XMLSchema-instance'
- NS_XSL : mixed = 'http://www.w3.org/1999/XSL/Transform'
- XPATH_HTML : mixed = 4
- XPATH_MISC : mixed = 16
- XPATH_NS_ALL : mixed = -1
- XPATH_PHP : mixed = 8
- XPATH_SLOTHSOFT : mixed = 1
- XPATH_W3C : mixed = 2
Methods
- createDocument() : DOMDocument
- guessExtension() : string
- load() : DOMDocument
- loadDocument() : DOMDocument
- loadXPath() : DOMXPath
- normalizeDocument() : DOMDocument
- Normalizes namespace prefixes in a document without changing element or attribute namespaces.
- parse() : DOMDocumentFragment
- parseDocument() : DOMDocument
- stringify() : string
- transformToDocument() : DOMDocument
- transformToFile() : SplFileInfo
- transformToFragment() : DOMDocumentFragment
Constants
NS_AMBER_AMBERDATA
public
mixed
NS_AMBER_AMBERDATA
= 'http://schema.slothsoft.net/amber/amberdata'
NS_ATOM
public
mixed
NS_ATOM
= 'http://www.w3.org/2005/Atom'
NS_CRON_INSTRUCTIONS
public
mixed
NS_CRON_INSTRUCTIONS
= 'http://schema.slothsoft.net/cron/instructions'
NS_EM
public
mixed
NS_EM
= 'http://www.mozilla.org/2004/em-rdf#'
NS_FARAH_DICTIONARY
public
mixed
NS_FARAH_DICTIONARY
= 'http://schema.slothsoft.net/farah/dictionary'
NS_FARAH_MODULE
public
mixed
NS_FARAH_MODULE
= 'http://schema.slothsoft.net/farah/module'
NS_FARAH_SITES
public
mixed
NS_FARAH_SITES
= 'http://schema.slothsoft.net/farah/sitemap'
NS_GD
public
mixed
NS_GD
= 'http://schemas.google.com/g/2005'
NS_HTML
public
mixed
NS_HTML
= 'http://www.w3.org/1999/xhtml'
NS_MEDIA
public
mixed
NS_MEDIA
= 'http://search.yahoo.com/mrss/'
NS_PHP
public
mixed
NS_PHP
= 'http://php.net/xpath'
NS_SAVEGAME_EDITOR
public
mixed
NS_SAVEGAME_EDITOR
= 'http://schema.slothsoft.net/savegame/editor'
NS_SCHEMA_VERSIONING
public
mixed
NS_SCHEMA_VERSIONING
= 'http://schema.slothsoft.net/schema/versioning'
NS_SITEMAP
public
mixed
NS_SITEMAP
= 'http://www.sitemaps.org/schemas/sitemap/0.9'
NS_SVG
public
mixed
NS_SVG
= 'http://www.w3.org/2000/svg'
NS_XINCLUDE
public
mixed
NS_XINCLUDE
= 'http://www.w3.org/2001/XInclude'
NS_XLINK
public
mixed
NS_XLINK
= 'http://www.w3.org/1999/xlink'
NS_XML
public
mixed
NS_XML
= 'http://www.w3.org/XML/1998/namespace'
NS_XMLNS
public
mixed
NS_XMLNS
= 'http://www.w3.org/2000/xmlns/'
NS_XSD
public
mixed
NS_XSD
= 'http://www.w3.org/2001/XMLSchema'
NS_XSI
public
mixed
NS_XSI
= 'http://www.w3.org/2001/XMLSchema-instance'
NS_XSL
public
mixed
NS_XSL
= 'http://www.w3.org/1999/XSL/Transform'
XPATH_HTML
public
mixed
XPATH_HTML
= 4
XPATH_MISC
public
mixed
XPATH_MISC
= 16
XPATH_NS_ALL
public
mixed
XPATH_NS_ALL
= -1
XPATH_PHP
public
mixed
XPATH_PHP
= 8
XPATH_SLOTHSOFT
public
mixed
XPATH_SLOTHSOFT
= 1
XPATH_W3C
public
mixed
XPATH_W3C
= 2
Methods
createDocument()
public
createDocument(string $namespaceURI, string $qualifiedName) : DOMDocument
Parameters
- $namespaceURI : string
- $qualifiedName : string
Tags
Return values
DOMDocumentguessExtension()
public
static guessExtension(string $namespaceURI) : string
Parameters
- $namespaceURI : string
Return values
stringload()
public
load(mixed $url[, bool $asHTML = false ]) : DOMDocument
Parameters
- $url : mixed
- $asHTML : bool = false
Return values
DOMDocumentloadDocument()
public
static loadDocument(string $filePath[, bool $asHTML = false ]) : DOMDocument
Parameters
- $filePath : string
- $asHTML : bool = false
Return values
DOMDocumentloadXPath()
public
static loadXPath(DOMDocument $document[, int $options = self::XPATH_HTML ]) : DOMXPath
Parameters
- $document : DOMDocument
- $options : int = self::XPATH_HTML
Return values
DOMXPathnormalizeDocument()
Normalizes namespace prefixes in a document without changing element or attribute namespaces.
public
normalizeDocument(DOMDocument $dataDoc) : DOMDocument
Only namespaces known to this helper are explicitly rewritten. Unknown namespaces are not assigned a configured prefix, because a prefix can be rebound inside a subtree and normalizing unknown namespace/prefix pairs globally can change the document meaning. Libxml may still serialize an unknown namespace with an equivalent in-scope prefix or default namespace declaration.
Known namespaces use the standardized prefixes defined by this helper when a prefix is emitted, such as "svg" for self::NS_SVG and "html" for self::NS_HTML. Using a known prefix for an unrelated unknown namespace can lead to unexpected results if the same document also contains the matching known namespace. Redundant namespace declarations may be removed during DOM serialization, and prefix/default namespace spelling may change where the namespace URI and local name remain the same.
Parameters
- $dataDoc : DOMDocument
Return values
DOMDocumentparse()
public
parse(string $xmlCode[, DOMDocument|null $targetDoc = null ][, bool $asHTML = false ]) : DOMDocumentFragment
Parameters
- $xmlCode : string
- $targetDoc : DOMDocument|null = null
- $asHTML : bool = false
Tags
Return values
DOMDocumentFragmentparseDocument()
public
static parseDocument(string $fileContents[, bool $asHTML = false ]) : DOMDocument
Parameters
- $fileContents : string
- $asHTML : bool = false
Return values
DOMDocumentstringify()
public
stringify(DOMNode $sourceNode) : string
Parameters
- $sourceNode : DOMNode
Return values
stringtransformToDocument()
public
transformToDocument(mixed $source, mixed $template[, array<string|int, mixed> $param = [] ]) : DOMDocument
Parameters
- $source : mixed
- $template : mixed
- $param : array<string|int, mixed> = []
Return values
DOMDocumenttransformToFile()
public
transformToFile(mixed $source, mixed $template[, array<string|int, mixed> $param = [] ][, SplFileInfo|null $output = null ]) : SplFileInfo
Parameters
- $source : mixed
- $template : mixed
- $param : array<string|int, mixed> = []
- $output : SplFileInfo|null = null
Return values
SplFileInfotransformToFragment()
public
transformToFragment(mixed $source, mixed $template[, array<string|int, mixed> $param = [] ][, DOMDocument|null $targetDoc = null ]) : DOMDocumentFragment
Parameters
- $source : mixed
- $template : mixed
- $param : array<string|int, mixed> = []
- $targetDoc : DOMDocument|null = null