ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
XMLSchema Class Reference

parses an XML Schema, allows access to it's data, other utility methods no validation... yet. More...

+ Inheritance diagram for XMLSchema:
+ Collaboration diagram for XMLSchema:

Public Member Functions

 XMLSchema ($schema='', $xml='', $namespaces=array())
 constructor More...
 
 parseFile ($xml, $type)
 parse an XML file More...
 
 parseString ($xml, $type)
 
 schemaStartElement ($parser, $name, $attrs)
 start-element handler More...
 
 schemaEndElement ($parser, $name)
 end-element handler More...
 
 schemaCharacterData ($parser, $data)
 element content handler More...
 
 serializeSchema ()
 serialize the schema More...
 
 xdebug ($string)
 adds debug data to the clas level debug string More...
 
 getPHPType ($type, $ns)
 get the PHP type of a user defined type in the schema PHP type is kind of a misnomer since it actually returns 'struct' for assoc. More...
 
 getTypeDef ($type)
 returns an array of information about a given type returns false if no type exists by the given name More...
 
 serializeTypeDef ($type)
 returns a sample serialization of a given type, or false if no type by the given name More...
 
 typeToForm ($name, $type)
 returns HTML form elements that allow a user to enter values for creating an instance of the given type. More...
 
 addComplexType ($name, $typeClass='complexType', $phpType='array', $compositor='', $restrictionBase='', $elements=array(), $attrs=array(), $arrayType='')
 adds a complex type to the schema More...
 
 addSimpleType ($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar')
 adds a simple type to the schema More...
 
- Public Member Functions inherited from nusoap_base
 debug ($string)
 adds debug data to the class level debug string More...
 
 expandEntities ($val)
 expands entities, e.g. More...
 
 getError ()
 returns error string if present More...
 
 setError ($str)
 sets error string More...
 
 isArraySimpleOrStruct ($val)
 detect if array is a simple array or a struct (associative array) More...
 
 serialize_val ($val, $name=false, $type=false, $name_ns=false, $type_ns=false, $attributes=false, $use='encoded')
 
 serializeEnvelope ($body, $headers=false, $namespaces=array(), $style='rpc', $use='encoded')
 serialize message More...
 
 formatDump ($str)
 
 contractQname ($qname)
 contracts a qualified name More...
 
 expandQname ($qname)
 expands a qualified name More...
 
 getLocalPart ($str)
 returns the local part of a prefixed string returns the original string, if not prefixed More...
 
 getPrefix ($str)
 returns the prefix part of a prefixed string returns false, if not prefixed More...
 
 getNamespaceFromPrefix ($prefix)
 pass it a prefix, it returns a namespace returns false if no namespace registered with the given prefix More...
 
 getPrefixFromNamespace ($ns)
 returns the prefix for a given namespace (or prefix) or false if no prefixes registered for the given namespace More...
 
 varDump ($data)
 
 nusoap_base ()
 constructor More...
 
 getGlobalDebugLevel ()
 gets the global debug level, which applies to future instances More...
 
 setGlobalDebugLevel ($level)
 sets the global debug level, which applies to future instances More...
 
 getDebugLevel ()
 gets the debug level for this instance More...
 
 setDebugLevel ($level)
 sets the debug level for this instance More...
 
 debug ($string)
 adds debug data to the instance debug string with formatting More...
 
 appendDebug ($string)
 adds debug data to the instance debug string without formatting More...
 
 clearDebug ()
 clears the current debug data for this instance More...
 
getDebug ()
 gets the current debug data for this instance More...
 
getDebugAsXMLComment ()
 gets the current debug data for this instance as an XML comment this may change the contents of the debug data More...
 
 expandEntities ($val)
 expands entities, e.g. More...
 
 getError ()
 returns error string if present More...
 
 setError ($str)
 sets error string More...
 
 isArraySimpleOrStruct ($val)
 detect if array is a simple array or a struct (associative array) More...
 
 serialize_val ($val, $name=false, $type=false, $name_ns=false, $type_ns=false, $attributes=false, $use='encoded', $soapval=false)
 
 serializeEnvelope ($body, $headers=false, $namespaces=array(), $style='rpc', $use='encoded', $encodingStyle='http://schemas.xmlsoap.org/soap/encoding/')
 serializes a message More...
 
 formatDump ($str)
 formats a string to be inserted into an HTML stream More...
 
 contractQname ($qname)
 contracts (changes namespace to prefix) a qualified name More...
 
 expandQname ($qname)
 expands (changes prefix to namespace) a qualified name More...
 
 getLocalPart ($str)
 returns the local part of a prefixed string returns the original string, if not prefixed More...
 
 getPrefix ($str)
 returns the prefix part of a prefixed string returns false, if not prefixed More...
 
 getNamespaceFromPrefix ($prefix)
 pass it a prefix, it returns a namespace More...
 
 getPrefixFromNamespace ($ns)
 returns the prefix for a given namespace (or prefix) or false if no prefixes registered for the given namespace More...
 
 getmicrotime ()
 returns the time in ODBC canonical form with microseconds More...
 
 varDump ($data)
 Returns a string with the output of var_dump. More...
 
 __toString ()
 represents the object as a string More...
 
- Public Member Functions inherited from nusoap_xmlschema
 nusoap_xmlschema ($schema='', $xml='', $namespaces=array())
 constructor More...
 
 parseFile ($xml, $type)
 parse an XML file More...
 
 parseString ($xml, $type)
 
 CreateTypeName ($ename)
 gets a type name for an unnamed type More...
 
 schemaStartElement ($parser, $name, $attrs)
 start-element handler More...
 
 schemaEndElement ($parser, $name)
 end-element handler More...
 
 schemaCharacterData ($parser, $data)
 element content handler More...
 
 serializeSchema ()
 serialize the schema More...
 
 xdebug ($string)
 adds debug data to the clas level debug string More...
 
 getPHPType ($type, $ns)
 get the PHP type of a user defined type in the schema PHP type is kind of a misnomer since it actually returns 'struct' for assoc. More...
 
 getTypeDef ($type)
 returns an associative array of information about a given type returns false if no type exists by the given name More...
 
 serializeTypeDef ($type)
 returns a sample serialization of a given type, or false if no type by the given name More...
 
 typeToForm ($name, $type)
 returns HTML form elements that allow a user to enter values for creating an instance of the given type. More...
 
 addComplexType ($name, $typeClass='complexType', $phpType='array', $compositor='', $restrictionBase='', $elements=array(), $attrs=array(), $arrayType='')
 adds a complex type to the schema More...
 
 addSimpleType ($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array())
 adds a simple type to the schema More...
 
 addElement ($attrs)
 adds an element to the schema More...
 

Data Fields

 $schema = ''
 
 $xml = ''
 
 $enclosingNamespaces
 
 $schemaInfo = array()
 
 $schemaTargetNamespace = ''
 
 $attributes = array()
 
 $complexTypes = array()
 
 $currentComplexType = false
 
 $elements = array()
 
 $currentElement = false
 
 $simpleTypes = array()
 
 $currentSimpleType = false
 
 $imports = array()
 
 $parser
 
 $position = 0
 
 $depth = 0
 
 $depth_array = array()
 
 $message = array()
 
 $defaultNamespace = array()
 
- Data Fields inherited from nusoap_base
 $title = 'NuSOAP'
 
 $version = '0.6.7'
 
 $revision = '$Revision$'
 
 $error_str = false
 Current error string (manipulated by getError/setError) More...
 
 $debug_str = ''
 Current debug string (manipulated by debug/appendDebug/clearDebug/getDebug/getDebugAsXMLComment) More...
 
 $charencoding = true
 
 $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'
 
 $soap_defencoding = 'UTF-8'
 
 $namespaces
 
 $usedNamespaces = array()
 
 $typemap
 
 $xmlEntities
 
 $debugLevel
 
- Data Fields inherited from nusoap_xmlschema
 $schema = ''
 
 $xml = ''
 
 $enclosingNamespaces
 
 $schemaInfo = array()
 
 $schemaTargetNamespace = ''
 
 $attributes = array()
 
 $complexTypes = array()
 
 $complexTypeStack = array()
 
 $currentComplexType = null
 
 $elements = array()
 
 $elementStack = array()
 
 $currentElement = null
 
 $simpleTypes = array()
 
 $simpleTypeStack = array()
 
 $currentSimpleType = null
 
 $imports = array()
 
 $parser
 
 $position = 0
 
 $depth = 0
 
 $depth_array = array()
 
 $message = array()
 
 $defaultNamespace = array()
 

Detailed Description

parses an XML Schema, allows access to it's data, other utility methods no validation... yet.

Backward compatibility.

very experimental and limited. As is discussed on XML-DEV, I'm one of the people that just doesn't have time to read the spec(s) thoroughly, and just have a couple of trusty tutorials I refer to :)

