parses an XML Schema, allows access to it's data, other utility methods no validation... More...
Inheritance diagram for XMLSchema:
Collaboration diagram for XMLSchema:Public Member Functions | |
| XMLSchema ($schema='', $xml='', $namespaces=array()) | |
| constructor | |
| parseFile ($xml, $type) | |
| parse an XML file | |
| parseString ($xml, $type) | |
| parse an XML string | |
| schemaStartElement ($parser, $name, $attrs) | |
| start-element handler | |
| schemaEndElement ($parser, $name) | |
| end-element handler | |
| schemaCharacterData ($parser, $data) | |
| element content handler | |
| serializeSchema () | |
| serialize the schema | |
| xdebug ($string) | |
| adds debug data to the clas level debug string | |
| 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. | |
| getTypeDef ($type) | |
| returns an array of information about a given type returns false if no type exists by the given name | |
| serializeTypeDef ($type) | |
| returns a sample serialization of a given type, or false if no type by the given name | |
| typeToForm ($name, $type) | |
| returns HTML form elements that allow a user to enter values for creating an instance of the given type. | |
| addComplexType ($name, $typeClass='complexType', $phpType='array', $compositor='', $restrictionBase='', $elements=array(), $attrs=array(), $arrayType='') | |
| adds a complex type to the schema | |
| addSimpleType ($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar') | |
| adds a simple type to the schema | |
| XMLSchema ($schema='', $xml='', $namespaces=array()) | |
| constructor | |
| parseFile ($xml, $type) | |
| parse an XML file | |
| parseString ($xml, $type) | |
| parse an XML string | |
| schemaStartElement ($parser, $name, $attrs) | |
| start-element handler | |
| schemaEndElement ($parser, $name) | |
| end-element handler | |
| schemaCharacterData ($parser, $data) | |
| element content handler | |
| serializeSchema () | |
| serialize the schema | |
| xdebug ($string) | |
| adds debug data to the clas level debug string | |
| 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. | |
| getTypeDef ($type) | |
| returns an array of information about a given type returns false if no type exists by the given name | |
| serializeTypeDef ($type) | |
| returns a sample serialization of a given type, or false if no type by the given name | |
| typeToForm ($name, $type) | |
| returns HTML form elements that allow a user to enter values for creating an instance of the given type. | |
| addComplexType ($name, $typeClass='complexType', $phpType='array', $compositor='', $restrictionBase='', $elements=array(), $attrs=array(), $arrayType='') | |
| adds a complex type to the schema | |
| addSimpleType ($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar') | |
| adds a simple type to the schema | |
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() | |
parses an XML Schema, allows access to it's data, other utility methods no validation...
yet. 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 :)
public
yet. 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 :)
public
Definition at line 17 of file class.xmlschema.php.
| 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') );
| name | ||
| typeClass | (complexType|simpleType|attribute) | |
| phpType,: | currently supported are array and struct (php assoc array) | |
| compositor | (all|sequence|choice) | |
| restrictionBase | namespace: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[]" ) ) | |
| arrayType,: | namespace:name (http://www.w3.org/2001/XMLSchema:string) |
Definition at line 727 of file class.xmlschema.php.
References $elements, nusoap_base::varDump(), and xdebug().
{
$this->complexTypes[$name] = array(
'name' => $name,
'typeClass' => $typeClass,
'phpType' => $phpType,
'compositor'=> $compositor,
'restrictionBase' => $restrictionBase,
'elements' => $elements,
'attrs' => $attrs,
'arrayType' => $arrayType
);
$this->xdebug("addComplexType $name: " . $this->varDump($this->complexTypes[$name]));
}
Here is the call graph for this function:| 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') );
| name | ||
| typeClass | (complexType|simpleType|attribute) | |
| phpType,: | currently supported are array and struct (php assoc array) | |
| compositor | (all|sequence|choice) | |
| restrictionBase | namespace: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[]" ) ) | |
| arrayType,: | namespace:name (http://www.w3.org/2001/XMLSchema:string) |
Definition at line 1444 of file nusoap.php.
References $elements, nusoap_base::varDump(), and xdebug().
{
$this->complexTypes[$name] = array(
'name' => $name,
'typeClass' => $typeClass,
'phpType' => $phpType,
'compositor'=> $compositor,
'restrictionBase' => $restrictionBase,
'elements' => $elements,
'attrs' => $attrs,
'arrayType' => $arrayType
);
$this->xdebug("addComplexType $name: " . $this->varDump($this->complexTypes[$name]));
}
Here is the call graph for this function:| XMLSchema::addSimpleType | ( | $ | name, | |
| $ | restrictionBase = '', |
|||
| $ | typeClass = 'simpleType', |
|||
| $ | phpType = 'scalar' | |||
| ) |
adds a simple type to the schema
| name | ||
| restrictionBase | namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) | |
| typeClass | (simpleType) | |
| phpType,: | (scalar) |
Definition at line 752 of file class.xmlschema.php.
References nusoap_base::varDump(), and xdebug().
{
$this->simpleTypes[$name] = array(
'name' => $name,
'typeClass' => $typeClass,
'phpType' => $phpType,
'type' => $restrictionBase
);
$this->xdebug("addSimpleType $name: " . $this->varDump($this->simpleTypes[$name]));
}
Here is the call graph for this function:| XMLSchema::addSimpleType | ( | $ | name, | |
| $ | restrictionBase = '', |
|||
| $ | typeClass = 'simpleType', |
|||
| $ | phpType = 'scalar' | |||
| ) |
adds a simple type to the schema
| name | ||
| restrictionBase | namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) | |
| typeClass | (simpleType) | |
| phpType,: | (scalar) |
Definition at line 1469 of file nusoap.php.
References nusoap_base::varDump(), and xdebug().
{
$this->simpleTypes[$name] = array(
'name' => $name,
'typeClass' => $typeClass,
'phpType' => $phpType,
'type' => $restrictionBase
);
$this->xdebug("addSimpleType $name: " . $this->varDump($this->simpleTypes[$name]));
}
Here is the call graph for this function:| 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'
| string | $type, name of defined type | |
| string | $ns, namespace of type |
Definition at line 1254 of file nusoap.php.
References $type.
{
if(isset($this->typemap[$ns][$type])){
//print "found type '$type' and ns $ns in typemap<br>";
return $this->typemap[$ns][$type];
} elseif(isset($this->complexTypes[$type])){
//print "getting type '$type' and ns $ns from complexTypes array<br>";
return $this->complexTypes[$type]['phpType'];
}
return false;
}
| 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'
| string | $type, name of defined type | |
| string | $ns, namespace of type |
Definition at line 537 of file class.xmlschema.php.
References $type.
{
if(isset($this->typemap[$ns][$type])){
//print "found type '$type' and ns $ns in typemap<br>";
return $this->typemap[$ns][$type];
} elseif(isset($this->complexTypes[$type])){
//print "getting type '$type' and ns $ns from complexTypes array<br>";
return $this->complexTypes[$type]['phpType'];
}
return false;
}
| 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 )
| string |
Definition at line 564 of file class.xmlschema.php.
References $type, and xdebug().
Referenced by getTypeDef(), serializeTypeDef(), and typeToForm().
{
//$this->debug("in getTypeDef for type $type");
if(isset($this->complexTypes[$type])){
$this->xdebug("in getTypeDef, found complexType $type");
return $this->complexTypes[$type];
} elseif(isset($this->simpleTypes[$type])){
$this->xdebug("in getTypeDef, found simpleType $type");
if (!isset($this->simpleTypes[$type]['phpType'])) {
// get info for type to tack onto the simple type
// TODO: can this ever really apply (i.e. what is a simpleType really?)
$uqType = substr($this->simpleTypes[$type]['type'], strrpos($this->simpleTypes[$type]['type'], ':') + 1);
$ns = substr($this->simpleTypes[$type]['type'], 0, strrpos($this->simpleTypes[$type]['type'], ':'));
$etype = $this->getTypeDef($uqType);
if ($etype) {
if (isset($etype['phpType'])) {
$this->simpleTypes[$type]['phpType'] = $etype['phpType'];
}
if (isset($etype['elements'])) {
$this->simpleTypes[$type]['elements'] = $etype['elements'];
}
}
}
return $this->simpleTypes[$type];
} elseif(isset($this->elements[$type])){
$this->xdebug("in getTypeDef, found element $type");
if (!isset($this->elements[$type]['phpType'])) {
// get info for type to tack onto the element
$uqType = substr($this->elements[$type]['type'], strrpos($this->elements[$type]['type'], ':') + 1);
$ns = substr($this->elements[$type]['type'], 0, strrpos($this->elements[$type]['type'], ':'));
$etype = $this->getTypeDef($uqType);
if ($etype) {
if (isset($etype['phpType'])) {
$this->elements[$type]['phpType'] = $etype['phpType'];
}
if (isset($etype['elements'])) {
$this->elements[$type]['elements'] = $etype['elements'];
}
} elseif ($ns == 'http://www.w3.org/2001/XMLSchema') {
$this->elements[$type]['phpType'] = 'scalar';
}
}
return $this->elements[$type];
} elseif(isset($this->attributes[$type])){
$this->xdebug("in getTypeDef, found attribute $type");
return $this->attributes[$type];
}
$this->xdebug("in getTypeDef, did not find $type");
return false;
}
Here is the call graph for this function:
Here is the caller graph for this function:| 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 )
| string |
Definition at line 1281 of file nusoap.php.
References $type, getTypeDef(), and xdebug().
{
//$this->debug("in getTypeDef for type $type");
if(isset($this->complexTypes[$type])){
$this->xdebug("in getTypeDef, found complexType $type");
return $this->complexTypes[$type];
} elseif(isset($this->simpleTypes[$type])){
$this->xdebug("in getTypeDef, found simpleType $type");
if (!isset($this->simpleTypes[$type]['phpType'])) {
// get info for type to tack onto the simple type
// TODO: can this ever really apply (i.e. what is a simpleType really?)
$uqType = substr($this->simpleTypes[$type]['type'], strrpos($this->simpleTypes[$type]['type'], ':') + 1);
$ns = substr($this->simpleTypes[$type]['type'], 0, strrpos($this->simpleTypes[$type]['type'], ':'));
$etype = $this->getTypeDef($uqType);
if ($etype) {
if (isset($etype['phpType'])) {
$this->simpleTypes[$type]['phpType'] = $etype['phpType'];
}
if (isset($etype['elements'])) {
$this->simpleTypes[$type]['elements'] = $etype['elements'];
}
}
}
return $this->simpleTypes[$type];
} elseif(isset($this->elements[$type])){
$this->xdebug("in getTypeDef, found element $type");
if (!isset($this->elements[$type]['phpType'])) {
// get info for type to tack onto the element
$uqType = substr($this->elements[$type]['type'], strrpos($this->elements[$type]['type'], ':') + 1);
$ns = substr($this->elements[$type]['type'], 0, strrpos($this->elements[$type]['type'], ':'));
$etype = $this->getTypeDef($uqType);
if ($etype) {
if (isset($etype['phpType'])) {
$this->elements[$type]['phpType'] = $etype['phpType'];
}
if (isset($etype['elements'])) {
$this->elements[$type]['elements'] = $etype['elements'];
}
} elseif ($ns == 'http://www.w3.org/2001/XMLSchema') {
$this->elements[$type]['phpType'] = 'scalar';
}
}
return $this->elements[$type];
} elseif(isset($this->attributes[$type])){
$this->xdebug("in getTypeDef, found attribute $type");
return $this->attributes[$type];
}
$this->xdebug("in getTypeDef, did not find $type");
return false;
}
Here is the call graph for this function:| XMLSchema::parseFile | ( | $ | xml, | |
| $ | type | |||
| ) |
parse an XML file
| string | $xml, path/URL to XML file | |
| string | $type, (schema | xml) |
Definition at line 803 of file nusoap.php.
References $type, $xml, nusoap_base::debug(), parseString(), and nusoap_base::setError().
{
// parse xml file
if($xml != ""){
$xmlStr = @join("",@file($xml));
if($xmlStr == ""){
$msg = 'Error reading XML from '.$xml;
$this->setError($msg);
$this->debug($msg);
return false;
} else {
$this->debug("parsing $xml");
$this->parseString($xmlStr,$type);
$this->debug("done parsing $xml");
return true;
}
}
return false;
}
Here is the call graph for this function:| XMLSchema::parseFile | ( | $ | xml, | |
| $ | type | |||
| ) |
parse an XML file
| string | $xml, path/URL to XML file | |
| string | $type, (schema | xml) |
Definition at line 86 of file class.xmlschema.php.
References $type, $xml, nusoap_base::debug(), parseString(), and nusoap_base::setError().
Referenced by XMLSchema().
{
// parse xml file
if($xml != ""){
$xmlStr = @join("",@file($xml));
if($xmlStr == ""){
$msg = 'Error reading XML from '.$xml;
$this->setError($msg);
$this->debug($msg);
return false;
} else {
$this->debug("parsing $xml");
$this->parseString($xmlStr,$type);
$this->debug("done parsing $xml");
return true;
}
}
return false;
}
Here is the call graph for this function:
Here is the caller graph for this function:| XMLSchema::parseString | ( | $ | xml, | |
| $ | type | |||
| ) |
parse an XML string
| string | $xml path or URL | |
| string | $type, (schema|xml) private |
Definition at line 829 of file nusoap.php.
References $type, $xml, nusoap_base::debug(), and nusoap_base::setError().
{
// parse xml string
if($xml != ""){
// Create an XML parser.
$this->parser = xml_parser_create();
// Set the options for parsing the XML data.
xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
// Set the object for the parser.
xml_set_object($this->parser, $this);
// Set the element handlers for the parser.
if($type == "schema"){
xml_set_element_handler($this->parser, 'schemaStartElement','schemaEndElement');
xml_set_character_data_handler($this->parser,'schemaCharacterData');
} elseif($type == "xml"){
xml_set_element_handler($this->parser, 'xmlStartElement','xmlEndElement');
xml_set_character_data_handler($this->parser,'xmlCharacterData');
}
// Parse the XML file.
if(!xml_parse($this->parser,$xml,true)){
// Display an error message.
$errstr = sprintf('XML error parsing XML schema on line %d: %s',
xml_get_current_line_number($this->parser),
xml_error_string(xml_get_error_code($this->parser))
);
$this->debug($errstr);
$this->debug("XML payload:\n" . $xml);
$this->setError($errstr);
}
xml_parser_free($this->parser);
} else{
$this->debug('no xml passed to parseString()!!');
$this->setError('no xml passed to parseString()!!');
}
}
Here is the call graph for this function:| XMLSchema::parseString | ( | $ | xml, | |
| $ | type | |||
| ) |
parse an XML string
| string | $xml path or URL | |
| string | $type, (schema|xml) private |
Definition at line 112 of file class.xmlschema.php.
References $type, $xml, nusoap_base::debug(), and nusoap_base::setError().
Referenced by parseFile().
{
// parse xml string
if($xml != ""){
// Create an XML parser.
$this->parser = xml_parser_create();
// Set the options for parsing the XML data.
xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
// Set the object for the parser.
xml_set_object($this->parser, $this);
// Set the element handlers for the parser.
if($type == "schema"){
xml_set_element_handler($this->parser, 'schemaStartElement','schemaEndElement');
xml_set_character_data_handler($this->parser,'schemaCharacterData');
} elseif($type == "xml"){
xml_set_element_handler($this->parser, 'xmlStartElement','xmlEndElement');
xml_set_character_data_handler($this->parser,'xmlCharacterData');
}
// Parse the XML file.
if(!xml_parse($this->parser,$xml,true)){
// Display an error message.
$errstr = sprintf('XML error parsing XML schema on line %d: %s',
xml_get_current_line_number($this->parser),
xml_error_string(xml_get_error_code($this->parser))
);
$this->debug($errstr);
$this->debug("XML payload:\n" . $xml);
$this->setError($errstr);
}
xml_parser_free($this->parser);
} else{
$this->debug('no xml passed to parseString()!!');
$this->setError('no xml passed to parseString()!!');
}
}
Here is the call graph for this function:
Here is the caller graph for this function:| XMLSchema::schemaCharacterData | ( | $ | parser, | |
| $ | data | |||
| ) |
| XMLSchema::schemaCharacterData | ( | $ | parser, | |
| $ | data | |||
| ) |
| XMLSchema::schemaEndElement | ( | $ | parser, | |
| $ | name | |||
| ) |
end-element handler
| string | $parser XML parser object | |
| string | $name element name private |
Definition at line 392 of file class.xmlschema.php.
References $pos.
{
// bring depth down a notch
$this->depth--;
// position of current element is equal to the last value left in depth_array for my depth
if(isset($this->depth_array[$this->depth])){
$pos = $this->depth_array[$this->depth];
}
// move on...
if($name == 'complexType'){
$this->currentComplexType = false;
$this->currentElement = false;
}
if($name == 'element'){
$this->currentElement = false;
}
if($name == 'simpleType'){
$this->currentSimpleType = false;
}
}
| XMLSchema::schemaEndElement | ( | $ | parser, | |
| $ | name | |||
| ) |
end-element handler
| string | $parser XML parser object | |
| string | $name element name private |
Definition at line 1109 of file nusoap.php.
References $pos.
{
// bring depth down a notch
$this->depth--;
// position of current element is equal to the last value left in depth_array for my depth
if(isset($this->depth_array[$this->depth])){
$pos = $this->depth_array[$this->depth];
}
// move on...
if($name == 'complexType'){
$this->currentComplexType = false;
$this->currentElement = false;
}
if($name == 'element'){
$this->currentElement = false;
}
if($name == 'simpleType'){
$this->currentSimpleType = false;
}
}
| XMLSchema::schemaStartElement | ( | $ | parser, | |
| $ | name, | |||
| $ | attrs | |||
| ) |
start-element handler
| string | $parser XML parser object | |
| string | $name element name | |
| string | $attrs associative array of attributes private |
Definition at line 877 of file nusoap.php.
References $depth, $pos, nusoap_base::expandQname(), nusoap_base::getLocalPart(), nusoap_base::getNamespaceFromPrefix(), nusoap_base::getPrefix(), nusoap_base::getPrefixFromNamespace(), nusoap_base::varDump(), and xdebug().
{
// position in the total number of elements, starting from 0
$pos = $this->position++;
$depth = $this->depth++;
// set self as current value for this depth
$this->depth_array[$depth] = $pos;
$this->message[$pos] = array('cdata' => '');
if ($depth > 0) {
$this->defaultNamespace[$pos] = $this->defaultNamespace[$this->depth_array[$depth - 1]];
} else {
$this->defaultNamespace[$pos] = false;
}
// get element prefix
if($prefix = $this->getPrefix($name)){
// get unqualified name
$name = $this->getLocalPart($name);
} else {
$prefix = '';
}
// loop thru attributes, expanding, and registering namespace declarations
if(count($attrs) > 0){
foreach($attrs as $k => $v){
// if ns declarations, add to class level array of valid namespaces
if(ereg("^xmlns",$k)){
//$this->xdebug("$k: $v");
//$this->xdebug('ns_prefix: '.$this->getPrefix($k));
if($ns_prefix = substr(strrchr($k,':'),1)){
//$this->xdebug("Add namespace[$ns_prefix] = $v");
$this->namespaces[$ns_prefix] = $v;
} else {
$this->defaultNamespace[$pos] = $v;
if (! $this->getPrefixFromNamespace($v)) {
$this->namespaces['ns'.(count($this->namespaces)+1)] = $v;
}
}
if($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema'){
$this->XMLSchemaVersion = $v;
$this->namespaces['xsi'] = $v.'-instance';
}
}
}
foreach($attrs as $k => $v){
// expand each attribute
$k = strpos($k,':') ? $this->expandQname($k) : $k;
$v = strpos($v,':') ? $this->expandQname($v) : $v;
$eAttrs[$k] = $v;
}
$attrs = $eAttrs;
} else {
$attrs = array();
}
// find status, register data
switch($name){
case 'all':
case 'choice':
case 'sequence':
//$this->xdebug("compositor $name for currentComplexType: $this->currentComplexType and currentElement: $this->currentElement");
$this->complexTypes[$this->currentComplexType]['compositor'] = $name;
if($name == 'all' || $name == 'sequence'){
$this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
}
break;
case 'attribute':
//$this->xdebug("parsing attribute $attrs[name] $attrs[ref] of value: ".$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']);
$this->xdebug("parsing attribute " . $this->varDump($attrs));
if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
$v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
if (!strpos($v, ':')) {
// no namespace in arrayType attribute value...
if ($this->defaultNamespace[$pos]) {
// ...so use the default
$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
}
}
}
if(isset($attrs['name'])){
$this->attributes[$attrs['name']] = $attrs;
$aname = $attrs['name'];
} elseif(isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType'){
if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
$aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
} else {
$aname = '';
}
} elseif(isset($attrs['ref'])){
$aname = $attrs['ref'];
$this->attributes[$attrs['ref']] = $attrs;
}
if(isset($this->currentComplexType)){
$this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs;
} elseif(isset($this->currentElement)){
$this->elements[$this->currentElement]['attrs'][$aname] = $attrs;
}
// arrayType attribute
if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType'){
$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
$prefix = $this->getPrefix($aname);
if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])){
$v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
} else {
$v = '';
}
if(strpos($v,'[,]')){
$this->complexTypes[$this->currentComplexType]['multidimensional'] = true;
}
$v = substr($v,0,strpos($v,'[')); // clip the []
if(!strpos($v,':') && isset($this->typemap[$this->XMLSchemaVersion][$v])){
$v = $this->XMLSchemaVersion.':'.$v;
}
$this->complexTypes[$this->currentComplexType]['arrayType'] = $v;
}
break;
case 'complexType':
if(isset($attrs['name'])){
$this->xdebug('processing named complexType '.$attrs['name']);
$this->currentElement = false;
$this->currentComplexType = $attrs['name'];
$this->complexTypes[$this->currentComplexType] = $attrs;
$this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType';
if(isset($attrs['base']) && ereg(':Array$',$attrs['base'])){
$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
} else {
$this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
}
}else{
$this->xdebug('processing unnamed complexType for element '.$this->currentElement);
$this->currentComplexType = $this->currentElement . '_ContainedType';
$this->currentElement = false;
$this->complexTypes[$this->currentComplexType] = $attrs;
$this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType';
if(isset($attrs['base']) && ereg(':Array$',$attrs['base'])){
$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
} else {
$this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
}
}
break;
case 'element':
// elements defined as part of a complex type should
// not really be added to $this->elements, but for some
// reason, they are
if(isset($attrs['type'])){
$this->xdebug("processing typed element ".$attrs['name']." of type ".$attrs['type']);
$this->currentElement = $attrs['name'];
$this->elements[ $attrs['name'] ] = $attrs;
$this->elements[ $attrs['name'] ]['typeClass'] = 'element';
if (!isset($this->elements[ $attrs['name'] ]['form'])) {
$this->elements[ $attrs['name'] ]['form'] = $this->schemaInfo['elementFormDefault'];
}
$ename = $attrs['name'];
} elseif(isset($attrs['ref'])){
$ename = $attrs['ref'];
} else {
$this->xdebug("processing untyped element ".$attrs['name']);
$this->currentElement = $attrs['name'];
$this->elements[ $attrs['name'] ] = $attrs;
$this->elements[ $attrs['name'] ]['typeClass'] = 'element';
$this->elements[ $attrs['name'] ]['type'] = $this->schemaTargetNamespace . ':' . $attrs['name'] . '_ContainedType';
if (!isset($this->elements[ $attrs['name'] ]['form'])) {
$this->elements[ $attrs['name'] ]['form'] = $this->schemaInfo['elementFormDefault'];
}
}
if(isset($ename) && $this->currentComplexType){
$this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs;
}
break;
// we ignore enumeration values
//case 'enumeration':
//break;
case 'import':
if (isset($attrs['schemaLocation'])) {
//$this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']);
$this->imports[$attrs['namespace']][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
} else {
//$this->xdebug('import namespace ' . $attrs['namespace']);
$this->imports[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
$this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace'];
}
}
break;
case 'restriction':
//$this->xdebug("in restriction for currentComplexType: $this->currentComplexType and currentElement: $this->currentElement");
if($this->currentElement){
$this->elements[$this->currentElement]['type'] = $attrs['base'];
} elseif($this->currentSimpleType){
$this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base'];
} elseif($this->currentComplexType){
$this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base'];
if(strstr($attrs['base'],':') == ':Array'){
$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
}
}
break;
case 'schema':
$this->schemaInfo = $attrs;
$this->schemaInfo['schemaVersion'] = $this->getNamespaceFromPrefix($prefix);
if (isset($attrs['targetNamespace'])) {
$this->schemaTargetNamespace = $attrs['targetNamespace'];
}
if (!isset($attrs['elementFormDefault'])) {
$this->schemaInfo['elementFormDefault'] = 'unqualified';
}
break;
case 'simpleType':
if(isset($attrs['name'])){
$this->xdebug("processing simpleType for name " . $attrs['name']);
$this->currentSimpleType = $attrs['name'];
$this->simpleTypes[ $attrs['name'] ] = $attrs;
$this->simpleTypes[ $attrs['name'] ]['typeClass'] = 'simpleType';
$this->simpleTypes[ $attrs['name'] ]['phpType'] = 'scalar';
} else {
//echo 'not parsing: '.$name;
//var_dump($attrs);
}
break;
default:
//$this->xdebug("do not have anything to do for element $name");
}
}
Here is the call graph for this function:| XMLSchema::schemaStartElement | ( | $ | parser, | |
| $ | name, | |||
| $ | attrs | |||
| ) |
start-element handler
| string | $parser XML parser object | |
| string | $name element name | |
| string | $attrs associative array of attributes private |
Definition at line 160 of file class.xmlschema.php.
References $depth, $pos, nusoap_base::expandQname(), nusoap_base::getLocalPart(), nusoap_base::getNamespaceFromPrefix(), nusoap_base::getPrefix(), nusoap_base::getPrefixFromNamespace(), nusoap_base::varDump(), and xdebug().
{
// position in the total number of elements, starting from 0
$pos = $this->position++;
$depth = $this->depth++;
// set self as current value for this depth
$this->depth_array[$depth] = $pos;
$this->message[$pos] = array('cdata' => '');
if ($depth > 0) {
$this->defaultNamespace[$pos] = $this->defaultNamespace[$this->depth_array[$depth - 1]];
} else {
$this->defaultNamespace[$pos] = false;
}
// get element prefix
if($prefix = $this->getPrefix($name)){
// get unqualified name
$name = $this->getLocalPart($name);
} else {
$prefix = '';
}
// loop thru attributes, expanding, and registering namespace declarations
if(count($attrs) > 0){
foreach($attrs as $k => $v){
// if ns declarations, add to class level array of valid namespaces
if(ereg("^xmlns",$k)){
//$this->xdebug("$k: $v");
//$this->xdebug('ns_prefix: '.$this->getPrefix($k));
if($ns_prefix = substr(strrchr($k,':'),1)){
//$this->xdebug("Add namespace[$ns_prefix] = $v");
$this->namespaces[$ns_prefix] = $v;
} else {
$this->defaultNamespace[$pos] = $v;
if (! $this->getPrefixFromNamespace($v)) {
$this->namespaces['ns'.(count($this->namespaces)+1)] = $v;
}
}
if($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema'){
$this->XMLSchemaVersion = $v;
$this->namespaces['xsi'] = $v.'-instance';
}
}
}
foreach($attrs as $k => $v){
// expand each attribute
$k = strpos($k,':') ? $this->expandQname($k) : $k;
$v = strpos($v,':') ? $this->expandQname($v) : $v;
$eAttrs[$k] = $v;
}
$attrs = $eAttrs;
} else {
$attrs = array();
}
// find status, register data
switch($name){
case 'all':
case 'choice':
case 'sequence':
//$this->xdebug("compositor $name for currentComplexType: $this->currentComplexType and currentElement: $this->currentElement");
$this->complexTypes[$this->currentComplexType]['compositor'] = $name;
if($name == 'all' || $name == 'sequence'){
$this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
}
break;
case 'attribute':
//$this->xdebug("parsing attribute $attrs[name] $attrs[ref] of value: ".$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']);
$this->xdebug("parsing attribute " . $this->varDump($attrs));
if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
$v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
if (!strpos($v, ':')) {
// no namespace in arrayType attribute value...
if ($this->defaultNamespace[$pos]) {
// ...so use the default
$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
}
}
}
if(isset($attrs['name'])){
$this->attributes[$attrs['name']] = $attrs;
$aname = $attrs['name'];
} elseif(isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType'){
if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
$aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
} else {
$aname = '';
}
} elseif(isset($attrs['ref'])){
$aname = $attrs['ref'];
$this->attributes[$attrs['ref']] = $attrs;
}
if(isset($this->currentComplexType)){
$this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs;
} elseif(isset($this->currentElement)){
$this->elements[$this->currentElement]['attrs'][$aname] = $attrs;
}
// arrayType attribute
if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType'){
$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
$prefix = $this->getPrefix($aname);
if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])){
$v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
} else {
$v = '';
}
if(strpos($v,'[,]')){
$this->complexTypes[$this->currentComplexType]['multidimensional'] = true;
}
$v = substr($v,0,strpos($v,'[')); // clip the []
if(!strpos($v,':') && isset($this->typemap[$this->XMLSchemaVersion][$v])){
$v = $this->XMLSchemaVersion.':'.$v;
}
$this->complexTypes[$this->currentComplexType]['arrayType'] = $v;
}
break;
case 'complexType':
if(isset($attrs['name'])){
$this->xdebug('processing named complexType '.$attrs['name']);
$this->currentElement = false;
$this->currentComplexType = $attrs['name'];
$this->complexTypes[$this->currentComplexType] = $attrs;
$this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType';
if(isset($attrs['base']) && ereg(':Array$',$attrs['base'])){
$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
} else {
$this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
}
}else{
$this->xdebug('processing unnamed complexType for element '.$this->currentElement);
$this->currentComplexType = $this->currentElement . '_ContainedType';
$this->currentElement = false;
$this->complexTypes[$this->currentComplexType] = $attrs;
$this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType';
if(isset($attrs['base']) && ereg(':Array$',$attrs['base'])){
$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
} else {
$this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
}
}
break;
case 'element':
// elements defined as part of a complex type should
// not really be added to $this->elements, but for some
// reason, they are
if(isset($attrs['type'])){
$this->xdebug("processing typed element ".$attrs['name']." of type ".$attrs['type']);
$this->currentElement = $attrs['name'];
$this->elements[ $attrs['name'] ] = $attrs;
$this->elements[ $attrs['name'] ]['typeClass'] = 'element';
if (!isset($this->elements[ $attrs['name'] ]['form'])) {
$this->elements[ $attrs['name'] ]['form'] = $this->schemaInfo['elementFormDefault'];
}
$ename = $attrs['name'];
} elseif(isset($attrs['ref'])){
$ename = $attrs['ref'];
} else {
$this->xdebug("processing untyped element ".$attrs['name']);
$this->currentElement = $attrs['name'];
$this->elements[ $attrs['name'] ] = $attrs;
$this->elements[ $attrs['name'] ]['typeClass'] = 'element';
$this->elements[ $attrs['name'] ]['type'] = $this->schemaTargetNamespace . ':' . $attrs['name'] . '_ContainedType';
if (!isset($this->elements[ $attrs['name'] ]['form'])) {
$this->elements[ $attrs['name'] ]['form'] = $this->schemaInfo['elementFormDefault'];
}
}
if(isset($ename) && $this->currentComplexType){
$this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs;
}
break;
// we ignore enumeration values
//case 'enumeration':
//break;
case 'import':
if (isset($attrs['schemaLocation'])) {
//$this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']);
$this->imports[$attrs['namespace']][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
} else {
//$this->xdebug('import namespace ' . $attrs['namespace']);
$this->imports[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
$this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace'];
}
}
break;
case 'restriction':
//$this->xdebug("in restriction for currentComplexType: $this->currentComplexType and currentElement: $this->currentElement");
if($this->currentElement){
$this->elements[$this->currentElement]['type'] = $attrs['base'];
} elseif($this->currentSimpleType){
$this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base'];
} elseif($this->currentComplexType){
$this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base'];
if(strstr($attrs['base'],':') == ':Array'){
$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
}
}
break;
case 'schema':
$this->schemaInfo = $attrs;
$this->schemaInfo['schemaVersion'] = $this->getNamespaceFromPrefix($prefix);
if (isset($attrs['targetNamespace'])) {
$this->schemaTargetNamespace = $attrs['targetNamespace'];
}
if (!isset($attrs['elementFormDefault'])) {
$this->schemaInfo['elementFormDefault'] = 'unqualified';
}
break;
case 'simpleType':
if(isset($attrs['name'])){
$this->xdebug("processing simpleType for name " . $attrs['name']);
$this->currentSimpleType = $attrs['name'];
$this->simpleTypes[ $attrs['name'] ] = $attrs;
$this->simpleTypes[ $attrs['name'] ]['typeClass'] = 'simpleType';
$this->simpleTypes[ $attrs['name'] ]['phpType'] = 'scalar';
} else {
//echo 'not parsing: '.$name;
//var_dump($attrs);
}
break;
default:
//$this->xdebug("do not have anything to do for element $name");
}
}
Here is the call graph for this function:| XMLSchema::serializeSchema | ( | ) |
serialize the schema
public
Definition at line 1146 of file nusoap.php.
References $list, $xml, and nusoap_base::getPrefixFromNamespace().
{
$schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion);
$xml = '';
// imports
if (sizeof($this->imports) > 0) {
foreach($this->imports as $ns => $list) {
foreach ($list as $ii) {
if ($ii['location'] != '') {
$xml .= " <$schemaPrefix:import location=\"" . $ii['location'] . '" namespace="' . $ns . "\" />\n";
} else {
$xml .= " <$schemaPrefix:import namespace=\"" . $ns . "\" />\n";
}
}
}
}
// complex types
foreach($this->complexTypes as $typeName => $attrs){
$contentStr = '';
// serialize child elements
if(isset($attrs['elements']) && (count($attrs['elements']) > 0)){
foreach($attrs['elements'] as $element => $eParts){
if(isset($eParts['ref'])){
$contentStr .= " <$schemaPrefix:element ref=\"$element\"/>\n";
} else {
$contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\"/>\n";
}
}
}
// attributes
if(isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)){
foreach($attrs['attrs'] as $attr => $aParts){
$contentStr .= " <$schemaPrefix:attribute ref=\"".$this->contractQName($aParts['ref']).'"';
if(isset($aParts['http://schemas.xmlsoap.org/wsdl/:arrayType'])){
$this->usedNamespaces['wsdl'] = $this->namespaces['wsdl'];
$contentStr .= ' wsdl:arrayType="'.$this->contractQName($aParts['http://schemas.xmlsoap.org/wsdl/:arrayType']).'"';
}
$contentStr .= "/>\n";
}
}
// if restriction
if( isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != ''){
$contentStr = " <$schemaPrefix:restriction base=\"".$this->contractQName($attrs['restrictionBase'])."\">\n".$contentStr." </$schemaPrefix:restriction>\n";
}
// compositor obviates complex/simple content
if(isset($attrs['compositor']) && ($attrs['compositor'] != '')){
$contentStr = " <$schemaPrefix:$attrs[compositor]>\n".$contentStr." </$schemaPrefix:$attrs[compositor]>\n";
}
// complex or simple content
elseif((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)){
$contentStr = " <$schemaPrefix:complexContent>\n".$contentStr." </$schemaPrefix:complexContent>\n";
}
// finalize complex type
if($contentStr != ''){
$contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n".$contentStr." </$schemaPrefix:complexType>\n";
} else {
$contentStr = " <$schemaPrefix:complexType name=\"$typeName\"/>\n";
}
$xml .= $contentStr;
}
// simple types
if(isset($this->simpleTypes) && count($this->simpleTypes) > 0){
foreach($this->simpleTypes as $typeName => $attr){
$xml .= " <$schemaPrefix:simpleType name=\"$typeName\">\n <restriction base=\"".$this->contractQName($eParts['type'])."\"/>\n </$schemaPrefix:simpleType>";
}
}
// elements
if(isset($this->elements) && count($this->elements) > 0){
foreach($this->elements as $element => $eParts){
$xml .= " <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts['type'])."\"/>\n";
}
}
// attributes
if(isset($this->attributes) && count($this->attributes) > 0){
foreach($this->attributes as $attr => $aParts){
$xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"".$this->contractQName($aParts['type'])."\"\n/>";
}
}
// finish 'er up
$el = "<$schemaPrefix:schema targetNamespace=\"$this->schemaTargetNamespace\"\n";
foreach (array_diff($this->usedNamespaces, $this->enclosingNamespaces) as $nsp => $ns) {
$el .= " xmlns:$nsp=\"$ns\"\n";
}
$xml = $el . ">\n".$xml."</$schemaPrefix:schema>\n";
return $xml;
}
Here is the call graph for this function:| XMLSchema::serializeSchema | ( | ) |
serialize the schema
public
Definition at line 429 of file class.xmlschema.php.
References $list, $xml, and nusoap_base::getPrefixFromNamespace().
{
$schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion);
$xml = '';
// imports
if (sizeof($this->imports) > 0) {
foreach($this->imports as $ns => $list) {
foreach ($list as $ii) {
if ($ii['location'] != '') {
$xml .= " <$schemaPrefix:import location=\"" . $ii['location'] . '" namespace="' . $ns . "\" />\n";
} else {
$xml .= " <$schemaPrefix:import namespace=\"" . $ns . "\" />\n";
}
}
}
}
// complex types
foreach($this->complexTypes as $typeName => $attrs){
$contentStr = '';
// serialize child elements
if(isset($attrs['elements']) && (count($attrs['elements']) > 0)){
foreach($attrs['elements'] as $element => $eParts){
if(isset($eParts['ref'])){
$contentStr .= " <$schemaPrefix:element ref=\"$element\"/>\n";
} else {
$contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\"/>\n";
}
}
}
// attributes
if(isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)){
foreach($attrs['attrs'] as $attr => $aParts){
$contentStr .= " <$schemaPrefix:attribute ref=\"".$this->contractQName($aParts['ref']).'"';
if(isset($aParts['http://schemas.xmlsoap.org/wsdl/:arrayType'])){
$this->usedNamespaces['wsdl'] = $this->namespaces['wsdl'];
$contentStr .= ' wsdl:arrayType="'.$this->contractQName($aParts['http://schemas.xmlsoap.org/wsdl/:arrayType']).'"';
}
$contentStr .= "/>\n";
}
}
// if restriction
if( isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != ''){
$contentStr = " <$schemaPrefix:restriction base=\"".$this->contractQName($attrs['restrictionBase'])."\">\n".$contentStr." </$schemaPrefix:restriction>\n";
}
// compositor obviates complex/simple content
if(isset($attrs['compositor']) && ($attrs['compositor'] != '')){
$contentStr = " <$schemaPrefix:$attrs[compositor]>\n".$contentStr." </$schemaPrefix:$attrs[compositor]>\n";
}
// complex or simple content
elseif((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)){
$contentStr = " <$schemaPrefix:complexContent>\n".$contentStr." </$schemaPrefix:complexContent>\n";
}
// finalize complex type
if($contentStr != ''){
$contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n".$contentStr." </$schemaPrefix:complexType>\n";
} else {
$contentStr = " <$schemaPrefix:complexType name=\"$typeName\"/>\n";
}
$xml .= $contentStr;
}
// simple types
if(isset($this->simpleTypes) && count($this->simpleTypes) > 0){
foreach($this->simpleTypes as $typeName => $attr){
$xml .= " <$schemaPrefix:simpleType name=\"$typeName\">\n <restriction base=\"".$this->contractQName($eParts['type'])."\"/>\n </$schemaPrefix:simpleType>";
}
}
// elements
if(isset($this->elements) && count($this->elements) > 0){
foreach($this->elements as $element => $eParts){
$xml .= " <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts['type'])."\"/>\n";
}
}
// attributes
if(isset($this->attributes) && count($this->attributes) > 0){
foreach($this->attributes as $attr => $aParts){
$xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"".$this->contractQName($aParts['type'])."\"\n/>";
}
}
// finish 'er up
$el = "<$schemaPrefix:schema targetNamespace=\"$this->schemaTargetNamespace\"\n";
foreach (array_diff($this->usedNamespaces, $this->enclosingNamespaces) as $nsp => $ns) {
$el .= " xmlns:$nsp=\"$ns\"\n";
}
$xml = $el . ">\n".$xml."</$schemaPrefix:schema>\n";
return $xml;
}
Here is the call graph for this function:| XMLSchema::serializeTypeDef | ( | $ | type | ) |
returns a sample serialization of a given type, or false if no type by the given name
| string | $type, name of type |
Definition at line 621 of file class.xmlschema.php.
References $data, $type, and getTypeDef().
Referenced by serializeTypeDef().
{
//print "in sTD() for type $type<br>";
if($typeDef = $this->getTypeDef($type)){
$str .= '<'.$type;
if(is_array($typeDef['attrs'])){
foreach($attrs as $attName => $data){
$str .= " $attName=\"{type = ".$data['type']."}\"";
}
}
$str .= " xmlns=\"".$this->schema['targetNamespace']."\"";
if(count($typeDef['elements']) > 0){
$str .= ">";
foreach($typeDef['elements'] as $element => $eData){
$str .= $this->serializeTypeDef($element);
}
$str .= "</$type>";
} elseif($typeDef['typeClass'] == 'element') {
$str .= "></$type>";
} else {
$str .= "/>";
}
return $str;
}
return false;
}
Here is the call graph for this function:
Here is the caller graph for this function:| XMLSchema::serializeTypeDef | ( | $ | type | ) |
returns a sample serialization of a given type, or false if no type by the given name
| string | $type, name of type |
Definition at line 1338 of file nusoap.php.
References $data, $type, getTypeDef(), and serializeTypeDef().
{
//print "in sTD() for type $type<br>";
if($typeDef = $this->getTypeDef($type)){
$str .= '<'.$type;
if(is_array($typeDef['attrs'])){
foreach($attrs as $attName => $data){
$str .= " $attName=\"{type = ".$data['type']."}\"";
}
}
$str .= " xmlns=\"".$this->schema['targetNamespace']."\"";
if(count($typeDef['elements']) > 0){
$str .= ">";
foreach($typeDef['elements'] as $element => $eData){
$str .= $this->serializeTypeDef($element);
}
$str .= "</$type>";
} elseif($typeDef['typeClass'] == 'element') {
$str .= "></$type>";
} else {
$str .= "/>";
}
return $str;
}
return false;
}
Here is the call graph for this function:| XMLSchema::typeToForm | ( | $ | name, | |
| $ | type | |||
| ) |
returns HTML form elements that allow a user to enter values for creating an instance of the given type.
| string | $name, name for type instance | |
| string | $type, name of type |
Definition at line 1373 of file nusoap.php.
References $type, and getTypeDef().
{
// get typedef
if($typeDef = $this->getTypeDef($type)){
// if struct
if($typeDef['phpType'] == 'struct'){
$buffer .= '<table>';
foreach($typeDef['elements'] as $child => $childDef){
$buffer .= "
<tr><td align='right'>$childDef[name] (type: ".$this->getLocalPart($childDef['type'])."):</td>
<td><input type='text' name='parameters[".$name."][$childDef[name]]'></td></tr>";
}
$buffer .= '</table>';
// if array
} elseif($typeDef['phpType'] == 'array'){
$buffer .= '<table>';
for($i=0;$i < 3; $i++){
$buffer .= "
<tr><td align='right'>array item (type: $typeDef[arrayType]):</td>
<td><input type='text' name='parameters[".$name."][]'></td></tr>";
}
$buffer .= '</table>';
// if scalar
} else {
$buffer .= "<input type='text' name='parameters[$name]'>";
}
} else {
$buffer .= "<input type='text' name='parameters[$name]'>";
}
return $buffer;
}
Here is the call graph for this function:| XMLSchema::typeToForm | ( | $ | name, | |
| $ | type | |||
| ) |
returns HTML form elements that allow a user to enter values for creating an instance of the given type.
| string | $name, name for type instance | |
| string | $type, name of type |
Definition at line 656 of file class.xmlschema.php.
References $type, and getTypeDef().
{
// get typedef
if($typeDef = $this->getTypeDef($type)){
// if struct
if($typeDef['phpType'] == 'struct'){
$buffer .= '<table>';
foreach($typeDef['elements'] as $child => $childDef){
$buffer .= "
<tr><td align='right'>$childDef[name] (type: ".$this->getLocalPart($childDef['type'])."):</td>
<td><input type='text' name='parameters[".$name."][$childDef[name]]'></td></tr>";
}
$buffer .= '</table>';
// if array
} elseif($typeDef['phpType'] == 'array'){
$buffer .= '<table>';
for($i=0;$i < 3; $i++){
$buffer .= "
<tr><td align='right'>array item (type: $typeDef[arrayType]):</td>
<td><input type='text' name='parameters[".$name."][]'></td></tr>";
}
$buffer .= '</table>';
// if scalar
} else {
$buffer .= "<input type='text' name='parameters[$name]'>";
}
} else {
$buffer .= "<input type='text' name='parameters[$name]'>";
}
return $buffer;
}
Here is the call graph for this function:| XMLSchema::xdebug | ( | $ | string | ) |
adds debug data to the clas level debug string
| string | $string debug data private |
Definition at line 522 of file class.xmlschema.php.
References nusoap_base::debug().
Referenced by addComplexType(), addSimpleType(), getTypeDef(), and schemaStartElement().
{
$this->debug('<' . $this->schemaTargetNamespace . '> '.$string);
}
Here is the call graph for this function:
Here is the caller graph for this function:| XMLSchema::xdebug | ( | $ | string | ) |
adds debug data to the clas level debug string
| string | $string debug data private |
Definition at line 1239 of file nusoap.php.
References nusoap_base::debug().
{
$this->debug('<' . $this->schemaTargetNamespace . '> '.$string);
}
Here is the call graph for this function:| XMLSchema::XMLSchema | ( | $ | schema = '', |
|
| $ | xml = '', |
|||
| $ | namespaces = array() | |||
| ) |
constructor
| string | $schema schema document URI | |
| string | $xml xml document URI | |
| string | $namespaces namespaces defined in enclosing XML public |
Definition at line 53 of file class.xmlschema.php.
References nusoap_base::$namespaces, $schema, $xml, nusoap_base::debug(), and parseFile().
{
$this->debug('xmlschema class instantiated, inside constructor');
// files
$this->schema = $schema;
$this->xml = $xml;
// namespaces
$this->enclosingNamespaces = $namespaces;
$this->namespaces = array_merge($this->namespaces, $namespaces);
// parse schema file
if($schema != ''){
$this->debug('initial schema file: '.$schema);
$this->parseFile($schema, 'schema');
}
// parse xml file
if($xml != ''){
$this->debug('initial xml file: '.$xml);
$this->parseFile($xml, 'xml');
}
}
Here is the call graph for this function:| XMLSchema::XMLSchema | ( | $ | schema = '', |
|
| $ | xml = '', |
|||
| $ | namespaces = array() | |||
| ) |
constructor
| string | $schema schema document URI | |
| string | $xml xml document URI | |
| string | $namespaces namespaces defined in enclosing XML public |
Definition at line 770 of file nusoap.php.
References nusoap_base::$namespaces, $schema, $xml, nusoap_base::debug(), and parseFile().
{
$this->debug('xmlschema class instantiated, inside constructor');
// files
$this->schema = $schema;
$this->xml = $xml;
// namespaces
$this->enclosingNamespaces = $namespaces;
$this->namespaces = array_merge($this->namespaces, $namespaces);
// parse schema file
if($schema != ''){
$this->debug('initial schema file: '.$schema);
$this->parseFile($schema, 'schema');
}
// parse xml file
if($xml != ''){
$this->debug('initial xml file: '.$xml);
$this->parseFile($xml, 'xml');
}
}
Here is the call graph for this function:| XMLSchema::$attributes = array() |
Definition at line 28 of file class.xmlschema.php.
| XMLSchema::$complexTypes = array() |
Definition at line 29 of file class.xmlschema.php.
| XMLSchema::$currentComplexType = false |
Definition at line 30 of file class.xmlschema.php.
| XMLSchema::$currentElement = false |
Definition at line 32 of file class.xmlschema.php.
| XMLSchema::$currentSimpleType = false |
Definition at line 34 of file class.xmlschema.php.
| XMLSchema::$defaultNamespace = array() |
Definition at line 43 of file class.xmlschema.php.
| XMLSchema::$depth = 0 |
Definition at line 40 of file class.xmlschema.php.
Referenced by schemaStartElement().
| XMLSchema::$depth_array = array() |
Definition at line 41 of file class.xmlschema.php.
| XMLSchema::$elements = array() |
Definition at line 31 of file class.xmlschema.php.
Referenced by addComplexType().
| XMLSchema::$enclosingNamespaces |
Definition at line 23 of file class.xmlschema.php.
| XMLSchema::$imports = array() |
Definition at line 36 of file class.xmlschema.php.
| XMLSchema::$message = array() |
Definition at line 42 of file class.xmlschema.php.
| XMLSchema::$parser |
Definition at line 38 of file class.xmlschema.php.
| XMLSchema::$position = 0 |
Definition at line 39 of file class.xmlschema.php.
| XMLSchema::$schema = '' |
Definition at line 20 of file class.xmlschema.php.
Referenced by XMLSchema().
| XMLSchema::$schemaInfo = array() |
Definition at line 25 of file class.xmlschema.php.
| XMLSchema::$schemaTargetNamespace = '' |
Definition at line 26 of file class.xmlschema.php.
| XMLSchema::$simpleTypes = array() |
Definition at line 33 of file class.xmlschema.php.
| XMLSchema::$xml = '' |
Definition at line 21 of file class.xmlschema.php.
Referenced by parseFile(), parseString(), serializeSchema(), and XMLSchema().
1.7.1