Browse files

Rename QName::ns property to QName::prefix.

git-svn-id: http://svn.php.net/repository/pear/packages/SOAP/trunk@265559 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent a5d8e0c commit 84d63b3357be002a7fb48ddb30df9d89b9b53775 Jan Schneider committed Aug 27, 2008
Showing with 42 additions and 53 deletions.
  1. +6 −8 Base.php
  2. +2 −2 Client.php
  3. +7 −7 Parser.php
  4. +14 −14 WSDL.php
  5. +3 −2 package.xml
  6. +5 −10 test/qnames_1.phpt
  7. +5 −10 test/qnames_2.phpt
View
14 Base.php
@@ -67,7 +67,6 @@
*/
class SOAP_Base_Object extends PEAR
{
-
/**
* Supported encodings, limited by XML extension.
*
@@ -790,7 +789,7 @@ function _decode($soapval)
if ($isstruct) {
if ($this->_wsdl) {
// Get this child's WSDL information.
- // /$soapval->ns/$soapval->type/$item->ns/$item->name
+ // /$soapval->prefix/$soapval->type/$item->prefix/$item->name
$child_type = $this->_wsdl->getComplexTypeChildType(
$soapval->namespace,
$soapval->name,
@@ -1098,7 +1097,7 @@ function setTypeTranslation($type, $class = null)
class QName
{
var $name = '';
- var $ns = '';
+ var $prefix = '';
var $namespace = '';
function QName($name, $namespace = '')
@@ -1109,9 +1108,8 @@ function QName($name, $namespace = '')
$this->namespace = $m[1];
} elseif (substr_count($name, ':') == 1) {
$s = explode(':', $name);
- $s = array_reverse($s);
- $this->name = $s[0];
- $this->ns = $s[1];
+ $this->prefix = $s[0];
+ $this->name = $s[1];
$this->namespace = $namespace;
} else {
$this->name = $name;
@@ -1133,8 +1131,8 @@ function fqn()
{
if ($this->namespace) {
return '{' . $this->namespace . '}' . $this->name;
- } elseif ($this->ns) {
- return $this->ns . ':' . $this->name;
+ } elseif ($this->prefix) {
+ return $this->prefix . ':' . $this->name;
}
return $this->name;
}
View
4 Client.php
@@ -605,8 +605,8 @@ function _generate($method, $params, $namespace = false,
// Type is likely a qname, split it apart, and get
// the type namespace from WSDL.
$qname = new QName($part['type']);
- if ($qname->ns) {
- $type_namespace = $this->_wsdl->namespaces[$qname->ns];
+ if ($qname->prefix) {
+ $type_namespace = $this->_wsdl->namespaces[$qname->prefix];
} elseif (isset($part['namespace'])) {
$type_namespace = $this->_wsdl->namespaces[$part['namespace']];
} else {
View
14 Parser.php
@@ -342,7 +342,7 @@ function _startElement($parser, $name, $attrs)
// If ns declarations, add to class level array of valid
// namespaces.
$kqn = new QName($key);
- if ($kqn->ns == 'xmlns') {
+ if ($kqn->prefix == 'xmlns') {
$prefix = $kqn->name;
if (in_array($value, $this->_XMLSchema)) {
@@ -353,7 +353,7 @@ function _startElement($parser, $name, $attrs)
// Set method namespace.
} elseif ($key == 'xmlns') {
- $qname->ns = $this->_getNamespacePrefix($value);
+ $qname->prefix = $this->_getNamespacePrefix($value);
$qname->namespace = $value;
} elseif ($kqn->name == 'actor') {
$this->message[$pos]['actor'] = $value;
@@ -364,7 +364,7 @@ function _startElement($parser, $name, $attrs)
} elseif ($kqn->name == 'type') {
$vqn = new QName($value);
$this->message[$pos]['type'] = $vqn->name;
- $this->message[$pos]['type_namespace'] = $this->_getNamespaceForPrefix($vqn->ns);
+ $this->message[$pos]['type_namespace'] = $this->_getNamespaceForPrefix($vqn->prefix);
// Should do something here with the namespace of specified
// type?
@@ -409,10 +409,10 @@ function _startElement($parser, $name, $attrs)
}
}
// See if namespace is defined in tag.
- if (isset($attrs['xmlns:' . $qname->ns])) {
- $namespace = $attrs['xmlns:' . $qname->ns];
- } elseif ($qname->ns && !$qname->namespace) {
- $namespace = $this->_getNamespaceForPrefix($qname->ns);
+ if (isset($attrs['xmlns:' . $qname->prefix])) {
+ $namespace = $attrs['xmlns:' . $qname->prefix];
+ } elseif ($qname->prefix && !$qname->namespace) {
+ $namespace = $this->_getNamespaceForPrefix($qname->prefix);
} else {
// Get namespace.
$namespace = $qname->namespace ? $qname->namespace : $this->default_namespace;
View
28 WSDL.php
@@ -1199,8 +1199,8 @@ function startElement($parser, $name, $attrs)
{
// Get element prefix.
$qname = new QName($name);
- if ($qname->ns) {
- $ns = $qname->ns;
+ if ($qname->prefix) {
+ $ns = $qname->prefix;
if ($ns && ((!$this->tns && strcasecmp($qname->name, 'definitions') == 0) || $ns == $this->tns)) {
$name = $qname->name;
}
@@ -1248,7 +1248,7 @@ function startElement($parser, $name, $attrs)
if (array_key_exists('base', $attrs)) {
$qn = new QName($attrs['base']);
$this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] = $qn->name;
- $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['namespace'] = $qn->ns;
+ $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['namespace'] = $qn->prefix;
} else {
$this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] = 'Struct';
}
@@ -1262,8 +1262,8 @@ function startElement($parser, $name, $attrs)
if (isset($attrs['type'])) {
$qn = new QName($attrs['type']);
$attrs['type'] = $qn->name;
- if ($qn->ns && array_key_exists($qn->ns, $this->wsdl->namespaces)) {
- $attrs['namespace'] = $qn->ns;
+ if ($qn->prefix && array_key_exists($qn->prefix, $this->wsdl->namespaces)) {
+ $attrs['namespace'] = $qn->prefix;
}
}
@@ -1361,7 +1361,7 @@ function startElement($parser, $name, $attrs)
if ($q->name == 'arrayType') {
$this->wsdl->complexTypes[$this->schema][$this->currentComplexType][$q->name] = $vq->name. $vq->arrayInfo;
$this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['type'] = 'Array';
- $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['namespace'] = $vq->ns;
+ $this->wsdl->complexTypes[$this->schema][$this->currentComplexType]['namespace'] = $vq->prefix;
} else {
$this->wsdl->complexTypes[$this->schema][$this->currentComplexType][$q->name] = $vq->name;
}
@@ -1388,7 +1388,7 @@ function startElement($parser, $name, $attrs)
}
if ($qn) {
$attrs['type'] = $qn->name;
- $attrs['namespace'] = $qn->ns;
+ $attrs['namespace'] = $qn->prefix;
}
$this->wsdl->messages[$this->currentMessage][$attrs['name']] = $attrs;
// error in wsdl
@@ -1425,7 +1425,7 @@ function startElement($parser, $name, $attrs)
if (array_key_exists('message', $attrs)) {
$qn = new QName($attrs['message']);
$this->wsdl->portTypes[$this->currentPortType][$this->currentOperation][$name]['message'] = $qn->name;
- $this->wsdl->portTypes[$this->currentPortType][$this->currentOperation][$name]['namespace'] = $qn->ns;
+ $this->wsdl->portTypes[$this->currentPortType][$this->currentOperation][$name]['namespace'] = $qn->prefix;
}
}
break;
@@ -1439,7 +1439,7 @@ function startElement($parser, $name, $attrs)
break;
case 'binding':
- $ns = $qname->ns ? $this->wsdl->namespaces[$qname->ns] : SCHEMA_WSDL;
+ $ns = $qname->prefix ? $this->wsdl->namespaces[$qname->prefix] : SCHEMA_WSDL;
switch ($ns) {
case SCHEMA_SOAP:
case SCHEMA_SOAP12:
@@ -1626,7 +1626,7 @@ function startElement($parser, $name, $attrs)
break;
case 'service':
- $ns = $qname->ns ? $this->wsdl->namespaces[$qname->ns] : SCHEMA_WSDL;
+ $ns = $qname->prefix ? $this->wsdl->namespaces[$qname->prefix] : SCHEMA_WSDL;
switch ($qname->name) {
case 'port':
@@ -1636,13 +1636,13 @@ function startElement($parser, $name, $attrs)
// XXX hack to deal with binding namespaces
$qn = new QName($attrs['binding']);
$this->wsdl->services[$this->currentService]['ports'][$this->currentPort]['binding'] = $qn->name;
- $this->wsdl->services[$this->currentService]['ports'][$this->currentPort]['namespace'] = $qn->ns;
+ $this->wsdl->services[$this->currentService]['ports'][$this->currentPort]['namespace'] = $qn->prefix;
break;
case 'address':
$this->wsdl->services[$this->currentService]['ports'][$this->currentPort]['address'] = $attrs;
// what TYPE of port is it? SOAP or HTTP?
- $ns = $qname->ns ? $this->wsdl->namespaces[$qname->ns] : SCHEMA_WSDL;
+ $ns = $qname->prefix ? $this->wsdl->namespaces[$qname->prefix] : SCHEMA_WSDL;
switch ($ns) {
case SCHEMA_WSDL_HTTP:
$this->wsdl->services[$this->currentService]['ports'][$this->currentPort]['type']='http';
@@ -1736,14 +1736,14 @@ function startElement($parser, $name, $attrs)
case 'binding':
// sect 2.5 wsdl:binding attributes: name type
// children: wsdl:operation soap:binding http:binding
- if ($qname->ns && $qname->ns != $this->tns) {
+ if ($qname->prefix && $qname->prefix != $this->tns) {
break;
}
$this->status = 'binding';
$this->currentBinding = $attrs['name'];
$qn = new QName($attrs['type']);
$this->wsdl->bindings[$this->currentBinding]['type'] = $qn->name;
- $this->wsdl->bindings[$this->currentBinding]['namespace'] = $qn->ns;
+ $this->wsdl->bindings[$this->currentBinding]['namespace'] = $qn->prefix;
break;
case 'service':
View
5 package.xml
@@ -39,15 +39,16 @@ http://pear.php.net/dtd/package-2.0.xsd">
</lead>
<date>2008-12-31</date>
<version>
- <release>0.12.1</release>
- <api>0.12.0</api>
+ <release>0.13.0</release>
+ <api>0.13.0</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
<license uri="http://www.php.net/license">PHP License</license>
<notes>* Add support for XML Schema include statements.
+* Rename QName::ns property to QName::prefix.
</notes>
<contents>
<dir baseinstalldir="SOAP" name="/">
View
15 test/qnames_1.phpt
@@ -1,18 +1,13 @@
--TEST--
-QNames : Standard QName
+QNames: Standard QName
--FILE--
<?php
require_once 'SOAP/Base.php';
require_once dirname(__FILE__) . '/test.utility.php';
-$qname = &new QName('ns:elementName');
-$val = array('name' => $qname->name, 'ns' => $qname->ns);
-var_dump($val);
+$qname = new QName('ns:elementName');
+var_dump($qname->name, $qname->prefix);
?>
--EXPECT--
-array(2) {
- ["name"]=>
- string(11) "elementName"
- ["ns"]=>
- string(2) "ns"
-}
+string(11) "elementName"
+string(2) "ns"
View
15 test/qnames_2.phpt
@@ -1,18 +1,13 @@
--TEST--
-QNames : URN QName
+QNames: URN QName
--FILE--
<?php
require_once 'SOAP/Base.php';
require_once dirname(__FILE__) . '/test.utility.php';
-$qname = &new QName('urn:some:api:bar');
-$val = array('name' => $qname->name, 'ns' => $qname->ns);
-var_dump($val);
+$qname = new QName('urn:some:api:bar');
+var_dump($qname->name, $qname->prefix);
?>
--EXPECT--
-array(2) {
- ["name"]=>
- string(16) "urn:some:api:bar"
- ["ns"]=>
- string(0) ""
-}
+string(16) "urn:some:api:bar"
+string(0) ""

0 comments on commit 84d63b3

Please sign in to comment.