Author
Dietrich Ayala dietr.nosp@m.ich@.nosp@m.ganx4.nosp@m..com
Version
$Id$ @access public

Definition at line 734 of file nusoap.php.

Member Function Documentation

◆ addComplexType()

XMLSchema::addComplexType (   $name,
  $typeClass = 'complexType',
  $phpType = 'array',
  $compositor = '',
  $restrictionBase = '',
  $elements = array(),
  $attrs = array(),
  $arrayType = '' 
)

adds a complex type to the schema

example: array

addType( 'ArrayOfstring', 'complexType', 'array', '', 'SOAP-ENC:Array', array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'string[]'), 'xsd:string' );

example: PHP associative array ( SOAP Struct )

addType( 'SOAPStruct', 'complexType', 'struct', 'all', array('myVar'=> array('name'=>'myVar','type'=>'string') );

Parameters
name
typeClass(complexType|simpleType|attribute)
phpTypecurrently supported are array and struct (php assoc array)
compositor(all|sequence|choice)
restrictionBasenamespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
elements= array ( name = array(name=>'',type=>'') )
attrs= array( array( 'ref' => "http://schemas.xmlsoap.org/soap/encoding/:arrayType", "http://schemas.xmlsoap.org/wsdl/:arrayType" => "string[]" ) )
arrayTypenamespace:name (http://www.w3.org/2001/XMLSchema:string)

Reimplemented from nusoap_xmlschema.

Definition at line 1444 of file nusoap.php.

1444 {
1445 $this->complexTypes[$name] = array(
1446 'name' => $name,
1447 'typeClass' => $typeClass,
1448 'phpType' => $phpType,
1449 'compositor'=> $compositor,
1450 'restrictionBase' => $restrictionBase,
1451 'elements' => $elements,
1452 'attrs' => $attrs,
1453 'arrayType' => $arrayType
1454 );
1455
1456 $this->xdebug("addComplexType $name: " . $this->varDump($this->complexTypes[$name]));
1457 }
xdebug($string)
adds debug data to the clas level debug string
Definition: nusoap.php:1239
varDump($data)
Definition: nusoap.php:567

References $elements, nusoap_base\varDump(), and xdebug().

+ Here is the call graph for this function:

◆ addSimpleType()

XMLSchema::addSimpleType (   $name,
  $restrictionBase = '',
  $typeClass = 'simpleType',
  $phpType = 'scalar' 
)

adds a simple type to the schema

Parameters
name
restrictionBasenamespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
typeClass(simpleType)
phpType(scalar)
See also
xmlschema

Definition at line 1469 of file nusoap.php.

1469 {
1470 $this->simpleTypes[$name] = array(
1471 'name' => $name,
1472 'typeClass' => $typeClass,
1473 'phpType' => $phpType,
1474 'type' => $restrictionBase
1475 );
1476
1477 $this->xdebug("addSimpleType $name: " . $this->varDump($this->simpleTypes[$name]));
1478 }

References nusoap_base\varDump(), and xdebug().

+ Here is the call graph for this function:

◆ getPHPType()

XMLSchema::getPHPType (   $type,
  $ns 
)

get the PHP type of a user defined type in the schema PHP type is kind of a misnomer since it actually returns 'struct' for assoc.

arrays returns false if no type exists, or not w/ the given namespace else returns a string that is either a native php type, or 'struct'

Parameters
string$type,nameof defined type
string$ns,namespaceof type
Returns
mixed @access public

Reimplemented from nusoap_xmlschema.

Definition at line 1254 of file nusoap.php.

1254 {
1255 if(isset($this->typemap[$ns][$type])){
1256 //print "found type '$type' and ns $ns in typemap<br>";
1257 return $this->typemap[$ns][$type];
1258 } elseif(isset($this->complexTypes[$type])){
1259 //print "getting type '$type' and ns $ns from complexTypes array<br>";
1260 return $this->complexTypes[$type]['phpType'];
1261 }
1262 return false;
1263 }

◆ getTypeDef()

XMLSchema::getTypeDef (   $type)

returns an array of information about a given type returns false if no type exists by the given name

     typeDef = array(
     'elements' => array(), // refs to elements array
    'restrictionBase' => '',
    'phpType' => '',
    'order' => '(sequence|all)',
    'attrs' => array() // refs to attributes array
    )
Parameters
string
Returns
mixed @access public

Reimplemented from nusoap_xmlschema.

Definition at line 1281 of file nusoap.php.

1281 {
1282 //$this->debug("in getTypeDef for type $type");
1283 if(isset($this->complexTypes[$type])){
1284 $this->xdebug("in getTypeDef, found complexType $type");
1285 return $this->complexTypes[$type];
1286 } elseif(isset($this->simpleTypes[$type])){
1287 $this->xdebug("in getTypeDef, found simpleType $type");
1288 if (!isset($this->simpleTypes[$type]['phpType'])) {
1289 // get info for type to tack onto the simple type
1290 // TODO: can this ever really apply (i.e. what is a simpleType really?)
1291 $uqType = substr($this->simpleTypes[$type]['type'], strrpos($this->simpleTypes[$type]['type'], ':') + 1);
1292 $ns = substr($this->simpleTypes[$type]['type'], 0, strrpos($this->simpleTypes[$type]['type'], ':'));
1293 $etype = $this->getTypeDef($uqType);
1294 if ($etype) {
1295 if (isset($etype['phpType'])) {
1296 $this->simpleTypes[$type]['phpType'] = $etype['phpType'];
1297 }
1298 if (isset($etype['elements'])) {
1299 $this->simpleTypes[$type]['elements'] = $etype['elements'];
1300 }
1301 }
1302 }
1303 return $this->simpleTypes[$type];
1304 } elseif(isset($this->elements[$type])){
1305 $this->xdebug("in getTypeDef, found element $type");
1306 if (!isset($this->elements[$type]['phpType'])) {
1307 // get info for type to tack onto the element
1308 $uqType = substr($this->elements[$type]['type'], strrpos($this->elements[$type]['type'], ':') + 1);
1309 $ns = substr($this->elements[$type]['type'], 0, strrpos($this->elements[$type]['type'], ':'));
1310 $etype = $this->getTypeDef($uqType);
1311 if ($etype) {
1312 if (isset($etype['phpType'])) {
1313 $this->elements[$type]['phpType'] = $etype['phpType'];
1314 }
1315 if (isset($etype['elements'])) {
1316 $this->elements[$type]['elements'] = $etype['elements'];
1317 }
1318 } elseif ($ns == 'http://www.w3.org/2001/XMLSchema') {
1319 $this->elements[$type]['phpType'] = 'scalar';
1320 }
1321 }
1322 return $this->elements[$type];
1323 } elseif(isset($this->attributes[$type])){
1324 $this->xdebug("in getTypeDef, found attribute $type");
1325 return $this->attributes[$type];
1326 }
1327 $this->xdebug("in getTypeDef, did not find $type");
1328 return false;
1329 }
getTypeDef($type)
returns an array of information about a given type returns false if no type exists by the given name
Definition: nusoap.php:1281

References getTypeDef(), and xdebug().

Referenced by getTypeDef(), serializeTypeDef(), and typeToForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseFile()

XMLSchema::parseFile (   $xml,
  $type 
)

parse an XML file

Parameters
string$xml,path/URLto XML file
string$type,(schema| xml)
Returns
boolean @access public

Reimplemented from nusoap_xmlschema.

Definition at line 803 of file nusoap.php.

803 {
804 // parse xml file
805 if($xml != ""){
806 $xmlStr = @join("",@file($xml));
807 if($xmlStr == ""){
808 $msg = 'Error reading XML from '.$xml;
809 $this->setError($msg);
810 $this->debug($msg);
811 return false;
812 } else {
813 $this->debug("parsing $xml");
814 $this->parseString($xmlStr,$type);
815 $this->debug("done parsing $xml");
816 return true;
817 }
818 }
819 return false;
820 }
parseString($xml, $type)
Definition: nusoap.php:829
setError($str)
sets error string
Definition: nusoap.php:184
debug($string)
adds debug data to the class level debug string
Definition: nusoap.php:144

References $xml, nusoap_base\debug(), parseString(), and nusoap_base\setError().

Referenced by XMLSchema().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseString()

XMLSchema::parseString (   $xml,
  $type 
)
parse an XML string

@param    string $xml path or URL
Parameters
string$type,(schema|xml)@access private

Reimplemented from nusoap_xmlschema.

Definition at line 829 of file nusoap.php.

829 {
830 // parse xml string
831 if($xml != ""){
832
833 // Create an XML parser.
834 $this->parser = xml_parser_create();
835 // Set the options for parsing the XML data.
836 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
837
838 // Set the object for the parser.
839 xml_set_object($this->parser, $this);
840
841 // Set the element handlers for the parser.
842 if($type == "schema"){
843 xml_set_element_handler($this->parser, 'schemaStartElement','schemaEndElement');
844 xml_set_character_data_handler($this->parser,'schemaCharacterData');
845 } elseif($type == "xml"){
846 xml_set_element_handler($this->parser, 'xmlStartElement','xmlEndElement');
847 xml_set_character_data_handler($this->parser,'xmlCharacterData');
848 }
849
850 // Parse the XML file.
851 if(!xml_parse($this->parser,$xml,true)){
852 // Display an error message.
853 $errstr = sprintf('XML error parsing XML schema on line %d: %s',
854 xml_get_current_line_number($this->parser),
855 xml_error_string(xml_get_error_code($this->parser))
856 );
857 $this->debug($errstr);
858 $this->debug("XML payload:\n" . $xml);
859 $this->setError($errstr);
860 }
861
862 xml_parser_free($this->parser);
863 } else{
864 $this->debug('no xml passed to parseString()!!');
865 $this->setError('no xml passed to parseString()!!');
866 }
867 }

References $xml, nusoap_base\debug(), and nusoap_base\setError().

Referenced by parseFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ schemaCharacterData()

XMLSchema::schemaCharacterData (   $parser,
  $data 
)

element content handler

Parameters
string$parserXML parser object
string$dataelement content @access private

Reimplemented from nusoap_xmlschema.

Definition at line 1136 of file nusoap.php.

1136 {
1137 $pos = $this->depth_array[$this->depth - 1];
1138 $this->message[$pos]['cdata'] .= $data;
1139 }
$data

References $data.

◆ schemaEndElement()

XMLSchema::schemaEndElement (   $parser,
  $name 
)

end-element handler

Parameters
string$parserXML parser object
string$nameelement name @access private

Reimplemented from nusoap_xmlschema.

Definition at line 1109 of file nusoap.php.

1109 {
1110 // bring depth down a notch
1111 $this->depth--;
1112 // position of current element is equal to the last value left in depth_array for my depth
1113 if(isset($this->depth_array[$this->depth])){
1114 $pos = $this->depth_array[$this->depth];
1115 }
1116 // move on...
1117 if($name == 'complexType'){
1118 $this->currentComplexType = false;
1119 $this->currentElement = false;
1120 }
1121 if($name == 'element'){
1122 $this->currentElement = false;
1123 }
1124 if($name == 'simpleType'){
1125 $this->currentSimpleType = false;
1126 }
1127 }

References $depth.

◆ schemaStartElement()

XMLSchema::schemaStartElement (   $parser,
  $name,
  $attrs 
)

start-element handler

Parameters
string$parserXML parser object
string$nameelement name
string$attrsassociative array of attributes @access private

Reimplemented from nusoap_xmlschema.

Definition at line 877 of file nusoap.php.

877 {
878
879 // position in the total number of elements, starting from 0
880 $pos = $this->position++;
881 $depth = $this->depth++;
882 // set self as current value for this depth
883 $this->depth_array[$depth] = $pos;
884 $this->message[$pos] = array('cdata' => '');
885 if ($depth > 0) {
886 $this->defaultNamespace[$pos] = $this->defaultNamespace[$this->depth_array[$depth - 1]];
887 } else {
888 $this->defaultNamespace[$pos] = false;
889 }
890
891 // get element prefix
892 if($prefix = $this->getPrefix($name)){
893 // get unqualified name
894 $name = $this->getLocalPart($name);
895 } else {
896 $prefix = '';
897 }
898
899 // loop thru attributes, expanding, and registering namespace declarations
900 if(count($attrs) > 0){
901 foreach($attrs as $k => $v){
902 // if ns declarations, add to class level array of valid namespaces
903 if(ereg("^xmlns",$k)){
904 //$this->xdebug("$k: $v");
905 //$this->xdebug('ns_prefix: '.$this->getPrefix($k));
906 if($ns_prefix = substr(strrchr($k,':'),1)){
907 //$this->xdebug("Add namespace[$ns_prefix] = $v");
908 $this->namespaces[$ns_prefix] = $v;
909 } else {
910 $this->defaultNamespace[$pos] = $v;
911 if (! $this->getPrefixFromNamespace($v)) {
912 $this->namespaces['ns'.(count($this->namespaces)+1)] = $v;
913 }
914 }
915 if($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema'){
916 $this->XMLSchemaVersion = $v;
917 $this->namespaces['xsi'] = $v.'-instance';
918 }
919 }
920 }
921 foreach($attrs as $k => $v){
922 // expand each attribute
923 $k = strpos($k,':') ? $this->expandQname($k) : $k;
924 $v = strpos($v,':') ? $this->expandQname($v) : $v;
925 $eAttrs[$k] = $v;
926 }
927 $attrs = $eAttrs;
928 } else {
929 $attrs = array();
930 }
931 // find status, register data
932 switch($name){
933 case 'all':
934 case 'choice':
935 case 'sequence':
936 //$this->xdebug("compositor $name for currentComplexType: $this->currentComplexType and currentElement: $this->currentElement");
937 $this->complexTypes[$this->currentComplexType]['compositor'] = $name;
938 if($name == 'all' || $name == 'sequence'){
939 $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
940 }
941 break;
942 case 'attribute':
943 //$this->xdebug("parsing attribute $attrs[name] $attrs[ref] of value: ".$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']);
944 $this->xdebug("parsing attribute " . $this->varDump($attrs));
945 if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
946 $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
947 if (!strpos($v, ':')) {
948 // no namespace in arrayType attribute value...
949 if ($this->defaultNamespace[$pos]) {
950 // ...so use the default
951 $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
952 }
953 }
954 }
955 if(isset($attrs['name'])){
956 $this->attributes[$attrs['name']] = $attrs;
957 $aname = $attrs['name'];
958 } elseif(isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType'){
959 if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
960 $aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
961 } else {
962 $aname = '';
963 }
964 } elseif(isset($attrs['ref'])){
965 $aname = $attrs['ref'];
966 $this->attributes[$attrs['ref']] = $attrs;
967 }
968
969 if(isset($this->currentComplexType)){
970 $this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs;
971 } elseif(isset($this->currentElement)){
972 $this->elements[$this->currentElement]['attrs'][$aname] = $attrs;
973 }
974 // arrayType attribute
975 if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType'){
976 $this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
977 $prefix = $this->getPrefix($aname);
978 if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])){
979 $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
980 } else {
981 $v = '';
982 }
983 if(strpos($v,'[,]')){
984 $this->complexTypes[$this->currentComplexType]['multidimensional'] = true;
985 }
986 $v = substr($v,0,strpos($v,'[')); // clip the []
987 if(!strpos($v,':') && isset($this->typemap[$this->XMLSchemaVersion][$v])){
988 $v = $this->XMLSchemaVersion.':'.$v;
989 }
990 $this->complexTypes[$this->currentComplexType]['arrayType'] = $v;
991 }
992 break;
993 case 'complexType':
994 if(isset($attrs['name'])){
995 $this->xdebug('processing named complexType '.$attrs['name']);
996 $this->currentElement = false;
997 $this->currentComplexType = $attrs['name'];
998 $this->complexTypes[$this->currentComplexType] = $attrs;
999 $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType';
1000 if(isset($attrs['base']) && ereg(':Array$',$attrs['base'])){
1001 $this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
1002 } else {
1003 $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
1004 }
1005 }else{
1006 $this->xdebug('processing unnamed complexType for element '.$this->currentElement);
1007 $this->currentComplexType = $this->currentElement . '_ContainedType';
1008 $this->currentElement = false;
1009 $this->complexTypes[$this->currentComplexType] = $attrs;
1010 $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType';
1011 if(isset($attrs['base']) && ereg(':Array$',$attrs['base'])){
1012 $this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
1013 } else {
1014 $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
1015 }
1016 }
1017 break;
1018 case 'element':
1019 // elements defined as part of a complex type should
1020 // not really be added to $this->elements, but for some
1021 // reason, they are
1022 if(isset($attrs['type'])){
1023 $this->xdebug("processing typed element ".$attrs['name']." of type ".$attrs['type']);
1024 $this->currentElement = $attrs['name'];
1025 $this->elements[ $attrs['name'] ] = $attrs;
1026 $this->elements[ $attrs['name'] ]['typeClass'] = 'element';
1027 if (!isset($this->elements[ $attrs['name'] ]['form'])) {
1028 $this->elements[ $attrs['name'] ]['form'] = $this->schemaInfo['elementFormDefault'];
1029 }
1030 $ename = $attrs['name'];
1031 } elseif(isset($attrs['ref'])){
1032 $ename = $attrs['ref'];
1033 } else {
1034 $this->xdebug("processing untyped element ".$attrs['name']);
1035 $this->currentElement = $attrs['name'];
1036 $this->elements[ $attrs['name'] ] = $attrs;
1037 $this->elements[ $attrs['name'] ]['typeClass'] = 'element';
1038 $this->elements[ $attrs['name'] ]['type'] = $this->schemaTargetNamespace . ':' . $attrs['name'] . '_ContainedType';
1039 if (!isset($this->elements[ $attrs['name'] ]['form'])) {
1040 $this->elements[ $attrs['name'] ]['form'] = $this->schemaInfo['elementFormDefault'];
1041 }
1042 }
1043 if(isset($ename) && $this->currentComplexType){
1044 $this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs;
1045 }
1046 break;
1047 // we ignore enumeration values
1048 //case 'enumeration':
1049 //break;
1050 case 'import':
1051 if (isset($attrs['schemaLocation'])) {
1052 //$this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']);
1053 $this->imports[$attrs['namespace']][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
1054 } else {
1055 //$this->xdebug('import namespace ' . $attrs['namespace']);
1056 $this->imports[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
1057 if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
1058 $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace'];
1059 }
1060 }
1061 break;
1062 case 'restriction':
1063 //$this->xdebug("in restriction for currentComplexType: $this->currentComplexType and currentElement: $this->currentElement");
1064 if($this->currentElement){
1065 $this->elements[$this->currentElement]['type'] = $attrs['base'];
1066 } elseif($this->currentSimpleType){
1067 $this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base'];
1068 } elseif($this->currentComplexType){
1069 $this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base'];
1070 if(strstr($attrs['base'],':') == ':Array'){
1071 $this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
1072 }
1073 }
1074 break;
1075 case 'schema':
1076 $this->schemaInfo = $attrs;
1077 $this->schemaInfo['schemaVersion'] = $this->getNamespaceFromPrefix($prefix);
1078 if (isset($attrs['targetNamespace'])) {
1079 $this->schemaTargetNamespace = $attrs['targetNamespace'];
1080 }
1081 if (!isset($attrs['elementFormDefault'])) {
1082 $this->schemaInfo['elementFormDefault'] = 'unqualified';
1083 }
1084 break;
1085 case 'simpleType':
1086 if(isset($attrs['name'])){
1087 $this->xdebug("processing simpleType for name " . $attrs['name']);
1088 $this->currentSimpleType = $attrs['name'];
1089 $this->simpleTypes[ $attrs['name'] ] = $attrs;
1090 $this->simpleTypes[ $attrs['name'] ]['typeClass'] = 'simpleType';
1091 $this->simpleTypes[ $attrs['name'] ]['phpType'] = 'scalar';
1092 } else {
1093 //echo 'not parsing: '.$name;
1094 //var_dump($attrs);
1095 }
1096 break;
1097 default:
1098 //$this->xdebug("do not have anything to do for element $name");
1099 }
1100 }
$currentComplexType
Definition: nusoap.php:747
$currentElement
Definition: nusoap.php:749
$currentSimpleType
Definition: nusoap.php:751
getPrefix($str)
returns the prefix part of a prefixed string returns false, if not prefixed
Definition: nusoap.php:525
getNamespaceFromPrefix($prefix)
pass it a prefix, it returns a namespace returns false if no namespace registered with the given pref...
Definition: nusoap.php:541
getPrefixFromNamespace($ns)
returns the prefix for a given namespace (or prefix) or false if no prefixes registered for the given...
Definition: nusoap.php:557
expandQname($qname)
expands a qualified name
Definition: nusoap.php:483
getLocalPart($str)
returns the local part of a prefixed string returns the original string, if not prefixed
Definition: nusoap.php:508

References $currentComplexType, $currentElement, $currentSimpleType, $depth, nusoap_base\expandQname(), nusoap_base\getLocalPart(), nusoap_base\getNamespaceFromPrefix(), nusoap_base\getPrefix(), nusoap_base\getPrefixFromNamespace(), nusoap_base\varDump(), and xdebug().

+ Here is the call graph for this function:

◆ serializeSchema()

XMLSchema::serializeSchema ( )

serialize the schema

@access public

Reimplemented from nusoap_xmlschema.

Definition at line 1146 of file nusoap.php.

1146 {
1147
1148 $schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion);
1149 $xml = '';
1150 // imports
1151 if (sizeof($this->imports) > 0) {
1152 foreach($this->imports as $ns => $list) {
1153 foreach ($list as $ii) {
1154 if ($ii['location'] != '') {
1155 $xml .= " <$schemaPrefix:import location=\"" . $ii['location'] . '" namespace="' . $ns . "\" />\n";
1156 } else {
1157 $xml .= " <$schemaPrefix:import namespace=\"" . $ns . "\" />\n";
1158 }
1159 }
1160 }
1161 }
1162 // complex types
1163 foreach($this->complexTypes as $typeName => $attrs){
1164 $contentStr = '';
1165 // serialize child elements
1166 if(isset($attrs['elements']) && (count($attrs['elements']) > 0)){
1167 foreach($attrs['elements'] as $element => $eParts){
1168 if(isset($eParts['ref'])){
1169 $contentStr .= " <$schemaPrefix:element ref=\"$element\"/>\n";
1170 } else {
1171 $contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\"/>\n";
1172 }
1173 }
1174 }
1175 // attributes
1176 if(isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)){
1177 foreach($attrs['attrs'] as $attr => $aParts){
1178 $contentStr .= " <$schemaPrefix:attribute ref=\"".$this->contractQName($aParts['ref']).'"';
1179 if(isset($aParts['http://schemas.xmlsoap.org/wsdl/:arrayType'])){
1180 $this->usedNamespaces['wsdl'] = $this->namespaces['wsdl'];
1181 $contentStr .= ' wsdl:arrayType="'.$this->contractQName($aParts['http://schemas.xmlsoap.org/wsdl/:arrayType']).'"';
1182 }
1183 $contentStr .= "/>\n";
1184 }
1185 }
1186 // if restriction
1187 if( isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != ''){
1188 $contentStr = " <$schemaPrefix:restriction base=\"".$this->contractQName($attrs['restrictionBase'])."\">\n".$contentStr." </$schemaPrefix:restriction>\n";
1189 }
1190 // compositor obviates complex/simple content
1191 if(isset($attrs['compositor']) && ($attrs['compositor'] != '')){
1192 $contentStr = " <$schemaPrefix:$attrs[compositor]>\n".$contentStr." </$schemaPrefix:$attrs[compositor]>\n";
1193 }
1194 // complex or simple content
1195 elseif((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)){
1196 $contentStr = " <$schemaPrefix:complexContent>\n".$contentStr." </$schemaPrefix:complexContent>\n";
1197 }
1198 // finalize complex type
1199 if($contentStr != ''){
1200 $contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n".$contentStr." </$schemaPrefix:complexType>\n";
1201 } else {
1202 $contentStr = " <$schemaPrefix:complexType name=\"$typeName\"/>\n";
1203 }
1204 $xml .= $contentStr;
1205 }
1206 // simple types
1207 if(isset($this->simpleTypes) && count($this->simpleTypes) > 0){
1208 foreach($this->simpleTypes as $typeName => $attr){
1209 $xml .= " <$schemaPrefix:simpleType name=\"$typeName\">\n <restriction base=\"".$this->contractQName($eParts['type'])."\"/>\n </$schemaPrefix:simpleType>";
1210 }
1211 }
1212 // elements
1213 if(isset($this->elements) && count($this->elements) > 0){
1214 foreach($this->elements as $element => $eParts){
1215 $xml .= " <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts['type'])."\"/>\n";
1216 }
1217 }
1218 // attributes
1219 if(isset($this->attributes) && count($this->attributes) > 0){
1220 foreach($this->attributes as $attr => $aParts){
1221 $xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"".$this->contractQName($aParts['type'])."\"\n/>";
1222 }
1223 }
1224 // finish 'er up
1225 $el = "<$schemaPrefix:schema targetNamespace=\"$this->schemaTargetNamespace\"\n";
1226 foreach (array_diff($this->usedNamespaces, $this->enclosingNamespaces) as $nsp => $ns) {
1227 $el .= " xmlns:$nsp=\"$ns\"\n";
1228 }
1229 $xml = $el . ">\n".$xml."</$schemaPrefix:schema>\n";
1230 return $xml;
1231 }

References $xml, and nusoap_base\getPrefixFromNamespace().

+ Here is the call graph for this function:

◆ serializeTypeDef()

XMLSchema::serializeTypeDef (   $type)

returns a sample serialization of a given type, or false if no type by the given name

Parameters
string$type,nameof type
Returns
mixed @access public

Reimplemented from nusoap_xmlschema.

Definition at line 1338 of file nusoap.php.

1338 {
1339 //print "in sTD() for type $type<br>";
1340 if($typeDef = $this->getTypeDef($type)){
1341 $str .= '<'.$type;
1342 if(is_array($typeDef['attrs'])){
1343 foreach($attrs as $attName => $data){
1344 $str .= " $attName=\"{type = ".$data['type']."}\"";
1345 }
1346 }
1347 $str .= " xmlns=\"".$this->schema['targetNamespace']."\"";
1348 if(count($typeDef['elements']) > 0){
1349 $str .= ">";
1350 foreach($typeDef['elements'] as $element => $eData){
1351 $str .= $this->serializeTypeDef($element);
1352 }
1353 $str .= "</$type>";
1354 } elseif($typeDef['typeClass'] == 'element') {
1355 $str .= "></$type>";
1356 } else {
1357 $str .= "/>";
1358 }
1359 return $str;
1360 }
1361 return false;
1362 }
serializeTypeDef($type)
returns a sample serialization of a given type, or false if no type by the given name
Definition: nusoap.php:1338

