Class XMLSchema

Description

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 :)

  • access: public
  • version: $Id: class.xmlschema.php,v 1.39 2005/08/04 01:27:42 snichol Exp $
  • author: Dietrich Ayala <dietrich@ganx4.com>

Located in /core/nusoap/lib/class.xmlschema.php (line 17)

nusoap_base
   |
   --XMLSchema
Variable Summary
Method Summary
XMLSchema XMLSchema ([string $schema = ''], [string $xml = ''], [string $namespaces = array()])
void addComplexType (name $name, [typeClass $typeClass = 'complexType'], [phpType: $phpType = 'array'], [compositor $compositor = ''], [restrictionBase $restrictionBase = ''], [elements $elements = array()], [attrs $attrs = array()], [arrayType: $arrayType = ''])
void addElement (array $attrs)
void addSimpleType (string $name, [string $restrictionBase = ''], [string $typeClass = 'simpleType'], [string $phpType = 'scalar'], [array $enumeration = array()])
mixed getPHPType (mixed $type, mixed $ns, string $type,, string $ns,)
mixed getTypeDef (string $type)
boolean parseFile (mixed $xml, mixed $type, string $xml,, string $type,)
void serializeSchema ()
mixed serializeTypeDef (mixed $type, string $type,)
string typeToForm (mixed $name, mixed $type, string $name,, string $type,)
Variables
mixed $attributes = array() (line 28)
mixed $complexTypes = array() (line 29)
mixed $complexTypeStack = array() (line 30)
mixed $currentComplexType = null (line 31)
mixed $currentElement = null (line 34)
mixed $currentSimpleType = null (line 37)
mixed $defaultNamespace = array() (line 46)
mixed $depth = 0 (line 43)
mixed $depth_array = array() (line 44)
mixed $elements = array() (line 32)
mixed $elementStack = array() (line 33)
mixed $enclosingNamespaces (line 23)
mixed $imports = array() (line 39)
mixed $message = array() (line 45)
mixed $parser (line 41)
mixed $position = 0 (line 42)
mixed $schema = '' (line 20)
mixed $schemaInfo = array() (line 25)
mixed $schemaTargetNamespace = '' (line 26)
mixed $simpleTypes = array() (line 35)
mixed $simpleTypeStack = array() (line 36)
mixed $xml = '' (line 21)
Methods
Constructor XMLSchema (line 56)

constructor

  • access: public
XMLSchema XMLSchema ([string $schema = ''], [string $xml = ''], [string $namespaces = array()])
  • string $schema: schema document URI
  • string $xml: xml document URI
  • string $namespaces: namespaces defined in enclosing XML
addComplexType (line 842)

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') );

void addComplexType (name $name, [typeClass $typeClass = 'complexType'], [phpType: $phpType = 'array'], [compositor $compositor = ''], [restrictionBase $restrictionBase = ''], [elements $elements = array()], [attrs $attrs = array()], [arrayType: $arrayType = ''])
  • name $name
  • typeClass $typeClass: (complexType|simpleType|attribute)
  • phpType: $phpType: currently supported are array and struct (php assoc array)
  • compositor $compositor: (all|sequence|choice)
  • restrictionBase $restrictionBase: namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
  • elements $elements: = array ( name = array(name=>'',type=>'') )
  • attrs $attrs: = array( array( 'ref' => "http://schemas.xmlsoap.org/soap/encoding/:arrayType", "http://schemas.xmlsoap.org/wsdl/:arrayType" => "string[]" ) )
  • arrayType: $arrayType: namespace:name (http://www.w3.org/2001/XMLSchema:string)
addElement (line 890)

adds an element to the schema

  • access: public
  • see: xmlschema
void addElement (array $attrs)
  • array $attrs: attributes that must include name and type
addSimpleType (line 870)

adds a simple type to the schema

void addSimpleType (string $name, [string $restrictionBase = ''], [string $typeClass = 'simpleType'], [string $phpType = 'scalar'], [array $enumeration = array()])
  • string $name
  • string $restrictionBase: namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
  • string $typeClass: (should always be simpleType)
  • string $phpType: (should always be scalar)
  • array $enumeration: array of values
getPHPType (line 633)

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'

  • deprecated:
  • access: public
mixed getPHPType (mixed $type, mixed $ns, string $type,, string $ns,)
  • string $type,: name of defined type
  • string $ns,: namespace of type
getTypeDef (line 666)

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

For a complexType typeDef = array( 'restrictionBase' => '', 'phpType' => '', 'compositor' => '(sequence|all)', 'elements' => array(), // refs to elements array 'attrs' => array() // refs to attributes array ... and so on (see addComplexType) )

For simpleType or element, the array has different keys.

mixed getTypeDef (string $type)
  • string $type
parseFile (line 89)

parse an XML file

  • access: public
boolean parseFile (mixed $xml, mixed $type, string $xml,, string $type,)
  • string $xml,: path/URL to XML file
  • string $type,: (schema | xml)
serializeSchema (line 505)

serialize the schema

  • access: public
void serializeSchema ()
serializeTypeDef (line 735)

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

  • deprecated:
  • access: public
mixed serializeTypeDef (mixed $type, string $type,)
  • string $type,: name of type
typeToForm (line 771)

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

  • deprecated:
  • access: public
string typeToForm (mixed $name, mixed $type, string $name,, string $type,)
  • string $name,: name for type instance
  • string $type,: name of type

Documentation generated on Tue, 4 Oct 2005 21:59:01 -0700 by phpDocumentor 1.3.0RC3