当前位置: 首页>>代码示例>>PHP>>正文


PHP XML_Util::splitQualifiedName方法代码示例

本文整理汇总了PHP中XML_Util::splitQualifiedName方法的典型用法代码示例。如果您正苦于以下问题:PHP XML_Util::splitQualifiedName方法的具体用法?PHP XML_Util::splitQualifiedName怎么用?PHP XML_Util::splitQualifiedName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XML_Util的用法示例。


在下文中一共展示了XML_Util::splitQualifiedName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: name

print "</pre>";
print "\n<br>\n";
/**
 * splitting a qualified tag name (no namespace)
 */
print "splitting qualified tag name (no namespace):<br>\n";
print "<pre>";
print_r(XML_Util::splitQualifiedName("foo"));
print "</pre>";
print "\n<br>\n";
/**
 * splitting a qualified tag name (no namespace, but default namespace specified)
 */
print "splitting qualified tag name (no namespace, but default namespace specified):<br>\n";
print "<pre>";
print_r(XML_Util::splitQualifiedName("foo", "bar"));
print "</pre>";
print "\n<br>\n";
/**
 * verifying XML names
 */
print "verifying 'My private tag':<br>\n";
print "<pre>";
print_r(XML_Util::isValidname('My Private Tag'));
print "</pre>";
print "\n<br><br>\n";
print "verifying '-MyTag':<br>\n";
print "<pre>";
print_r(XML_Util::isValidname('-MyTag'));
print "</pre>";
print "\n<br><br>\n";
开发者ID:bantudevelopment,项目名称:polysmis,代码行数:31,代码来源:example.php

示例2: createStartElement

 /**
  * create a start element
  *
  * <code>
  * require_once 'XML/Util.php';
  * 
  * // create an XML start element:
  * $tag = XML_Util::createStartElement("myNs:myTag", array("foo" => "bar") ,"http://www.w3c.org/myNs#");
  * </code>
  *
  * @access   public
  * @static
  * @param    string  $qname             qualified tagname (including namespace)
  * @param    array   $attributes        array containg attributes
  * @param    string  $namespaceUri      URI of the namespace
  * @param    boolean $multiline         whether to create a multiline tag where each attribute gets written to a single line
  * @param    string  $indent            string used to indent attributes (_auto indents attributes so they start at the same column)
  * @param    string  $linebreak         string used for linebreaks
  * @return   string  $string            XML start element
  * @see      XML_Util::createEndElement(), XML_Util::createTag()
  */
 function createStartElement($qname, $attributes = array(), $namespaceUri = null, $multiline = false, $indent = '_auto', $linebreak = "\n")
 {
     // if no attributes hav been set, use empty attributes
     if (!isset($attributes) || !is_array($attributes)) {
         $attributes = array();
     }
     if ($namespaceUri != null) {
         $parts = XML_Util::splitQualifiedName($qname);
     }
     // check for multiline attributes
     if ($multiline === true) {
         if ($indent === "_auto") {
             $indent = str_repeat(" ", strlen($qname) + 2);
         }
     }
     if ($namespaceUri != null) {
         // is a namespace given
         if (isset($parts["namespace"]) && !empty($parts["namespace"])) {
             $attributes["xmlns:" . $parts["namespace"]] = $namespaceUri;
         } else {
             // define this Uri as the default namespace
             $attributes["xmlns"] = $namespaceUri;
         }
     }
     // create attribute list
     $attList = XML_Util::attributesToString($attributes, true, $multiline, $indent, $linebreak);
     $element = sprintf("<%s%s>", $qname, $attList);
     return $element;
 }
开发者ID:prometheus-ev,项目名称:promdilps,代码行数:50,代码来源:v2.php

示例3: name

print '</pre>';
print "\n<br>\n";
/**
 * splitting a qualified tag name (no namespace)
 */
print 'splitting qualified tag name (no namespace):<br>';
print '<pre>';
print_r(XML_Util::splitQualifiedName('foo'));
print '</pre>';
print "\n<br>\n";
/**
 * splitting a qualified tag name (no namespace, but default namespace specified)
 */
print 'splitting qualified tag name ' . '(no namespace, but default namespace specified):<br>';
print '<pre>';
print_r(XML_Util::splitQualifiedName('foo', 'bar'));
print '</pre>';
print "\n<br>\n";
/**
 * verifying XML names
 */
print 'verifying \'My private tag\':<br>';
print '<pre>';
print_r(XML_Util::isValidname('My Private Tag'));
print '</pre>';
print "\n<br><br>\n";
print 'verifying \'-MyTag\':<br>';
print '<pre>';
print_r(XML_Util::isValidname('-MyTag'));
print '</pre>';
print "\n<br><br>\n";
开发者ID:quangbt2005,项目名称:vhost-kis,代码行数:31,代码来源:example.php

示例4: createTagFromArray

 /**
  * create a tag from an array
  * this method awaits an array in the following format
  * <pre>
  * array(
  *  "qname"        => $qname         // qualified name of the tag
  *  "namespace"    => $namespace     // namespace prefix (optional, if qname is specified or no namespace)
  *  "localpart"    => $localpart,    // local part of the tagname (optional, if qname is specified)
  *  "attributes"   => array(),       // array containing all attributes (optional)
  *  "content"      => $content,      // tag content (optional)
  *  "namespaceUri" => $namespaceUri  // namespaceUri for the given namespace (optional)
  *   )
  * </pre>
  *
  * <code>
  * 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 = PEAR_PackageFile_Generator_v2_XML_Util::createTagFromArray($tag);
  * </code>
  *
  * @access   public
  * @static
  * @param    array   $tag               tag definition
  * @param    integer $replaceEntities   whether to replace XML special chars in content, embedd it in a CData section or none of both
  * @param    boolean $multiline         whether to create a multiline tag where each attribute gets written to a single line
  * @param    string  $indent            string used to indent attributes (_auto indents attributes so they start at the same column)
  * @param    string  $linebreak         string used for linebreaks
  * @return   string  $string            XML tag
  * @see      PEAR_PackageFile_Generator_v2_XML_Util::createTag()
  * @uses     XML_Util::attributesToString() to serialize the attributes of the tag
  * @uses     XML_Util::splitQualifiedName() to get local part and namespace of a qualified name
  */
 function createTagFromArray($tag, $replaceEntities = PEAR_PackageFile_Generator_v2_XML_Util_REPLACE_ENTITIES, $multiline = false, $indent = "_auto", $linebreak = "\n", $encoding = PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML)
 {
     if (isset($tag["content"]) && !is_scalar($tag["content"])) {
         return XML_Util::raiseError("Supplied non-scalar value as tag content", PEAR_PackageFile_Generator_v2_XML_Util_ERROR_NON_SCALAR_CONTENT);
     }
     if (!isset($tag['qname']) && !isset($tag['localPart'])) {
         return XML_Util::raiseError('You must either supply a qualified name (qname) or local tag name (localPart).', PEAR_PackageFile_Generator_v2_XML_Util_ERROR_NO_TAG_NAME);
     }
     // if no attributes hav been set, use empty attributes
     if (!isset($tag["attributes"]) || !is_array($tag["attributes"])) {
         $tag["attributes"] = array();
     }
     // qualified name is not given
     if (!isset($tag["qname"])) {
         // check for namespace
         if (isset($tag["namespace"]) && !empty($tag["namespace"])) {
             $tag["qname"] = $tag["namespace"] . ":" . $tag["localPart"];
         } else {
             $tag["qname"] = $tag["localPart"];
         }
         // namespace URI is set, but no namespace
     } elseif (isset($tag["namespaceUri"]) && !isset($tag["namespace"])) {
         $parts = XML_Util::splitQualifiedName($tag["qname"]);
         $tag["localPart"] = $parts["localPart"];
         if (isset($parts["namespace"])) {
             $tag["namespace"] = $parts["namespace"];
         }
     }
     if (isset($tag["namespaceUri"]) && !empty($tag["namespaceUri"])) {
         // is a namespace given
         if (isset($tag["namespace"]) && !empty($tag["namespace"])) {
             $tag["attributes"]["xmlns:" . $tag["namespace"]] = $tag["namespaceUri"];
         } else {
             // define this Uri as the default namespace
             $tag["attributes"]["xmlns"] = $tag["namespaceUri"];
         }
     }
     // check for multiline attributes
     if ($multiline === true) {
         if ($indent === "_auto") {
             $indent = str_repeat(" ", strlen($tag["qname"]) + 2);
         }
     }
     // create attribute list
     $attList = XML_Util::attributesToString($tag["attributes"], true, $multiline, $indent, $linebreak);
     if (!isset($tag["content"]) || (string) $tag["content"] == '') {
         $tag = sprintf("<%s%s />", $tag["qname"], $attList);
     } else {
         if ($replaceEntities == PEAR_PackageFile_Generator_v2_XML_Util_REPLACE_ENTITIES) {
             $tag["content"] = PEAR_PackageFile_Generator_v2_XML_Util::replaceEntities($tag["content"], $encoding);
         } elseif ($replaceEntities == PEAR_PackageFile_Generator_v2_XML_Util_CDATA_SECTION) {
             $tag["content"] = XML_Util::createCDataSection($tag["content"]);
         }
         $tag = sprintf("<%s%s>%s</%s>", $tag["qname"], $attList, $tag["content"], $tag["qname"]);
     }
     return $tag;
 }