References $data, getTypeDef(), and serializeTypeDef().

Referenced by serializeTypeDef().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ typeToForm()

XMLSchema::typeToForm (   $name,
  $type 
)

returns HTML form elements that allow a user to enter values for creating an instance of the given type.

Parameters
string$name,namefor type instance
string$type,nameof type
Returns
string @access public

Reimplemented from nusoap_xmlschema.

Definition at line 1373 of file nusoap.php.

1373 {
1374 // get typedef
1375 if($typeDef = $this->getTypeDef($type)){
1376 // if struct
1377 if($typeDef['phpType'] == 'struct'){
1378 $buffer .= '<table>';
1379 foreach($typeDef['elements'] as $child => $childDef){
1380 $buffer .= "
1381 <tr><td align='right'>$childDef[name] (type: ".$this->getLocalPart($childDef['type'])."):</td>
1382 <td><input type='text' name='parameters[".$name."][$childDef[name]]'></td></tr>";
1383 }
1384 $buffer .= '</table>';
1385 // if array
1386 } elseif($typeDef['phpType'] == 'array'){
1387 $buffer .= '<table>';
1388 for($i=0;$i < 3; $i++){
1389 $buffer .= "
1390 <tr><td align='right'>array item (type: $typeDef[arrayType]):</td>
1391 <td><input type='text' name='parameters[".$name."][]'></td></tr>";
1392 }
1393 $buffer .= '</table>';
1394 // if scalar
1395 } else {
1396 $buffer .= "<input type='text' name='parameters[$name]'>";
1397 }
1398 } else {
1399 $buffer .= "<input type='text' name='parameters[$name]'>";
1400 }
1401 return $buffer;
1402 }

