BlueSpice MediaWiki REL1_27
 All Classes Namespaces Files Functions Variables Groups Pages
XmlTypeCheck Class Reference

Public Member Functions

 __construct ($input, $filterCallback=null, $isFile=true, $options=[])
 
 getRootElement ()
 
 XmlErrorHandler ($errno, $errstr)
 

Static Public Member Functions

static newFromFilename ($fname, $filterCallback=null)
 
static newFromString ($string, $filterCallback=null)
 

Public Attributes

 $wellFormed = null
 
 $filterMatch = false
 
 $filterMatchType = false
 
 $rootElement = ''
 

Protected Attributes

 $elementData = []
 
 $elementDataContext = []
 
 $stackDepth = 0
 

Constructor & Destructor Documentation

XmlTypeCheck::__construct (   $input,
  $filterCallback = null,
  $isFile = true,
  $options = [] 
)

Allow filtering an XML file.

Filters should return either true or a string to indicate something is wrong with the file. $this->filterMatch will store if the file failed validation (true = failed validation). $this->filterMatchType will contain the validation error. $this->wellFormed will contain whether the xml file is well-formed.

Note
If multiple filters are hit, only one of them will have the result stored in $this->filterMatchType.
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 a truthy value describing the error.
bool$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 external_dtd_handler: Callback for the url of external dtd subset dtd_handler: Callback given the full text of the <!DOCTYPE declaration. require_safe_dtd: Only allow non-recursive entities in internal dtd (default true)

Member Function Documentation

XmlTypeCheck::getRootElement ( )

Get the root element. Simple accessor to $rootElement

Returns
string
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
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

Member Data Documentation

XmlTypeCheck::$elementData = []
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.

XmlTypeCheck::$elementDataContext = []
protected

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

XmlTypeCheck::$filterMatch = false

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

XmlTypeCheck::$rootElement = ''

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

XmlTypeCheck::$stackDepth = 0
protected

Current depth of the data stack.

XmlTypeCheck::$wellFormed = null

Will be set to true or false to indicate whether the file is well-formed XML. Note that this doesn't check schema validity.


The documentation for this class was generated from the following file: