MediaWiki  1.23.6
XmlTypeCheck Class Reference

Public Member Functions

 __construct ( $input, $filterCallback=null, $isFile=true, $options=array())
 
 getRootElement ()
 Get the root element. More...
 

Static Public Member Functions

static newFromFilename ( $fname, $filterCallback=null)
 Alternative constructor: from filename. More...
 
static newFromString ( $string, $filterCallback=null)
 Alternative constructor: from string. More...
 

Public Attributes

 $filterMatch = false
 Will be set to true if the optional element filter returned a match at some point. More...
 
 $rootElement = ''
 Name of the document's root element, including any namespace as an expanded URL. More...
 
 $wellFormed = false
 Will be set to true or false to indicate whether the file is well-formed XML. More...
 

Protected Attributes

 $elementData = array()
 A stack of strings containing the data of each xml element as it's processed. More...
 
 $elementDataContext = array()
 A stack of element names and attributes, as we process them. More...
 
 $stackDepth = 0
 Current depth of the data stack. More...
 

Private Member Functions

 elementClose ( $parser, $name)
 
 elementData ( $parser, $data)
 
 elementOpen ( $parser, $name, $attribs)
 
 getParser ()
 Get an XML parser with the root element handler. More...
 
 processingInstructionHandler ( $parser, $target, $data)
 
 rootElementOpen ( $parser, $name, $attribs)
 
 validateFromFile ( $fname)
 
 validateFromString ( $string)
 

Private Attributes

 $parserOptions
 Additional parsing options. More...
 

Detailed Description

Definition at line 23 of file XmlTypeCheck.php.

Constructor & Destructor Documentation

◆ __construct()

XmlTypeCheck::__construct (   $input,
  $filterCallback = null,
  $isFile = true,
  $options = array() 
)
Parameters
string$inputa filename or string containing the XML element
callable$filterCallback(optional) Function to call to do additional custom validity checks from the SAX element handler event. This gives you access to the element namespace, name, attributes, and text contents. Filter should return 'true' to toggle on $this->filterMatch
boolean$isFile(optional) indicates if the first parameter is a filename (default, true) or if it is a string (false)
array$optionslist of additional parsing options: processing_instruction_handler: Callback for xml_set_processing_instruction_handler

Definition at line 78 of file XmlTypeCheck.php.

References $options, validateFromFile(), and validateFromString().

Member Function Documentation

◆ elementClose()

XmlTypeCheck::elementClose (   $parser,
  $name 
)
private
Parameters
$parser
$name

Definition at line 227 of file XmlTypeCheck.php.

References $attribs, $name, elementData(), and list.

◆ elementData()

XmlTypeCheck::elementData (   $parser,
  $data 
)
private
Parameters
$parser
$data

Definition at line 247 of file XmlTypeCheck.php.

Referenced by elementClose(), and elementOpen().

◆ elementOpen()

XmlTypeCheck::elementOpen (   $parser,
  $name,
  $attribs 
)
private
Parameters
$parser
$name
$attribs

Definition at line 217 of file XmlTypeCheck.php.

References $attribs, $name, array(), and elementData().

Referenced by rootElementOpen().

◆ getParser()

XmlTypeCheck::getParser ( )
private

Get an XML parser with the root element handler.

See also
XmlTypeCheck::rootElementOpen()
Returns
resource a resource handle for the XML parser

Definition at line 133 of file XmlTypeCheck.php.

References $parser, and array().

Referenced by validateFromFile(), and validateFromString().

◆ getRootElement()

XmlTypeCheck::getRootElement ( )

Get the root element.

Simple accessor to $rootElement

Returns
string

Definition at line 124 of file XmlTypeCheck.php.

References $rootElement.

◆ newFromFilename()

static XmlTypeCheck::newFromFilename (   $fname,
  $filterCallback = null 
)
static

Alternative constructor: from filename.

Parameters
string$fnamethe filename of an XML document
callable$filterCallback(optional) Function to call to do additional custom validity checks from the SAX element handler event. This gives you access to the element namespace, name, and attributes, but not to text contents. Filter should return 'true' to toggle on $this->filterMatch
Returns
XmlTypeCheck

Definition at line 100 of file XmlTypeCheck.php.

References $fname, and true.

◆ newFromString()

static XmlTypeCheck::newFromString (   $string,
  $filterCallback = null 
)
static

Alternative constructor: from string.

Parameters
string$stringa string containing an XML element
callable$filterCallback(optional) Function to call to do additional custom validity checks from the SAX element handler event. This gives you access to the element namespace, name, and attributes, but not to text contents. Filter should return 'true' to toggle on $this->filterMatch
Returns
XmlTypeCheck

Definition at line 115 of file XmlTypeCheck.php.

References false.

Referenced by XmlTypeCheckTest\testMalFormedXML(), and XmlTypeCheckTest\testWellFormedXML().

◆ processingInstructionHandler()

XmlTypeCheck::processingInstructionHandler (   $parser,
  $target,
  $data 
)
private
Parameters
$parser
$target
$data

Definition at line 258 of file XmlTypeCheck.php.

◆ rootElementOpen()

XmlTypeCheck::rootElementOpen (   $parser,
  $name,
  $attribs 
)
private
Parameters
$parser
$name
$attribs

Definition at line 195 of file XmlTypeCheck.php.

References $attribs, $name, $parser, array(), and elementOpen().

◆ validateFromFile()

XmlTypeCheck::validateFromFile (   $fname)
private
Parameters
string$fnamethe filename

Definition at line 150 of file XmlTypeCheck.php.

References $file, $fname, $parser, $ret, and getParser().

Referenced by __construct().

◆ validateFromString()

XmlTypeCheck::validateFromString (   $string)
private
Parameters
string$stringthe XML-input-string to be checked.

Definition at line 179 of file XmlTypeCheck.php.

References $parser, $ret, and getParser().

Referenced by __construct().

Member Data Documentation

◆ $elementData

XmlTypeCheck::$elementData = array()
protected

A stack of strings containing the data of each xml element as it's processed.

Append data to the top string of the stack, then pop off the string and process it when the element is closed.

Definition at line 47 of file XmlTypeCheck.php.

◆ $elementDataContext

XmlTypeCheck::$elementDataContext = array()
protected

A stack of element names and attributes, as we process them.

Definition at line 52 of file XmlTypeCheck.php.

◆ $filterMatch

XmlTypeCheck::$filterMatch = false

Will be set to true if the optional element filter returned a match at some point.

Definition at line 34 of file XmlTypeCheck.php.

◆ $parserOptions

XmlTypeCheck::$parserOptions
private
Initial value:
'processing_instruction_handler' => '',
)

Additional parsing options.

Definition at line 62 of file XmlTypeCheck.php.

◆ $rootElement

XmlTypeCheck::$rootElement = ''

Name of the document's root element, including any namespace as an expanded URL.

Definition at line 40 of file XmlTypeCheck.php.

Referenced by getRootElement().

◆ $stackDepth

XmlTypeCheck::$stackDepth = 0
protected

Current depth of the data stack.

Definition at line 57 of file XmlTypeCheck.php.

◆ $wellFormed

XmlTypeCheck::$wellFormed = false

Will be set to true or false to indicate whether the file is well-formed XML.

Note that this doesn't check schema validity.

Definition at line 28 of file XmlTypeCheck.php.


The documentation for this class was generated from the following file:
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.