References getTypeDef().

+ Here is the call graph for this function:

◆ xdebug()

XMLSchema::xdebug (   $string)

adds debug data to the clas level debug string

Parameters
string$stringdebug data @access private

Reimplemented from nusoap_xmlschema.

Definition at line 1239 of file nusoap.php.

1239 {
1240 $this->debug('<' . $this->schemaTargetNamespace . '> '.$string);
1241 }

References nusoap_base\debug().

Referenced by addComplexType(), addSimpleType(), getTypeDef(), and schemaStartElement().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ XMLSchema()

XMLSchema::XMLSchema (   $schema = '',
  $xml = '',
  $namespaces = array() 
)

constructor

Parameters
string$schemaschema document URI
string$xmlxml document URI
string$namespacesnamespaces defined in enclosing XML @access public

Definition at line 770 of file nusoap.php.

770 {
771
772 $this->debug('xmlschema class instantiated, inside constructor');
773 // files
774 $this->schema = $schema;
775 $this->xml = $xml;
776
777 // namespaces
778 $this->enclosingNamespaces = $namespaces;
779 $this->namespaces = array_merge($this->namespaces, $namespaces);
780
781 // parse schema file
782 if($schema != ''){
783 $this->debug('initial schema file: '.$schema);
784 $this->parseFile($schema, 'schema');
785 }
786
787 // parse xml file
788 if($xml != ''){
789 $this->debug('initial xml file: '.$xml);
790 $this->parseFile($xml, 'xml');
791 }
792
793 }
parseFile($xml, $type)
parse an XML file
Definition: nusoap.php:803

