#41490 [NEW]: xsd:choice with maxOccurs="unbounded" does not preserve element order
| From: | simon at highlyillogical dot org | Date: | Thu, 24 May 2007 13:36:14 +0000 |
| Subject: | #41490 [NEW]: xsd:choice with maxOccurs="unbounded" does not preserve element order | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-112995@lists.php.net to get a copy of this message | ||
From: simon at highlyillogical dot org
Operating system: Windows/Linux
PHP version: 5.2.2
PHP Bug Type: SOAP related
Bug description: xsd:choice with maxOccurs="unbounded" does not preserve element order
Description:
------------
When the PHP soap client parses a SOAP response that contains multiple
recurrences of an <xsd:choice maxOccurs="unbounded"> element, the ordering
of elements can be lost, as the results are grouped by element type.
For example, take the following complex type:
<xsd:complexType name="sentence">
<xsd:choice maxOccurs="unbounded">
<xsd element name="noun" type="xsd:string" />
<xsd element name="verb" type="xsd:string" />
<xsd element name="other" type="xsd:string" />
</xsd:choice>
</xsd:type>
This type can describe a sentence, with one element per word. An example
sentence might be:
<sentence>
<other>The</other>
<noun>cat</noun>
<other>is</other>
<verb>playing</verb>
<other>with</other>
<noun>string</noun>
</sentence>
When PHP parses this, it groups the elements by type. Thus, a sentence
which reads "The cat is playing with string", is mangled to read "cat
string playing The is with"
I've posted a wsdl to demonstrate the problem at:
http://zx81.highlyillogical.org/~simon/phpbugtest/phpbugtest.wsdl
A valid XML response similar to the case above is at:
http://zx81.highlyillogical.org/~simon/phpbugtest/bugtest.xml
To reproduce the problem, simply call the bugtest operation on the above
wsdl. It will always return the above xml response.
Reproduce code:
---------------
$client = new SoapClient (
"http://zx81.highlyillogical.org/~simon/phpbugtest/phpbugtest.wsdl"
) ;
// we're just hitting an XML file, so we don't care about the input
$result = $client->bugtest ( ) ;
var_dump ( $result ) ;
Expected result:
----------------
An output with the resulting objects are presented in the order in which
they occurred in the document.
Actual result:
--------------
object(stdClass)#2 (3) {
["noun"]=>
array(2) {
[0]=>
string(3) "cat"
[1]=>
string(6) "string"
}
["verb"]=>
string(7) "playing"
["other"]=>
array(3) {
[0]=>
string(3) "The"
[1]=>
string(2) "is"
[2]=>
string(4) "with"
}
}
--
Edit bug report at http://bugs.php.net/?id=41490&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41490&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41490&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41490&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41490&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=41490&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=41490&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=41490&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=41490&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=41490&r=support
Expected behavior: http://bugs.php.net/fix.php?id=41490&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=41490&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=41490&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41490&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41490&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41490&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=41490&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=41490&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=41490&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=41490&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=41490&r=mysqlcfg