开发者ID:kaz6120,项目名称:Loggix,代码行数:96,代码来源:v2.php

示例5: startTag

 /**
  * Start tag handler
  *
  * @param resource $parser
  * 		reference to parser resource
  * @param string $fullname
  * 		element name
  * @param array $attrs
  * 		array of attributes
  * @return none
  */
 function startTag($parser, $fullname, $attrs)
 {
     $nSpaces = array();
     foreach ($attrs as $atn => $atv) {
         $a = XML_Util::splitQualifiedName($atn);
         $atns = $a['namespace'];
         $atnm = $a['localPart'];
         unset($attrs[$atn]);
         if ($atns == 'xmlns') {
             $nSpaces[$atnm] = $atv;
         } else {
             if ($atns == NULL && $atnm == 'xmlns') {
                 $nSpaces[''] = $atv;
             } else {
                 $attrs[$atn] = new XmlAttrib($atns, $atnm, $atv);
             }
         }
     }
     $el = new XmlElement($fullname, $attrs, $nSpaces);
     array_push($this->stack, $el);
 }
开发者ID:romansavrulin,项目名称:Airtime,代码行数:32,代码来源:XmlParser.php

示例6: _endElement

 /**
  * SAX callback for 'endElement' event.
  *
  * @param  resource
  * @param  string
  * @access private
  */
 function _endElement($parser, $element)
 {
     $cdata = $this->_cdataStack[$this->_level];
     $element = $this->canonicalize($element);
     $qElement = XML_Util::splitQualifiedName($element, '&MAIN');
     $process = $this->_lastProcessed != $element;
     $recursion = FALSE;
     if ($process && isset($this->_callbackRegistry->overloadedNamespaces[$qElement['namespace']]['active'])) {
         // The event is handled by a callback
         // that is registered for this namespace.
         $result = $this->_callbackRegistry->overloadedNamespaces[$qElement['namespace']]['object']->endElement($qElement['localPart'], $cdata);
         if (is_array($result)) {
             $cdata =& $result[0];
             $reparse = $result[1];
         } else {
             $cdata =& $result;
             $reparse = TRUE;
         }
         $recursion = $reparse && isset($this->_elementStack[$this->_level - 1]) && $this->_callbackRegistry->overloadedNamespaces[$qElement['namespace']]['recursiveOperation'];
     } else {
         // No callback was registered for this element's
         // closing tag, copy it.
         $cdata .= '</' . $element . '>';
     }
     if ($recursion) {
         // Recursively process this transformation's result.
         if ($this->_checkDebug('&RECURSE')) {
             $this->sendMessage(sprintf('start recursion[%d]: %s', $this->_level, $cdata));
         }
         $transformer = new XML_Transformer(array('callbackRegistry' => &$this->_callbackRegistry, 'caseFolding' => $this->_caseFolding, 'caseFoldingTo' => $this->_caseFoldingTo, 'lastProcessed' => $element));
         $cdata = substr($transformer->transform("<_>{$cdata}</_>"), 3, -4);
         if ($this->_checkDebug('&RECURSE')) {
             $this->sendMessage(sprintf('end recursion[%d]: %s', $this->_level, $cdata));
         }
     }
     if ($this->_checkDebug($element)) {
         $this->sendMessage(sprintf('endElement[%d]: %s (with cdata=%s)', $this->_level, $element, $this->_cdataStack[$this->_level]));
     }
     // Move result of this transformation step to
     // the parent's CDATA section.
     $this->_cdataStack[--$this->_level] .= $cdata;
 }
开发者ID:Esleelkartea,项目名称:kz-adeada-talleres-electricos-,代码行数:49,代码来源:Transformer.php


注:本文中的XML_Util::splitQualifiedName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。