References nusoap_base\$namespaces, $schema, $xml, nusoap_base\debug(), and parseFile().

+ Here is the call graph for this function:

Field Documentation

◆ $attributes

XMLSchema::$attributes = array()

Definition at line 745 of file nusoap.php.

◆ $complexTypes

XMLSchema::$complexTypes = array()

Definition at line 746 of file nusoap.php.

◆ $currentComplexType

XMLSchema::$currentComplexType = false

Definition at line 747 of file nusoap.php.

Referenced by schemaStartElement().

◆ $currentElement

XMLSchema::$currentElement = false

Definition at line 749 of file nusoap.php.

Referenced by schemaStartElement().

◆ $currentSimpleType

XMLSchema::$currentSimpleType = false

Definition at line 751 of file nusoap.php.

Referenced by schemaStartElement().

◆ $defaultNamespace

XMLSchema::$defaultNamespace = array()

Definition at line 760 of file nusoap.php.

◆ $depth

XMLSchema::$depth = 0

Definition at line 757 of file nusoap.php.

Referenced by schemaEndElement(), and schemaStartElement().

◆ $depth_array

XMLSchema::$depth_array = array()

Definition at line 758 of file nusoap.php.

◆ $elements

XMLSchema::$elements = array()

Definition at line 748 of file nusoap.php.

Referenced by addComplexType().

◆ $enclosingNamespaces

XMLSchema::$enclosingNamespaces

Definition at line 740 of file nusoap.php.

◆ $imports

XMLSchema::$imports = array()

Definition at line 753 of file nusoap.php.

◆ $message

XMLSchema::$message = array()

Definition at line 759 of file nusoap.php.

◆ $parser

XMLSchema::$parser

Definition at line 755 of file nusoap.php.

◆ $position

XMLSchema::$position = 0

Definition at line 756 of file nusoap.php.

◆ $schema

XMLSchema::$schema = ''

Definition at line 737 of file nusoap.php.

Referenced by XMLSchema().

◆ $schemaInfo

XMLSchema::$schemaInfo = array()

Definition at line 742 of file nusoap.php.

◆ $schemaTargetNamespace

XMLSchema::$schemaTargetNamespace = ''

Definition at line 743 of file nusoap.php.

◆ $simpleTypes

XMLSchema::$simpleTypes = array()

Definition at line 750 of file nusoap.php.

◆ $xml

XMLSchema::$xml = ''

Definition at line 738 of file nusoap.php.

Referenced by parseFile(), parseString(), serializeSchema(), and XMLSchema().


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