diff options
Diffstat (limited to '1.4.0/dom/codeGen/1.4/om')
31 files changed, 1734 insertions, 0 deletions
diff --git a/1.4.0/dom/codeGen/1.4/om/base-types.php b/1.4.0/dom/codeGen/1.4/om/base-types.php new file mode 100644 index 0000000..48fe862 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/base-types.php @@ -0,0 +1,172 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class _type +{ + var $type = array(); + + function _type() + { + $this->type[] = "MotherOfAllTypes"; + } + + function isOfType( $type ) + { + return( $type == $this->type[ count( $this->type ) - 1 ] ); + } + + function getType() + { + $type = "NULL"; + if ( count( $this->type ) > 0 ) { $type = $this->type[ 0 ]; } + return $type; + } + + function isAncestor( $type ) + { + return in_array( $type, $this->type ); + } +} + +class _typedData extends _type +{ + var $data; + + var $attributeMeta = array(); + var $attributes = array(); + + function _typedData() + { + $this->type[] = "TypedData"; + parent::_type(); + } + + function _addAttribute( $name, $meta ) + { + $this->attributeMeta[ $name ] = $meta; + } + + function setAttribute( $name, $value ) + { + // Make sure we know about the attribute before setting it + if ( isset( $this->attributeMeta[ $name ] ) ) + { + $this->attributes[ $name ] = $value; + } + } + + function getAttribute( $name ) + { + $val = ""; + if ( isset( $this->attributeMeta[ $name ] ) && isset( $this->attributes[ $name ] ) ) { + $val = $this->attributes[ $name ]; + } + return $val; + } + + function & getAttributes() + { + return $this->attributes; + } + + function set( & $buffer ) + { + $this->data = $buffer; + } + + function append( & $buffer ) + { + $this->data .= $buffer; + } + + function get() + { + return $this->data; + } +} + +class _elementSet extends _typedData +{ + var $elementMeta = array(); + var $elements = array(); + + function _elementSet() + { + $this->_addAttribute( 'minOccurs', array( 'type' => 'xs:integer' ) ); + $this->setAttribute( 'minOccurs', '1' ); + $this->_addAttribute( 'maxOccurs', array( 'type' => 'xs:integer' ) ); + $this->setAttribute( 'maxOccurs', '1' ); + + $this->type[] = "ElementSet"; + parent::_typedData(); + } + + function _addElement( $name, $attrs ) + { + $this->elementMeta[ $name ] = $attrs; + } + + function addElement( & $e ) + { + if ( in_array( $e->getType(), array_keys( $this->elementMeta ) ) ) + { + $this->elements[] = & $e; + } else + { + print "Invalid element ". $e->getType() ."in ". $this->getType() ."\n"; + $this->log( "WARN: " . $e->getType() . " not a valid member of " . $this->getType() ); + } + } + + function & getElements() + { + return $this->elements; + } + + function & getElementsByType( $type ) + { + $list = array(); + for( $i=0; $i<count( $this->elements ); $i++ ) + { + if ( $this->elements[$i]->getType() == $type ) + { + $list[] = & $this->elements[$i]; + } + } + return $list; + } + + function setElement( $name, & $value ) + { + $this->elements[ $name ] = $value; + } + + function exists( $name ) + { + return isset( $this->elements[ $name ] ); + } + + function delete( $name ) + { + unset( $this->elements[ $name ] ); + } + + function _delete( $name ) + { + $this->delete( $name ); + unset( $this->elementMeta[ $name ] ); + } + + function getCount() + { + return count( $this->elements ); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/object-model.php b/1.4.0/dom/codeGen/1.4/om/object-model.php new file mode 100644 index 0000000..271c04b --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/object-model.php @@ -0,0 +1,43 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +require_once( 'om/base-types.php' ); + +require_once( 'om/xsAll.php' ); +require_once( 'om/xsAnnotation.php' ); +require_once( 'om/xsAny.php' ); +require_once( 'om/xsAttribute.php' ); +require_once( 'om/xsChoice.php' ); +require_once( 'om/xsComplexContent.php' ); +require_once( 'om/xsComplexType.php' ); +require_once( 'om/xsAll.php' ); +require_once( 'om/xsDocumentation.php' ); +require_once( 'om/xsAppinfo.php' ); +require_once( 'om/xsElement.php' ); +require_once( 'om/xsEnumeration.php' ); +require_once( 'om/xsExtension.php' ); +require_once( 'om/xsGroup.php' ); +require_once( 'om/xsList.php' ); +require_once( 'om/xsMaxLength.php' ); +require_once( 'om/xsMaxExclusive.php' ); +require_once( 'om/xsMaxInclusive.php' ); +require_once( 'om/xsMinLength.php' ); +require_once( 'om/xsMinExclusive.php' ); +require_once( 'om/xsMinInclusive.php' ); +require_once( 'om/xsPattern.php' ); +require_once( 'om/xsRestriction.php' ); +require_once( 'om/xsSchema.php' ); +require_once( 'om/xsSequence.php' ); +require_once( 'om/xsSimpleContent.php' ); +require_once( 'om/xsSimpleType.php' ); +require_once( 'om/xsUnion.php' ); +require_once( 'om/xsWhiteSpace.php' ); +require_once( 'om/xsImport.php' ); + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsAll.php b/1.4.0/dom/codeGen/1.4/om/xsAll.php new file mode 100644 index 0000000..bbe1b45 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsAll.php @@ -0,0 +1,27 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsAll extends _elementSet +{ + function xsAll() + { + $this->_addElement( 'xsElement', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsAttribute', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->type[] = "xsAll"; + parent::_elementSet(); + } + + function addAllElement( & $e ) + { + $this->addElement( $e ); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsAnnotation.php b/1.4.0/dom/codeGen/1.4/om/xsAnnotation.php new file mode 100644 index 0000000..b6fbd4b --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsAnnotation.php @@ -0,0 +1,31 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsAnnotation extends _elementSet +{ + function xsAnnotation() + { + $this->_addElement( 'xsDocumentation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsAppinfo', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->type[] = "xsAnnotation"; + parent::_elementSet(); + + // Set bounds on number of elements allowable in annotation element + $this->setAttribute( 'minOccurs', '0' ); + $this->setAttribute( 'maxOccurs', 'unbounded' ); + } + + function addAnnotationElement( & $e ) + { + $this->addElement( $e ); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsAny.php b/1.4.0/dom/codeGen/1.4/om/xsAny.php new file mode 100644 index 0000000..3a35831 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsAny.php @@ -0,0 +1,27 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsAny extends _typedData +{ + function xsAny() + { + $this->_addAttribute( 'namespace', array( 'type' => 'xs:anyURI' ) ); + $this->_addAttribute( 'processContents', array( 'type' => 'xs:string' ) ); + + $this->_addAttribute( 'minOccurs', array( 'type' => 'xs:integer' ) ); + $this->setAttribute( 'minOccurs', '1' ); + $this->_addAttribute( 'maxOccurs', array( 'type' => 'xs:integer' ) ); + $this->setAttribute( 'maxOccurs', '1' ); + + $this->type[] = 'xsAny'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsAppinfo.php b/1.4.0/dom/codeGen/1.4/om/xsAppinfo.php new file mode 100644 index 0000000..625296b --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsAppinfo.php @@ -0,0 +1,19 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsAppinfo extends _typedData +{ + function xsAppinfo() + { + $this->type[] = "xsAppinfo"; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsAttribute.php b/1.4.0/dom/codeGen/1.4/om/xsAttribute.php new file mode 100644 index 0000000..f8aa845 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsAttribute.php @@ -0,0 +1,27 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsAttribute extends _elementSet +{ + function xsAttribute() + { + $this->_addAttribute( 'name', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'type', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'use', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'default', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'ref', array( 'type' => 'xs:string' ) ); + + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->type[] = 'xsAttribute'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsChoice.php b/1.4.0/dom/codeGen/1.4/om/xsChoice.php new file mode 100644 index 0000000..9d31c5d --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsChoice.php @@ -0,0 +1,31 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsChoice extends _elementSet +{ + function xsChoice() + { + $this->_addElement( 'xsElement', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsAttribute', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsChoice', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsSequence', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsGroup', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->type[] = "xsChoice"; + parent::_elementSet(); + } + + function addChoiceElement( & $e ) + { + $this->addElement( $e ); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsComplexContent.php b/1.4.0/dom/codeGen/1.4/om/xsComplexContent.php new file mode 100644 index 0000000..2dd1d74 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsComplexContent.php @@ -0,0 +1,24 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsComplexContent extends _elementSet +{ + function xsComplexContent() + { + $this->_addElement( 'xsRestriction', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsExtension', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + +// $this->_addAttribute( 'name', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsComplexContent'; + parent::_elementSet(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsComplexType.php b/1.4.0/dom/codeGen/1.4/om/xsComplexType.php new file mode 100644 index 0000000..5333208 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsComplexType.php @@ -0,0 +1,222 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsComplexType extends _elementSet +{ + function xsComplexType() + { + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsChoice', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsAttribute', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsSequence', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsAll', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsGroup', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsSimpleContent', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsComplexContent', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + + $this->_addAttribute( 'name', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'mixed', array( 'type' => 'xs:string', 'default' => 'false' ) ); + + $this->type[] = 'xsComplexType'; + parent::_elementSet(); + } + + function & generate( $element_context, & $global_elements ) + { + $element_context[] = $this->getAttribute( "name" ); + print implode( ",", $element_context ) . "\n"; + + // Get new factory + $generator = new ElementMeta( $global_elements ); + $generator->setIsAComplexType( true ); + + // Load the class name and a context pre-fix (in case we're inside another element) + $generator->setName( $this->getAttribute( 'name' ) ); + $generator->setContext( $element_context ); + + // Extract any documentation for this node + $a = $this->getElementsByType( 'xsAnnotation' ); + if ( count( $a ) > 0 ) + { + $d = $a[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $d ) > 0 ) + { + $generator->setDocumentation( $d[0]->get() ); + } + } + if ( $this->getAttribute( 'mixed' ) == 'true' ) + { + $generator->setMixed( true ); + } + + $content = $this; // Should only be one + $this->generateComplexType( $content, $generator, $element_context ); + + if ( count( $generator->bag['elements'] ) == 0 ) { + $generator->setIsEmptyContent( true ); + } + + $meta = & $generator->getMeta(); + + if ( count( $element_context ) == 1 ) + { + $global_elements[ $element_context[0] ] = & $meta; + } + + return $meta; + } + + // Flatten choice/all/sequence groups into a single list of contained elements + function flatten( & $element, & $generator, & $context, $maxOccurs ) + { + //print "in flatten "; + $e_list = $element->getElements(); + for( $i=0; $i<count( $e_list ); $i++ ) + { + switch( $e_list[$i]->getType() ) + { + case 'xsChoice': + $generator->setHasChoice( true ); + $generator->addContentModel( 1, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsSequence': + $generator->addContentModel( 0, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsAll': + $generator->addContentModel( 3, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsGroup': + $generator->addContentModel( 2, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + $generator->addGroup( $e_list[$i] ); + case 'xsElement': + $nm = $e_list[$i]->getAttribute( 'name' ); + if ( $nm == '' ) { $nm = $e_list[$i]->getAttribute( 'ref' ); } + $generator->addContentModel( $nm, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + //print "found element!\n"; + // If a containing element/group has a maxOccurs > 1, then inherit it (will flag as array in code gen) + if ( $maxOccurs == 'unbounded' || $maxOccurs > 1 ) + { + $e_list[$i]->setAttribute( 'maxOccurs', $maxOccurs ); + } + $generator->addElement( $e_list[$i], $context ); + break; + case 'xsAttribute': + //print "found attribute!\n"; + $generator->addAttribute( $e_list[$i] ); + break; + case 'xsAny': + print "found an any\n"; + $generator->addContentModel( 4, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + $generator->bag['has_any'] = true; + break; + default: + break; + } + } + $generator->addContentModel( 5, 0, 0 ); //END content model - There will be one extra on every element + } + + //function that reads complex types. will recurse complex type derived heirarchies. + function generateComplexType( $content, & $generator, & $context ) { + //print "in generatecomplextype\n"; + if ( count( $content->getElementsByType( 'xsSimpleContent' ) ) > 0 ) { + //print "found simpleContent!\n"; + $temp = $content->getElementsByType( 'xsSimpleContent' ); + $content = $temp[0]; // Should only be one - now we now find out element's parent class + $temp = & $content->getElements(); + $content = $temp[0]; // Should either be an xsExtension or xsRestriction + $type = $content->getAttribute( 'base' ); + //print "setting extends to ". $type ."\n"; + $generator->setContentType( $type ); + $temp = & $content->getElementsByType( 'xsAttribute' ); + for( $i=0; $i<count( $temp ); $i++ ) { + $generator->addAttribute( $temp[$i] ); + } + } else if ( count( $content->getElementsByType( 'xsComplexContent' ) ) > 0 ) { + //print "found complexContent!\n"; + //ComplexContent specified means type is derived + $temp = $content->getElementsByType( 'xsComplexContent' ); + $content = $temp[0]; // Should only be one - now we now find out element's parent class + $temp = & $content->getElements(); + $content = $temp[0]; // Should either be an xsExtension or xsRestriction + if ( $content->getType() == 'xsExtension' ) { + $generator->bag['isExtension'] = true; + } + if ( $content->getType() == 'xsRestriction' ) { + $generator->bag['isRestriction'] = true; + } + $type = $content->getAttribute( 'base' ); + //print "setting extends to ". $type ."\n"; + $generator->bag['base_type'] = $type; + //Generate the complex type this is derived from + //*************CHANGE NEEDED HERE 8-25 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + for ( $i = 0; $i < count( $GLOBALS['_globals']['complex_types'] ); $i++ ) { + if ( $type == $GLOBALS['_globals']['complex_types'][$i]->getAttribute('name') ) { + $generator->setComplexType( true ); + $generator->bag['ref_elements'][] = $type; + //$this->generateComplexType( $GLOBALS['_globals']['complex_types'][$i], $generator, $context ); + break; + } + } + + // Parse element context + $this->flatten( $content, $generator, $element_context, $content->getAttribute( 'maxOccurs' ) ); + + } else { + //print "found nothing so doing complex content flatten\n"; + // The alternative to xsSimpleContent is xsComplexContent - if it is not specified, it is implied + // Parse element context + $this->flatten( $content, $generator, $element_context, $content->getAttribute( 'maxOccurs' ) ); + if ( count( $generator->bag['elements'] ) == 0 ) { + $generator->setIsEmptyContent( true ); + } + } + } + + function & generateType() { + $vars = array(); + $e = $this->getElements(); + $generator = new TypeMeta(); + + $generator->setType( $this->getAttribute( 'name' ) ); + $generator->setIsComplex( true ); + + $meta = & $generator->getMeta(); + return $meta; + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsDocumentation.php b/1.4.0/dom/codeGen/1.4/om/xsDocumentation.php new file mode 100644 index 0000000..a89ca8e --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsDocumentation.php @@ -0,0 +1,19 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsDocumentation extends _typedData +{ + function xsDocumentation() + { + $this->type[] = "xsDocumentation"; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsElement.php b/1.4.0/dom/codeGen/1.4/om/xsElement.php new file mode 100644 index 0000000..1aa0c8e --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsElement.php @@ -0,0 +1,368 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +require_once( 'src/ElementMeta.php' ); +require_once( 'src/TypeMeta.php' ); + +class xsElement extends _elementSet +{ + function xsElement() + { + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsComplexType', array( 'minOccurs' => '0', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsSimpleType', array( 'minOccurs' => '0', 'maxOccurs' => '1' ) ); + + $this->_addAttribute( 'ref', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'name', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'type', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'abstract', array( 'type' => 'xs:bool' ) ); + $this->_addAttribute( 'substitutionGroup', array( 'type' => 'xs:string' ) ); +// $this->_addAttribute( 'maxOccurs', array( 'type' => 'xs:integer' ) ); +// $this->_addAttribute( 'minOccurs', array( 'type' => 'xs:integer' ) ); + + $this->type[] = 'xsElement'; + parent::_elementSet(); + } + + function & generate( $element_context, & $global_elements ) + { + $element_context[] = $this->getAttribute( "name" ); + print implode( ",", $element_context ) . "\n"; + + // Get new factory + $generator = new ElementMeta( $global_elements ); + + // Load the class name and a context pre-fix (in case we're inside another element) + $generator->setName( $this->getAttribute( 'name' ) ); + $generator->setContext( $element_context ); + $subGroup = $this->getAttribute( 'substitutionGroup' ); + if ( $subGroup != '' ) { + //print "found a subGroup ". $subGroup ."!\n"; + $generator->setSubstitutionGroup( $subGroup ); + $generator->bag['ref_elements'][] = $subGroup; + } + $abstract = $this->getAttribute( 'abstract' ); + if ( $abstract != '' ) { + $generator->setAbstract( $abstract ); + } + + // Extract any documentation for this node + $a = $this->getElementsByType( 'xsAnnotation' ); + if ( count( $a ) > 0 ) + { + $d = $a[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $d ) > 0 ) + { + $generator->setDocumentation( $d[0]->get() ); + } + $ap = $a[0]->getElementsByType( 'xsAppinfo' ); + if ( count( $ap ) > 0 ) + { + $generator->setAppInfo( $ap[0]->get() ); + } + } + + //******************************************************************************************/ + //$generator->setContentType( $this->getAttribute( 'type' ) ); + $type = $this->getAttribute( 'type' ); + $generator->bag['base_type'] = $type; + //check if this type equals a complex type + //print "element ". $this->getAttribute( 'name' ) ." is of type ". $type ."!\n"; + if ( $type != "" ) { + //print "complex types: " . count($GLOBALS['_globals']['complex_types']) . "\n"; + for ( $i = 0; $i < count( $GLOBALS['_globals']['complex_types'] ); $i++ ) { + if ( !strcmp($type, $GLOBALS['_globals']['complex_types'][$i]->getAttribute('name') ) ) { + //print "found a match for ". $type ."\n"; + $generator->setComplexType( true ); + $generator->bag['ref_elements'][] = $type; + break; + } + } + if ( !$generator->bag['complex_type'] ) { + //wasn't a complex type that means it needs a content type + $generator->setContentType( $type ); + } + } + //*******************************************************************************************/ + + // Inspect the semantic structure of this node and extract the elements/attributes + $temp = $this->getElementsByType( 'xsComplexType' ); + + if ( count( $temp ) > 0 ) + { + if ( $temp[0]->getAttribute( 'mixed' ) == 'true' ) + { + $generator->setMixed( true ); + $generator->setContentType( 'ListOfInts' ); + } + + $content = $temp[0]; // Should only be one + $this->generateComplexType( $content, $generator, $element_context ); + if ( count( $generator->bag['elements'] ) == 0 ) { + $generator->setIsEmptyContent( true ); + } + } + else if ( count( $this->getElementsByType( 'xsSimpleType' ) ) > 0 ) { + //inline simple type definition. right now handle as string but needs to be fixed + $generator->bag['simple_type'] = new TypeMeta(); + $temp = $this->getElementsByType( 'xsSimpleType' ); + $this->generateSimpleType( $temp[0], $generator->bag['simple_type'] ); + if ( count( $generator->bag['simple_type']->bag['enum'] ) >0 ) { + $generator->setContentType( $this->getAttribute( 'name' ) ."_type" ); + } + else { + $generator->setContentType( $generator->bag['simple_type']->bag['base'] ); + } + } + + $meta = & $generator->getMeta(); + + if ( count( $element_context ) == 1 ) + { + $global_elements[ $element_context[0] ] = & $meta; + } + + return $meta; + } + + // Flatten choice/all/sequence groups into a single list of contained elements + function flatten( & $element, & $generator, & $context, $maxOccurs ) + { + //print "in flatten "; + $e_list = $element->getElements(); + for( $i=0; $i<count( $e_list ); $i++ ) + { + switch( $e_list[$i]->getType() ) + { + case 'xsChoice': + $generator->setHasChoice( true ); + $generator->addContentModel( 1, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsSequence': + $generator->addContentModel( 0, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsAll': + $generator->addContentModel( 3, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsGroup': + $generator->addContentModel( 2, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + $generator->addGroup( $e_list[$i] ); + case 'xsElement': + $nm = $e_list[$i]->getAttribute( 'name' ); + if ( $nm == '' ) { $nm = $e_list[$i]->getAttribute( 'ref' ); } + $generator->addContentModel( $nm, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + //print "found element!\n"; + // If a containing element/group has a maxOccurs > 1, then inherit it (will flag as array in code gen) + if ( $maxOccurs == 'unbounded' || $maxOccurs > 1 ) + { + $e_list[$i]->setAttribute( 'maxOccurs', $maxOccurs ); + } + $generator->addElement( $e_list[$i], $context ); + break; + case 'xsAttribute': + //print "found attribute!\n"; + $generator->addAttribute( $e_list[$i] ); + break; + case 'xsAny': + print "found an any\n"; + $generator->addContentModel( 4, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + $generator->bag['has_any'] = true; + break; + default: + break; + } + } + $generator->addContentModel( 5, 0, 0 ); //END content model - There will be one extra on every element + } + + //function that reads complex types. will recurse complex type derived heirarchies. + function generateComplexType( $content, & $generator, & $context ) { + //print "in generatecomplextype\n"; + if ( count( $content->getElementsByType( 'xsSimpleContent' ) ) > 0 ) { + //print "found simpleContent!\n"; + $temp = $content->getElementsByType( 'xsSimpleContent' ); + $content = $temp[0]; // Should only be one - now we now find out element's parent class + $temp = & $content->getElements(); + $content = $temp[0]; // Should either be an xsExtension or xsRestriction + $type = $content->getAttribute( 'base' ); + //print "setting extends to ". $type ."\n"; + $generator->setContentType( $type ); + $temp = & $content->getElementsByType( 'xsAttribute' ); + for( $i=0; $i<count( $temp ); $i++ ) { + $generator->addAttribute( $temp[$i] ); + } + } else if ( count( $content->getElementsByType( 'xsComplexContent' ) ) > 0 ) { + //print "found complexContent!\n"; + //ComplexContent specified means type is derived + $temp = $content->getElementsByType( 'xsComplexContent' ); + $content = $temp[0]; // Should only be one - now we now find out element's parent class + $temp = & $content->getElements(); + $content = $temp[0]; // Should either be an xsExtension or xsRestriction + if ( $content->getType() == 'xsExtension' ) { + $generator->bag['isExtension'] = true; + } + if ( $content->getType() == 'xsRestriction' ) { + $generator->bag['isRestriction'] = true; + } + $type = $content->getAttribute( 'base' ); + //print "setting extends to ". $type ."\n"; + $generator->bag['base_type'] = $type; + //Generate the complex type this is derived from + for ( $i = 0; $i < count( $GLOBALS['_globals']['complex_types'] ); $i++ ) { + if ( $type == $GLOBALS['_globals']['complex_types'][$i]->getAttribute('name') ) { + $generator->setComplexType( true ); + $generator->bag['ref_elements'][] = $type; + //$this->generateComplexType( $GLOBALS['_globals']['complex_types'][$i], $generator, $context ); + break; + } + } + + // Parse element context + $this->flatten( $content, $generator, $element_context, $content->getAttribute( 'maxOccurs' ) ); + + } else { + //print "found nothing so doing complex content flatten\n"; + // The alternative to xsSimpleContent is xsComplexContent - if it is not specified, it is implied + // Parse element context + $this->flatten( $content, $generator, $element_context, $content->getAttribute( 'maxOccurs' ) ); + + } + } + + //function that generates the inline simpleType + function generateSimpleType( $content, & $generator ) { + + $e = $content->getElements(); + $generator->setType( $this->getAttribute( 'name' ) ); + //print $this->getAttribute( 'name' ) ." has a simpletype\n"; + $a = $content->getElementsByType( 'xsAnnotation' ); + if ( count( $a ) > 0 ) { + //print "found annotation for ". $this->getAttribute( 'name' ) ."!\n"; + $d = $a[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $d ) > 0 ) + { + //print "found documentation for ". $this->getAttribute( 'name' ) ."!\n"; + $generator->setDocumentation( $d[0]->get() ); + } + $ap = $a[0]->getElementsByType( 'xsAppinfo' ); + if ( count( $ap ) > 0 ) + { + $generator->setAppInfo( $ap[0]->get() ); + } + } + + $idx = 0; + if ( $e[$idx]->getType() == 'xsAnnotation' ) { + $idx = 1; + } + if ( $e[$idx]->getType() == 'xsRestriction' || $e[$idx]->getType() == 'xsExtension' ) + { + $generator->setIsExtension( $e[$idx]->getType() == 'xsExtension' ); + + // Set base class + $generator->setBase( $e[$idx]->getAttribute( 'base' ) ); + + // Look for enums + $enums = $e[$idx]->getElementsByType( 'xsEnumeration' ); + for( $i=0; $i<count( $enums ); $i++ ) + { + $generator->addEnum( $enums[$i]->getAttribute( 'value' ) ); + //print $enums[$i]->getAttribute( 'value' ); + $an = $enums[$i]->getElementsByType('xsAnnotation'); + if ( count( $an ) > 0 ) { + $doc = $an[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $doc ) > 0 ) { + $generator->addEnumDoc( $i, $doc[0]->get() ); + } + $ap = $an[0]->getElementsByType( 'xsAppinfo' ); + if ( count( $ap ) > 0 ) + { + $generator->addEnumAppInfo( $i, $ap[0]->get() ); + } + } + } + + // Look for max/mins + $array_limits = array(); + $min = $e[$idx]->getElementsByType( 'xsMinLength' ); + $max = $e[$idx]->getElementsByType( 'xsMaxLength' ); + $minIn = $e[$idx]->getElementsByType( 'xsMinInclusive' ); + $maxIn = $e[$idx]->getElementsByType( 'xsMaxInclusive' ); + $minEx = $e[$idx]->getElementsByType( 'xsMinExclusive' ); + $maxEx = $e[$idx]->getElementsByType( 'xsMaxExclusive' ); + + if ( count( $min ) > 0 ) + { + $generator->setRestriction( 'minLength', $min[0]->getAttribute( 'value' ) ); + } + + if ( count( $max ) > 0 ) + { + $generator->setRestriction( 'maxLength', $max[0]->getAttribute( 'value' ) ); + } + + if ( count( $minIn ) > 0 ) + { + $generator->setRestriction( 'minInclusive', $minIn[0]->getAttribute( 'value' ) ); + } + + if ( count( $maxIn ) > 0 ) + { + $generator->setRestriction( 'maxInclusive', $maxIn[0]->getAttribute( 'value' ) ); + } + + if ( count( $minEx ) > 0 ) + { + $generator->setRestriction( 'minExclusive', $minEx[0]->getAttribute( 'value' ) ); + } + + if ( count( $maxEx ) > 0 ) + { + $generator->setRestriction( 'maxExclusive', $maxEx[0]->getAttribute( 'value' ) ); + } + } else if ( $e[$idx]->getType() == 'xsList' ) + { + //$extends = "xsList"; + $itemType = $e[$idx]->getAttribute( 'itemType' ); + $generator->setListType( $itemType ); + $generator->bag['isArray'] = true; + } else + { + $this->log( "WARN: unexpected element in xsSimpleType code generation" ); + } + } +} +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsEnumeration.php b/1.4.0/dom/codeGen/1.4/om/xsEnumeration.php new file mode 100644 index 0000000..5b5a2c7 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsEnumeration.php @@ -0,0 +1,23 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsEnumeration extends _elementSet +{ + function xsEnumeration() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:integer' ) ); + + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->type[] = 'xsEnumeration'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsExtension.php b/1.4.0/dom/codeGen/1.4/om/xsExtension.php new file mode 100644 index 0000000..e0ff68a --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsExtension.php @@ -0,0 +1,24 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsExtension extends _elementSet +{ + function xsExtension() + { + $this->_addElement( 'xsAttribute', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsSequence', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->_addAttribute( 'base', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsExtension'; + parent::_elementSet(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsGroup.php b/1.4.0/dom/codeGen/1.4/om/xsGroup.php new file mode 100644 index 0000000..4356087 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsGroup.php @@ -0,0 +1,152 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsGroup extends _elementSet +{ + function xsGroup() + { + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsElement', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsAttribute', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsChoice', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsSequence', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsGroup', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->_addAttribute( 'ref', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'name', array( 'type' => 'xs:string' ) ); + + $this->type[] = "xsGroup"; + parent::_elementSet(); + } + + function addChoiceElement( & $e ) + { + $this->addElement( $e ); + } + + function & generate( $element_context, & $global_elements ) + { + $element_context[] = $this->getAttribute( "name" ); + print implode( ",", $element_context ) . "\n"; + + // Get new factory + $generator = new ElementMeta( $global_elements ); + $generator->setIsAGroup( true ); + + // Load the class name and a context pre-fix (in case we're inside another element) + $generator->setName( $this->getAttribute( 'name' ) ); + $generator->setContext( $element_context ); + + // Extract any documentation for this node + $a = $this->getElementsByType( 'xsAnnotation' ); + if ( count( $a ) > 0 ) + { + $d = $a[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $d ) > 0 ) + { + $generator->setDocumentation( $d[0]->get() ); + } + } + + // Inspect the semantic structure of this node and extract the elements/attributes + $this->flatten( $this, $generator, $element_context, $this->getAttribute( 'maxOccurs' ) ); + + if ( count( $generator->bag['elements'] ) == 0 ) { + $generator->setIsEmptyContent( true ); + } + + $meta = & $generator->getMeta(); + + if ( count( $element_context ) == 1 ) + { + $global_elements[ $element_context[0] ] = & $meta; + } + + return $meta; + } + + // Flatten choice/all/sequence groups into a single list of contained elements + function flatten( & $element, & $generator, & $context, $maxOccurs ) + { + //print "in flatten "; + $e_list = $element->getElements(); + for( $i=0; $i<count( $e_list ); $i++ ) + { + switch( $e_list[$i]->getType() ) + { + case 'xsChoice': + $generator->setHasChoice( true ); + $generator->addContentModel( 1, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsSequence': + $generator->addContentModel( 0, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsAll': + $generator->addContentModel( 3, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsGroup': + $generator->addContentModel( 2, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + $generator->addGroup( $e_list[$i] ); + case 'xsElement': + $nm = $e_list[$i]->getAttribute( 'name' ); + if ( $nm == '' ) { $nm = $e_list[$i]->getAttribute( 'ref' ); } + $generator->addContentModel( $nm, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + //print "found element!\n"; + // If a containing element/group has a maxOccurs > 1, then inherit it (will flag as array in code gen) + if ( $maxOccurs == 'unbounded' || $maxOccurs > 1 ) + { + $e_list[$i]->setAttribute( 'maxOccurs', $maxOccurs ); + } + $generator->addElement( $e_list[$i], $context ); + break; + case 'xsAttribute': + //print "found attribute!\n"; + $generator->addAttribute( $e_list[$i] ); + break; + case 'xsAny': + print "found an any\n"; + $generator->addContentModel( 4, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + $generator->bag['has_any'] = true; + break; + default: + break; + } + } + $generator->addContentModel( 5, 0, 0 ); //END content model - There will be one extra on every element + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsImport.php b/1.4.0/dom/codeGen/1.4/om/xsImport.php new file mode 100644 index 0000000..1f5e6d0 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsImport.php @@ -0,0 +1,22 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsImport extends _typedData +{ + function xsImport() + { + $this->_addAttribute( 'namespace', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'schemaLocation', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsImport'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsList.php b/1.4.0/dom/codeGen/1.4/om/xsList.php new file mode 100644 index 0000000..b1ce038 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsList.php @@ -0,0 +1,49 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsList extends _typedData +{ + var $minLength; + var $maxLength; + + function xsList() + { + global $MAX_ARRAY_LENGTH; + + $this->minLength = 0; + $this->maxLength = $MAX_ARRAY_LENGTH; + + $this->_addAttribute( 'itemType', array( 'type' => 'xs:string' ) ); + $this->setAttribute( 'itemType', 'TypedData' ); + + $this->type[] = 'xsList'; + parent::_typedData(); + } + + // To save the heavyweight object-per-data-point approach, allow a list type + // to parse the buffer into a single array + function set( & $buffer ) + { + eval( '$type = new ' . $this->getAttribute( 'itemType' ) . '();' ); + $this->data = & $type->parse( $buffer ); + +/* for( $i=0; trim( $buffer ) != "" && $i<$this->maxLength; $i++ ) + { + eval( '$this->data[ $i ] = new ' . $this->getAttribute( 'itemType' ) . '();' ); + $this->data[ $i ]->set( $buffer ); + }*/ + } + + function getCount() + { + return count( $this->data ); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsMaxExclusive.php b/1.4.0/dom/codeGen/1.4/om/xsMaxExclusive.php new file mode 100644 index 0000000..8abec02 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsMaxExclusive.php @@ -0,0 +1,21 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsMaxExclusive extends _typedData +{ + function xsMaxExclusive() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:float' ) ); + + $this->type[] = 'xsMaxExclusive'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsMaxInclusive.php b/1.4.0/dom/codeGen/1.4/om/xsMaxInclusive.php new file mode 100644 index 0000000..8707dc9 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsMaxInclusive.php @@ -0,0 +1,21 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsMaxInclusive extends _typedData +{ + function xsMaxInclusive() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:float' ) ); + + $this->type[] = 'xsMaxInclusive'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsMaxLength.php b/1.4.0/dom/codeGen/1.4/om/xsMaxLength.php new file mode 100644 index 0000000..6394e9b --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsMaxLength.php @@ -0,0 +1,21 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsMaxLength extends _typedData +{ + function xsMaxLength() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:integer' ) ); + + $this->type[] = 'xsMaxLength'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsMinExclusive.php b/1.4.0/dom/codeGen/1.4/om/xsMinExclusive.php new file mode 100644 index 0000000..4f02bd3 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsMinExclusive.php @@ -0,0 +1,21 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsMinExclusive extends _typedData +{ + function xsMinExclusive() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:float' ) ); + + $this->type[] = 'xsMinExclusive'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsMinInclusive.php b/1.4.0/dom/codeGen/1.4/om/xsMinInclusive.php new file mode 100644 index 0000000..34ee962 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsMinInclusive.php @@ -0,0 +1,21 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsMinInclusive extends _typedData +{ + function xsMinInclusive() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:float' ) ); + + $this->type[] = 'xsMinInclusive'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsMinLength.php b/1.4.0/dom/codeGen/1.4/om/xsMinLength.php new file mode 100644 index 0000000..809243f --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsMinLength.php @@ -0,0 +1,21 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsMinLength extends _typedData +{ + function xsMinLength() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:integer' ) ); + + $this->type[] = 'xsMinLength'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsPattern.php b/1.4.0/dom/codeGen/1.4/om/xsPattern.php new file mode 100644 index 0000000..f679594 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsPattern.php @@ -0,0 +1,23 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsPattern extends _elementSet +{ + function xsPattern() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:string' ) ); + + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->type[] = 'xsPattern'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsRestriction.php b/1.4.0/dom/codeGen/1.4/om/xsRestriction.php new file mode 100644 index 0000000..61a96b0 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsRestriction.php @@ -0,0 +1,32 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsRestriction extends _elementSet +{ + function xsRestriction() + { + $this->_addElement( 'xsAttribute', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsMinLength', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsMaxLength', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsMinInclusive', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsMaxInclusive', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsMinExclusive', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsMaxExclusive', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsEnumeration', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsWhiteSpace', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsPattern', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->_addAttribute( 'base', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsRestriction'; + parent::_elementSet(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsSchema.php b/1.4.0/dom/codeGen/1.4/om/xsSchema.php new file mode 100644 index 0000000..c0b5d8b --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsSchema.php @@ -0,0 +1,32 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsSchema extends _elementSet +{ + function xsSchema() + { + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsElement', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsSimpleType', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsComplexType', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsGroup', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsImport', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->_addAttribute( 'targetNamespace', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'elementFormDefault', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'xmlns:xs', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'xmlns', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'version', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsSchema'; + parent::_elementSet(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsSequence.php b/1.4.0/dom/codeGen/1.4/om/xsSequence.php new file mode 100644 index 0000000..280d253 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsSequence.php @@ -0,0 +1,32 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsSequence extends _elementSet +{ + function xsSequence() + { + $this->_addElement( 'xsElement', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsAttribute', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsChoice', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsSequence', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsGroup', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsAny', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->type[] = "xsSequence"; + parent::_elementSet(); + } + + function addSequenceElement( & $e ) + { + $this->addElement( $e ); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsSimpleContent.php b/1.4.0/dom/codeGen/1.4/om/xsSimpleContent.php new file mode 100644 index 0000000..2001cea --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsSimpleContent.php @@ -0,0 +1,24 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsSimpleContent extends _elementSet +{ + function xsSimpleContent() + { + $this->_addElement( 'xsRestriction', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsExtension', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + +// $this->_addAttribute( 'name', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsSimpleContent'; + parent::_elementSet(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsSimpleType.php b/1.4.0/dom/codeGen/1.4/om/xsSimpleType.php new file mode 100644 index 0000000..5b40cbe --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsSimpleType.php @@ -0,0 +1,143 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +require_once( 'src/TypeMeta.php' ); + +class xsSimpleType extends _elementSet +{ + function xsSimpleType() + { + $this->_addElement( 'xsRestriction', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsExtension', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsList', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsUnion', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + + $this->_addAttribute( 'name', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsSimpleType'; + parent::_elementSet(); + } + + function & generate() + { + $vars = array(); + $e = $this->getElements(); + $generator = new TypeMeta(); + + $generator->setType( $this->getAttribute( 'name' ) ); + + $a = $this->getElementsByType( 'xsAnnotation' ); + if ( count( $a ) > 0 ) + { + //print "found annotation for ". $this->getAttribute( 'name' ) ."!\n"; + $d = $a[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $d ) > 0 ) + { + //print "found documentation for ". $this->getAttribute( 'name' ) ."!\n"; + $generator->setDocumentation( $d[0]->get() ); + } + $ap = $a[0]->getElementsByType( 'xsAppinfo' ); + if ( count( $ap ) > 0 ) + { + $generator->setAppInfo( $ap[0]->get() ); + } + } + + $idx = 0; + if ( $e[$idx]->getType() == 'xsAnnotation' ) { + $idx = 1; + } + if ( $e[$idx]->getType() == 'xsRestriction' || $e[$idx]->getType() == 'xsExtension' ) + { + $generator->setIsExtension( $e[$idx]->getType() == 'xsExtension' ); + + // Set base class + $generator->setBase( $e[$idx]->getAttribute( 'base' ) ); + + // Look for enums + $enums = $e[$idx]->getElementsByType( 'xsEnumeration' ); + for( $i=0; $i<count( $enums ); $i++ ) + { + $generator->addEnum( $enums[$i]->getAttribute( 'value' ) ); + $an = $enums[$i]->getElementsByType('xsAnnotation'); + if ( count( $an ) > 0 ) { + $doc = $an[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $doc ) > 0 ) { + $generator->addEnumDoc( $i, $doc[0]->get() ); + } + $ap = $an[0]->getElementsByType( 'xsAppinfo' ); + if ( count( $ap ) > 0 ) + { + $generator->addEnumAppInfo( $i, $ap[0]->get() ); + } + } + } + + // Look for max/mins + $array_limits = array(); + $min = $e[$idx]->getElementsByType( 'xsMinLength' ); + $max = $e[$idx]->getElementsByType( 'xsMaxLength' ); + $minIn = $e[$idx]->getElementsByType( 'xsMinInclusive' ); + $maxIn = $e[$idx]->getElementsByType( 'xsMaxInclusive' ); + $minEx = $e[$idx]->getElementsByType( 'xsMinExclusive' ); + $maxEx = $e[$idx]->getElementsByType( 'xsMaxExclusive' ); + + if ( count( $min ) > 0 ) + { + $generator->setRestriction( 'minLength', $min[0]->getAttribute( 'value' ) ); + } + + if ( count( $max ) > 0 ) + { + $generator->setRestriction( 'maxLength', $max[0]->getAttribute( 'value' ) ); + } + + if ( count( $minIn ) > 0 ) + { + $generator->setRestriction( 'minInclusive', $minIn[0]->getAttribute( 'value' ) ); + } + + if ( count( $maxIn ) > 0 ) + { + $generator->setRestriction( 'maxInclusive', $maxIn[0]->getAttribute( 'value' ) ); + } + + if ( count( $minEx ) > 0 ) + { + $generator->setRestriction( 'minExclusive', $minEx[0]->getAttribute( 'value' ) ); + } + + if ( count( $maxEx ) > 0 ) + { + $generator->setRestriction( 'maxExclusive', $maxEx[0]->getAttribute( 'value' ) ); + } + } else if ( $e[$idx]->getType() == 'xsList' ) + { + //$extends = "xsList"; + $itemType = $e[$idx]->getAttribute( 'itemType' ); + $generator->setListType( $itemType ); + $generator->bag['isArray'] = true; + } + else if ( $e[$idx]->getType() == 'xsUnion' ) { + $generator->setUnionMembers( $e[$idx]->getAttribute( 'memberTypes' ) ); + } + else + { + $this->log( "WARN: unexpected element in xsSimpleType code generation" ); + } + + $meta = & $generator->getMeta(); + return $meta; + } +} + + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsUnion.php b/1.4.0/dom/codeGen/1.4/om/xsUnion.php new file mode 100644 index 0000000..79954ad --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsUnion.php @@ -0,0 +1,21 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsUnion extends _typedData +{ + function xsUnion() + { + $this->_addAttribute( 'memberTypes', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsUnion'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsWhiteSpace.php b/1.4.0/dom/codeGen/1.4/om/xsWhiteSpace.php new file mode 100644 index 0000000..a968f0e --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsWhiteSpace.php @@ -0,0 +1,21 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsWhiteSpace extends _typedData +{ + function xsWhiteSpace() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsWhiteSpace'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file |