From: <rd...@us...> - 2007-03-29 18:59:54
|
Revision: 296 http://digir.svn.sourceforge.net/digir/?rev=296&view=rev Author: rdg Date: 2007-03-29 11:59:16 -0700 (Thu, 29 Mar 2007) Log Message: ----------- When a prefix for the target namespace of the response structure is declared in the output model, then use that prefix in the resulting XML (instead of using the default namespace approach). Modified Paths: -------------- tapirlink/trunk/classes/TpOutputModel.php tapirlink/trunk/classes/TpSchemaInspector.php tapirlink/trunk/classes/TpXmlGenerator.php Modified: tapirlink/trunk/classes/TpOutputModel.php =================================================================== --- tapirlink/trunk/classes/TpOutputModel.php 2007-03-29 14:53:35 UTC (rev 295) +++ tapirlink/trunk/classes/TpOutputModel.php 2007-03-29 18:59:16 UTC (rev 296) @@ -401,7 +401,7 @@ { if ( $this->mNamespaces[$i]->GetUri() == $ns ) { - return $this->mNamespaces[$i]->GetPrefix() . ':'; + return $this->mNamespaces[$i]->GetPrefix(); } } Modified: tapirlink/trunk/classes/TpSchemaInspector.php =================================================================== --- tapirlink/trunk/classes/TpSchemaInspector.php 2007-03-29 14:53:35 UTC (rev 295) +++ tapirlink/trunk/classes/TpSchemaInspector.php 2007-03-29 18:59:16 UTC (rev 296) @@ -167,6 +167,11 @@ $prefix = $this->mrOutputModel->GetPrefix( $ns ); + if ( ! empty( $prefix ) ) + { + $prefix .= ':'; + } + $path .= '/' . $prefix . $name; $g_dlog->debug( 'Visiting '.$path ); @@ -372,6 +377,11 @@ $prefix = $this->mrOutputModel->GetPrefix( $ns ); + if ( ! empty( $prefix ) ) + { + $prefix .= ':'; + } + $path .= '/@' . $prefix . $name; $g_dlog->debug( 'Visiting '.$path ); Modified: tapirlink/trunk/classes/TpXmlGenerator.php =================================================================== --- tapirlink/trunk/classes/TpXmlGenerator.php 2007-03-29 14:53:35 UTC (rev 295) +++ tapirlink/trunk/classes/TpXmlGenerator.php 2007-03-29 18:59:16 UTC (rev 296) @@ -112,6 +112,11 @@ $path_token_prefix = $this->mrOutputModel->GetPrefix( $element_namespace ); + if ( ! empty( $path_token_prefix ) ) + { + $path_token_prefix .= ':'; + } + $path .= '/' . $path_token_prefix . $name; $g_dlog->debug( 'Visiting element declaration at '.$path ); @@ -173,10 +178,23 @@ { $target_namespace = $this->mResponseStructure->GetTargetNamespace(); + $target_ns_prefix = $this->mrOutputModel->GetPrefix( $target_namespace ); + if ( $is_root ) { - $xmlns = ' xmlns="'.$target_namespace.'"'; + if ( empty( $target_ns_prefix ) ) + { + // Only declare a default namespace if there is no prefix + // associated with the target namespace + $xmlns = ' xmlns="'.$target_namespace.'"'; + } + else + { + $xmlns = ' xmlns:'.$target_ns_prefix.'="'.$target_namespace.'"'; + $prefix = $target_ns_prefix.':'; + } + $xmlns .= ' xmlns:'.TP_XSI_PREFIX.'="'.XMLSCHEMAINST.'"'; $imported_namespaces = $this->mResponseStructure->GetImportedNamespaces(); @@ -197,6 +215,10 @@ $prefix .= ':'; } + else if ( ! empty( $target_ns_prefix ) ) + { + $prefix = $target_ns_prefix . ':'; + } } array_push( $this->mNamespaceStack, $element_namespace ); @@ -216,16 +238,12 @@ } } - $open_tag = '<'; + $open_tag = '<' . $prefix . $name; if ( $is_root ) { - $open_tag .= $name . $xmlns; + $open_tag .= $xmlns; } - else - { - $open_tag .= $prefix . $name; - } $attributes_xml = ''; @@ -421,14 +439,18 @@ { $ns_depth = count( $this->mNamespaceStack ); - if ( $ns_depth > 0 ) + if ( $ns_depth ) // Sanity checking { $contextual_namespace = $this->mNamespaceStack[$ns_depth-1]; + // Note: assuming attributeFormDefault = unqualified + // (when the default namespace of attributes is the namespace + // of the containing element). + if ( $attribute_namespace != $contextual_namespace ) { $prefix = $this->mResponseStructure->GetPrefix( $attribute_namespace ); - + $prefix .= ':'; } } @@ -438,6 +460,11 @@ $path_token_prefix = $this->mrOutputModel->GetPrefix( $attribute_namespace ); + if ( ! empty( $path_token_prefix ) ) + { + $path_token_prefix .= ':'; + } + $path .= '/@' . $path_token_prefix . $name; $g_dlog->debug( 'Visiting attribute declaration at '.$path ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |