|
MediaWiki master
|
Module of static functions for generating XML. More...
Static Public Member Functions | |
| static | closeElement ( $element) |
| Shortcut to close an XML element. | |
| static | element ( $element, $attribs=null, $contents='', $allowShortTag=true) |
| Format an XML element with given attributes and, optionally, text content. | |
| static | elementClean ( $element, $attribs=[], $contents='') |
| Format an XML element as with self::element(), but run text through the content language's normalize() validator first to ensure that no invalid UTF-8 is passed. | |
| static | escapeTagsOnly ( $in) |
| Replace " > and < with their respective HTML entities ( ", >, <) | |
| static | expandAttributes (?array $attribs) |
| Given an array of ('attributename' => 'value'), it generates the code to set the XML attributes : attributename="value". | |
| static | isWellFormedXmlFragment ( $text) |
| Check if a string is a well-formed XML fragment. | |
| static | openElement ( $element, $attribs=null) |
| This opens an XML element. | |
| static | tags ( $element, $attribs, $contents) |
| Same as Xml::element(), but does not escape contents. | |
|
static |
Shortcut to close an XML element.
| string | $element | Element name |
Definition at line 110 of file Xml.php.
Referenced by MediaWiki\Api\ApiFormatXml\recXmlPrint().
|
static |
Format an XML element with given attributes and, optionally, text content.
Element and attribute names are assumed to be ready for literal inclusion. Strings are assumed to not contain XML-illegal characters; special characters (<, >, &) are escaped but illegals are not touched.
| string | $element | Element name |
| array | null | $attribs | Name=>value pairs. Values will be escaped. |
| string | null | $contents | Null to make an open tag only; '' for a contentless closed tag (default) |
| bool | $allowShortTag | Whether '' in $contents will result in a contentless closed tag |
Definition at line 35 of file Xml.php.
References MediaWiki\Xml\Xml\expandAttributes().
Referenced by MediaWiki\Xml\Xml\elementClean(), and MediaWiki\Api\ApiFormatXml\recXmlPrint().
|
static |
Format an XML element as with self::element(), but run text through the content language's normalize() validator first to ensure that no invalid UTF-8 is passed.
| string | $element | |
| array | null | $attribs | Name=>value pairs. Values will be escaped. |
| string | null | $contents | Null to make an open tag only; '' for a contentless closed tag (default) |
Definition at line 83 of file Xml.php.
References MediaWiki\Xml\Xml\element(), and MediaWiki\MediaWikiServices\getInstance().
|
static |
|
static |
Given an array of ('attributename' => 'value'), it generates the code to set the XML attributes : attributename="value".
The values are passed to Sanitizer::encodeAttribute. Returns null or empty string if no attributes given.
| array | null | $attribs | Array of attributes for an XML element |
Definition at line 61 of file Xml.php.
Referenced by MediaWiki\Xml\Xml\element(), and MediaWiki\Xml\Xml\openElement().
|
static |
|
static |
This opens an XML element.
| string | $element | Name of the element |
| array | null | $attribs | Array of attributes, see Xml::expandAttributes() |
Definition at line 101 of file Xml.php.
References MediaWiki\Xml\Xml\expandAttributes().
Referenced by MediaWiki\Api\ApiFormatXml\recXmlPrint(), and MediaWiki\Xml\Xml\tags().
|
static |
Same as Xml::element(), but does not escape contents.
Handy when the content you have is already valid xml.
| string | $element | Element name |
| array | null | $attribs | Array of attributes |
| string | $contents | Content of the element |
Definition at line 127 of file Xml.php.
References MediaWiki\Xml\Xml\openElement().