[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-soap
Subject:    Re: [SOAP] xsd:choice maxOccurs=unbounded, and element order
From:       83.12.224.2
Date:       2007-06-13 12:27:09
Message-ID: op.ttu0vjc7jwfyhp () asus-ms ! paylane ! local
[Download RAW message or body]

Actually, depending on XML structure to preserve order is dangerous. As  
you can see, even if order in XML is OK, some part of processing (in this  
case PHP) can mess it up. Generally, it is understood that XML does NOT  
preserve order by itself.

To preserve order assign unique ID to each element. It is also (IMO) a  
good idea to use single 'word' element type instead of several types. E.g:

<xsd:complexType name='containertype'>
   <xsd:sequence maxOccurs='unbounded'>
     <xsd:element name='word' type='word'/>
   </xsd:choice>
</xsd:complexType>

<xsd:complexType name='word'>
   <xsd:element name='id' type='xsd:positiveInteger'/>
   <xsd:element name='type'>
     <xsd:simpleContent>
       <xsd:restriction base='xsd:string'>
         <xsd:enumeration value='noun'/>
         <xsd:enumeration value='verb'/>
         ....
        </xsd:restriction>
     </xsd:simpleContent>
   </xsd:element>
   <xsd:element name='value' type='xsd:string'/>
</xsd:complexType>


This describes such XML:

<container>
   <word>
     <id>1</id>
     <type>noun</type>
     <value>John</value>
   </word>
   <word>
     <id>2</id>
     <type>verb</type>
     <value>has</value>
   </word>
   <word>
     <id>3</id>
     <type>noun</type>
     <value>kittens</value>
   </word>
</container>

Creating and iterating on such structure in PHP shouldn't be overly  
difficult.

Of course you may choose to use attributes instead of elements if you  
prefer to (I do not :-P )
'word' type can also be made abstract and extended if nouns or verbs  
require additional info to be sent.

-- 
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic