ILIAS
eassessment Revision 61809
|
Static Public Member Functions | |
apiVersion () | |
return API version | |
replaceEntities ($string, $replaceEntities=XML_UTIL_ENTITIES_XML, $encoding= 'ISO-8859-1') | |
replace XML entities | |
reverseEntities ($string, $replaceEntities=XML_UTIL_ENTITIES_XML, $encoding= 'ISO-8859-1') | |
reverse XML entities | |
getXMLDeclaration ($version= '1.0', $encoding=null, $standalone=null) | |
build an xml declaration | |
getDocTypeDeclaration ($root, $uri=null, $internalDtd=null) | |
build a document type declaration | |
attributesToString ($attributes, $sort=true, $multiline=false, $indent= ' ', $linebreak="\n", $entities=XML_UTIL_ENTITIES_XML) | |
create string representation of an attribute list | |
collapseEmptyTags ($xml, $mode=XML_UTIL_COLLAPSE_ALL) | |
Collapses empty tags. | |
createTag ($qname, $attributes=array(), $content=null, $namespaceUri=null, $replaceEntities=XML_UTIL_REPLACE_ENTITIES, $multiline=false, $indent= '_auto', $linebreak="\n", $sortAttributes=true) | |
create a tag | |
createTagFromArray ($tag, $replaceEntities=XML_UTIL_REPLACE_ENTITIES, $multiline=false, $indent= '_auto', $linebreak="\n", $sortAttributes=true) | |
create a tag from an array this method awaits an array in the following format | |
createStartElement ($qname, $attributes=array(), $namespaceUri=null, $multiline=false, $indent= '_auto', $linebreak="\n", $sortAttributes=true) | |
create a start element | |
createEndElement ($qname) | |
create an end element | |
createComment ($content) | |
create an XML comment | |
createCDataSection ($data) | |
create a CData section | |
splitQualifiedName ($qname, $defaultNs=null) | |
split qualified name and return namespace and local part | |
isValidName ($string) | |
check, whether string is valid XML name | |
raiseError ($msg, $code) | |
replacement for XML_Util::raiseError |
|
static |
|
static |
create string representation of an attribute list
require_once 'XML/Util.php';
// build an attribute string $att = array( 'foo' => 'bar', 'argh' => 'tomato' );
$attList = XML_Util::attributesToString($att);
array | $attributes | attribute array |
bool | array | $sort | sort attribute list alphabetically, may also be an assoc array containing the keys 'sort', 'multiline', 'indent', 'linebreak' and 'entities' |
bool | $multiline | use linebreaks, if more than one attribute is given |
string | $indent | string used for indentation of multiline attributes |
string | $linebreak | string used for linebreaks of multiline attributes |
int | $entities | setting for entities in attribute values (one of XML_UTIL_ENTITIES_NONE, XML_UTIL_ENTITIES_XML, XML_UTIL_ENTITIES_XML_REQUIRED, XML_UTIL_ENTITIES_HTML) |
Definition at line 383 of file Util.php.
References replaceEntities(), XML_UTIL_CDATA_SECTION, XML_UTIL_ENTITIES_NONE, and XML_UTIL_ENTITIES_XML.
Referenced by createStartElement(), createTagFromArray(), and getXMLDeclaration().
|
static |
Collapses empty tags.
string | $xml | XML |
int | $mode | Whether to collapse all empty tags (XML_UTIL_COLLAPSE_ALL) or only XHTML (XML_UTIL_COLLAPSE_XHTML_ONLY) ones. |
Definition at line 454 of file Util.php.
References XML_UTIL_COLLAPSE_XHTML_ONLY.
|
static |
create a CData section
require_once 'XML/Util.php';
// create a CData section $tag = XML_Util::createCDataSection('I am content.');
string | $data | data of the CData section |
Definition at line 798 of file Util.php.
References $data.
Referenced by createTagFromArray().
|
static |
create an XML comment
require_once 'XML/Util.php';
// create an XML start element: $tag = XML_Util::createComment('I am a comment');
string | $content | content of the comment |
Definition at line 776 of file Util.php.
References $comment.
|
static |
create an end element
require_once 'XML/Util.php';
// create an XML start element: $tag = XML_Util::createEndElement('myNs:myTag');
string | $qname | qualified tagname (including namespace) |
Definition at line 754 of file Util.php.
|
static |
create a start element
require_once 'XML/Util.php';
// create an XML start element: $tag = XML_Util::createStartElement('myNs:myTag', array('foo' => 'bar') ,'http://www.w3c.org/myNs#');
string | $qname | qualified tagname (including namespace) |
array | $attributes | array containg attributes |
string | $namespaceUri | URI of the namespace |
bool | $multiline | whether to create a multiline tag where each attribute gets written to a single line |
string | $indent | string used to indent attributes (_auto indents attributes so they start at the same column) |
string | $linebreak | string used for linebreaks |
bool | $sortAttributes | Whether to sort the attributes or not |
Definition at line 700 of file Util.php.
References attributesToString(), and splitQualifiedName().
|
static |
create a tag
This method will call XML_Util::createTagFromArray(), which is more flexible.
require_once 'XML/Util.php';
// create an XML tag: $tag = XML_Util::createTag('myNs:myTag', array('foo' => 'bar'), 'This is inside the tag', 'http://www.w3c.org/myNs#');
string | $qname | qualified tagname (including namespace) |
array | $attributes | array containg attributes |
mixed | $content | the content |
string | $namespaceUri | URI of the namespace |
int | $replaceEntities | whether to replace XML special chars in content, embedd it in a CData section or none of both |
bool | $multiline | whether to create a multiline tag where each attribute gets written to a single line |
string | $indent | string used to indent attributes (_auto indents attributes so they start at the same column) |
string | $linebreak | string used for linebreaks |
bool | $sortAttributes | Whether to sort the attributes or not |
Definition at line 504 of file Util.php.
References createTagFromArray().
|
static |
create a tag from an array this method awaits an array in the following format
array( // qualified name of the tag 'qname' => $qname
// namespace prefix (optional, if qname is specified or no namespace) 'namespace' => $namespace
// local part of the tagname (optional, if qname is specified) 'localpart' => $localpart,
// array containing all attributes (optional) 'attributes' => array(),
// tag content (optional) 'content' => $content,
// namespaceUri for the given namespace (optional) 'namespaceUri' => $namespaceUri )
require_once 'XML/Util.php';
$tag = array( 'qname' => 'foo:bar', 'namespaceUri' => 'http://foo.com', 'attributes' => array('key' => 'value', 'argh' => 'fruit&vegetable'), 'content' => 'I\'m inside the tag', ); // creating a tag with qualified name and namespaceUri $string = XML_Util::createTagFromArray($tag);
array | $tag | tag definition |
int | $replaceEntities | whether to replace XML special chars in content, embedd it in a CData section or none of both |
bool | $multiline | whether to create a multiline tag where each attribute gets written to a single line |
string | $indent | string used to indent attributes (_auto indents attributes so they start at the same column) |
string | $linebreak | string used for linebreaks |
bool | $sortAttributes | Whether to sort the attributes or not |
Definition at line 587 of file Util.php.
References attributesToString(), createCDataSection(), raiseError(), replaceEntities(), splitQualifiedName(), XML_UTIL_CDATA_SECTION, XML_UTIL_ENTITIES_NONE, XML_UTIL_ERROR_NO_TAG_NAME, and XML_UTIL_ERROR_NON_SCALAR_CONTENT.
Referenced by createTag().
|
static |
build a document type declaration
require_once 'XML/Util.php';
// get a doctype declaration: $xmlDecl = XML_Util::getDocTypeDeclaration('rootTag','myDocType.dtd');
string | $root | name of the root tag |
string | $uri | uri of the doctype definition (or array with uri and public id) |
string | $internalDtd | internal dtd entries |
Definition at line 328 of file Util.php.
|
static |
build an xml declaration
require_once 'XML/Util.php';
// get an XML declaration: $xmlDecl = XML_Util::getXMLDeclaration('1.0', 'UTF-8', true);
string | $version | xml version |
string | $encoding | character encoding |
bool | $standalone | document is standalone (or not) |
Definition at line 289 of file Util.php.
References attributesToString().
|
static |
check, whether string is valid XML name
XML names are used for tagname, attribute names and various other, lesser known entities.
An XML name may only consist of alphanumeric characters, dashes, undescores and periods, and has to start with a letter or an underscore.
require_once 'XML/Util.php';
// verify tag name $result = XML_Util::isValidName('invalidTag?'); if (is_a($result, 'PEAR_Error')) { print 'Invalid XML name: ' . $result->getMessage(); }
string | $string | string that should be checked |
Definition at line 871 of file Util.php.
References raiseError(), XML_UTIL_ERROR_INVALID_CHARS, and XML_UTIL_ERROR_INVALID_START.
|
static |
replacement for XML_Util::raiseError
Avoids the necessity to always require PEAR.php
string | $msg | error message |
int | $code | error code |
Definition at line 905 of file Util.php.
Referenced by createTagFromArray(), and isValidName().
|
static |
replace XML entities
With the optional second parameter, you may select, which entities should be replaced.
require_once 'XML/Util.php';
// replace XML entites: $string = XML_Util::replaceEntities('This string contains < & >.');
With the optional third parameter, you may pass the character encoding require_once 'XML/Util.php';
// replace XML entites in UTF-8: $string = XML_Util::replaceEntities( 'This string contains < & > as well as ä, ö, ß, à and ê', XML_UTIL_ENTITIES_HTML, 'UTF-8' );
string | $string | string where XML special chars should be replaced |
int | $replaceEntities | setting for entities in attribute values (one of XML_UTIL_ENTITIES_XML, XML_UTIL_ENTITIES_XML_REQUIRED, XML_UTIL_ENTITIES_HTML) |
string | $encoding | encoding value (if any)... must be a valid encoding as determined by the htmlentities() function |
Definition at line 179 of file Util.php.
References XML_UTIL_ENTITIES_HTML, XML_UTIL_ENTITIES_XML, and XML_UTIL_ENTITIES_XML_REQUIRED.
Referenced by attributesToString(), and createTagFromArray().
|
static |
reverse XML entities
With the optional second parameter, you may select, which entities should be reversed.
require_once 'XML/Util.php';
// reverse XML entites: $string = XML_Util::reverseEntities('This string contains < & >.');
With the optional third parameter, you may pass the character encoding require_once 'XML/Util.php';
// reverse XML entites in UTF-8: $string = XML_Util::reverseEntities( 'This string contains < & > as well as' . ' ä, ö, ß, à and ê', XML_UTIL_ENTITIES_HTML, 'UTF-8' );
string | $string | string where XML special chars should be replaced |
int | $replaceEntities | setting for entities in attribute values (one of XML_UTIL_ENTITIES_XML, XML_UTIL_ENTITIES_XML_REQUIRED, XML_UTIL_ENTITIES_HTML) |
string | $encoding | encoding value (if any)... must be a valid encoding as determined by the html_entity_decode() function |
Definition at line 245 of file Util.php.
References XML_UTIL_ENTITIES_HTML, XML_UTIL_ENTITIES_XML, and XML_UTIL_ENTITIES_XML_REQUIRED.
|
static |
split qualified name and return namespace and local part
require_once 'XML/Util.php';
// split qualified tag $parts = XML_Util::splitQualifiedName('xslt:stylesheet');
the returned array will contain two elements:
array( 'namespace' => 'xslt', 'localPart' => 'stylesheet' );
string | $qname | qualified tag name |
string | $defaultNs | default namespace (optional) |
Definition at line 829 of file Util.php.
Referenced by createStartElement(), and createTagFromArray().