94 if ( $indent !==
null ) {
95 if ( $name !==
null ) {
98 $indstr =
"\n" . str_repeat(
' ', $indent );
103 if ( is_object(
$value ) ) {
106 if ( is_array(
$value ) ) {
114 $subelementKeys = array_merge(
133 $indexedSubelements = [];
134 foreach (
$value as $k => $v ) {
140 if ( is_bool( $v ) && !in_array( $k, $bcBools,
true ) ) {
141 $v = $v ?
'true' :
'false';
144 if ( $name !==
null && $k === $contentKey ) {
146 } elseif ( is_int( $k ) ) {
147 $indexedSubelements[$k] = $v;
148 } elseif ( is_array( $v ) || is_object( $v ) ) {
150 } elseif ( in_array( $k, $subelementKeys,
true ) || $name ===
null ) {
156 } elseif ( is_bool( $oldv ) ) {
160 } elseif ( $v !==
null ) {
165 if ( $content !==
null ) {
166 if ( $subelements || $indexedSubelements ) {
168 'content' => $content,
173 } elseif ( is_scalar( $content ) ) {
176 $attributes += [
'xml:space' =>
'preserve' ];
180 if ( $content !==
null ) {
181 if ( is_scalar( $content ) ) {
182 $retval .= $indstr . Xml::element( $name, $attributes, $content );
184 if ( $name !==
null ) {
185 $retval .= $indstr . Xml::element( $name, $attributes,
null );
187 $retval .= static::recXmlPrint(
null, $content, $indent );
188 if ( $name !==
null ) {
189 $retval .= $indstr . Xml::closeElement( $name );
192 } elseif ( !$indexedSubelements && !$subelements ) {
193 if ( $name !==
null ) {
194 $retval .= $indstr . Xml::element( $name, $attributes );
197 if ( $name !==
null ) {
198 $retval .= $indstr . Xml::element( $name, $attributes,
null );
200 foreach ( $subelements as $k => $v ) {
201 $retval .= static::recXmlPrint( $k, $v, $indent );
203 foreach ( $indexedSubelements as $k => $v ) {
204 $retval .= static::recXmlPrint( $indexedTagName, $v, $indent,
205 $indexSubelements ? [
'_idx' => $k ] : []
208 if ( $name !==
null ) {
209 $retval .= $indstr . Xml::closeElement( $name );
216 $retval .= $indstr . Xml::element( $name, $attributes );
218 $retval .= $indstr . Xml::element( $name, $attributes,
$value );
266 $nt = Title::newFromText( $this->mXslt );
267 if ( is_null( $nt ) || !$nt->exists() ) {
268 $this->
addWarning(
'apiwarn-invalidxmlstylesheet' );
272 if ( $nt->getNamespace() != NS_MEDIAWIKI ) {
273 $this->
addWarning(
'apiwarn-invalidxmlstylesheetns' );
277 if ( substr( $nt->getText(), -4 ) !==
'.xsl' ) {
278 $this->
addWarning(
'apiwarn-invalidxmlstylesheetext' );
282 $this->
printText(
'<?xml-stylesheet href="' .
283 htmlspecialchars( $nt->getLocalURL(
'action=raw' ) ) .
'" type="text/xsl" ?>' );