Andrew's Web Libraries (AWL)
XMLDocument Class Reference

Public Member Functions

 __construct ( $namespaces=null)
 
 AddNamespace ( $namespace, $prefix=null)
 
 DefaultNamespace ()
 
 GetXmlNsArray ()
 
 Tag ( $in_tag, $namespace=null, $prefix=null)
 
 NSElement (&$element, $in_tag, $content=false, $attributes=false, $namespace=null)
 
 DAVElement (&$element, $tag, $content=false, $attributes=false)
 
 CalDAVElement (&$element, $tag, $content=false, $attributes=false)
 
 CardDAVElement (&$element, $tag, $content=false, $attributes=false)
 
 CalendarserverElement (&$element, $tag, $content=false, $attributes=false)
 
 NewXMLElement ( $in_tag, $content=false, $attributes=false, $xmlns=null)
 
 Render ( $root, $content=false, $attributes=false, $xmlns=null)
 
 href ($url)
 

Static Public Attributes

static $ns_dav = 'DAV:'
 
static $ns_caldav = 'urn:ietf:params:xml:ns:caldav'
 
static $ns_carddav = 'urn:ietf:params:xml:ns:carddav'
 
static $ns_calendarserver = 'http://calendarserver.org/ns/'
 

Private Attributes

 $namespaces
 
 $prefixes
 
 $root
 

Detailed Description

Definition at line 20 of file XMLDocument.php.

Constructor & Destructor Documentation

◆ __construct()

XMLDocument::__construct (   $namespaces = null)

Simple XMLDocument constructor

Parameters
array$namespacesAn array of 'namespace' => 'prefix' pairs, where the prefix is used as a short form for the namespace.

Definition at line 48 of file XMLDocument.php.

Member Function Documentation

◆ AddNamespace()

XMLDocument::AddNamespace (   $namespace,
  $prefix = null 
)

Add a new namespace to the document, optionally specifying it's short prefix

Parameters
string$namespaceThe full namespace name to be added
string$prefixAn optional short form for the namespace.

Definition at line 66 of file XMLDocument.php.

◆ CalDAVElement()

XMLDocument::CalDAVElement ( $element,
  $tag,
  $content = false,
  $attributes = false 
)

Special helper for tags in the urn:ietf:params:xml:ns:caldav namespace.

Parameters
object$elementThe tag we are adding a new namespaced element to
string$tagThe tag name
mixed$contentThe content of the tag
array$attributesAn array of key/value pairs of attributes.

Definition at line 225 of file XMLDocument.php.

◆ CalendarserverElement()

XMLDocument::CalendarserverElement ( $element,
  $tag,
  $content = false,
  $attributes = false 
)

Special helper for tags in the http://calendarserver.org/ns/ namespace.

Parameters
object$elementThe tag we are adding a new namespaced element to
string$tagThe tag name
mixed$contentThe content of the tag
array$attributesAn array of key/value pairs of attributes.

Definition at line 253 of file XMLDocument.php.

◆ CardDAVElement()

XMLDocument::CardDAVElement ( $element,
  $tag,
  $content = false,
  $attributes = false 
)

Special helper for tags in the urn:ietf:params:xml:ns:carddav namespace.

Parameters
object$elementThe tag we are adding a new namespaced element to
string$tagThe tag name
mixed$contentThe content of the tag
array$attributesAn array of key/value pairs of attributes.

Definition at line 239 of file XMLDocument.php.

◆ DAVElement()

XMLDocument::DAVElement ( $element,
  $tag,
  $content = false,
  $attributes = false 
)

Special helper for tags in the DAV: namespace.

Parameters
object$elementThe tag we are adding a new namespaced element to
string$tagThe tag name
mixed$contentThe content of the tag
array$attributesAn array of key/value pairs of attributes.

Definition at line 212 of file XMLDocument.php.

◆ DefaultNamespace()

XMLDocument::DefaultNamespace ( )

Return the default namespace for this document

Definition at line 111 of file XMLDocument.php.

◆ GetXmlNsArray()

XMLDocument::GetXmlNsArray ( )

Return a tag with namespace stripped and replaced with a short form, and the ns added to the document.

Definition at line 124 of file XMLDocument.php.

◆ href()

XMLDocument::href (   $url)

Return a DAV::href XML element, or an array of them

Parameters
mixed$urlThe URL (or array of URLs) to be wrapped in DAV::href tags
Returns
XMLElement The newly created XMLElement object.

Definition at line 315 of file XMLDocument.php.

◆ NewXMLElement()

XMLDocument::NewXMLElement (   $in_tag,
  $content = false,
  $attributes = false,
  $xmlns = null 
)
Parameters
string$in_tagThe tag name of the new element, possibly namespaced
mixed$contentEither a string of content, or an array of sub-elements
array$attributesAn array of attribute name/value pairs
array$xmlnsAn XML namespace specifier

Definition at line 265 of file XMLDocument.php.

◆ NSElement()

XMLDocument::NSElement ( $element,
  $in_tag,
  $content = false,
  $attributes = false,
  $namespace = null 
)

Special helper for namespaced tags.

Parameters
object$elementThe tag we are adding a new namespaced element to
string$tagThe tag name, possibly prefixed with the namespace
mixed$contentThe content of the tag
array$attributesAn array of key/value pairs of attributes.
string$namespaceThe namespace for the tag

Definition at line 184 of file XMLDocument.php.

◆ Render()

XMLDocument::Render (   $root,
  $content = false,
  $attributes = false,
  $xmlns = null 
)

Render the document tree into (nicely formatted) XML

Parameters
mixed$rootA root XMLElement or a tagname to create one with the remaining parameters.
mixed$contentEither a string of content, or an array of sub-elements
array$attributesAn array of attribute name/value pairs
array$xmlnsAn XML namespace specifier
Returns
A rendered namespaced XML document.

They handed us a pre-existing object. We'll just use it...

We got a tag name, so we need to create the root element

Add our namespace attributes here.

And render...

Definition at line 288 of file XMLDocument.php.

◆ Tag()

XMLDocument::Tag (   $in_tag,
  $namespace = null,
  $prefix = null 
)

Return a tag with namespace stripped and replaced with a short form, and the ns added to the document.

Parameters
string$in_tagThe tag we want a namespace prefix on.
string$namespaceThe namespace we want it in (which will be parsed from $in_tag if not present
string$prefixThe prefix we would like to use. Leave it out and one will be assigned.
Returns
string The tag with a namespace prefix consistent with previous tags in this namespace.

Definition at line 144 of file XMLDocument.php.

Member Data Documentation

◆ $namespaces

XMLDocument::$namespaces
private

Definition at line 29 of file XMLDocument.php.

◆ $ns_caldav

XMLDocument::$ns_caldav = 'urn:ietf:params:xml:ns:caldav'
static

Definition at line 170 of file XMLDocument.php.

◆ $ns_calendarserver

XMLDocument::$ns_calendarserver = 'http://calendarserver.org/ns/'
static

Definition at line 172 of file XMLDocument.php.

◆ $ns_carddav

XMLDocument::$ns_carddav = 'urn:ietf:params:xml:ns:carddav'
static

Definition at line 171 of file XMLDocument.php.

◆ $ns_dav

XMLDocument::$ns_dav = 'DAV:'
static

Definition at line 169 of file XMLDocument.php.

◆ $prefixes

XMLDocument::$prefixes
private

Definition at line 35 of file XMLDocument.php.

◆ $root

XMLDocument::$root
private

Definition at line 41 of file XMLDocument.php.


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