Extra content at the end of the document while generating xml from PHP [closed]

senOntone

New Member
I am trying to generate XForms specification from PHP. This is my class file:\[code\]<?phpclass xforms_lib{var $namespace;var $namespaceXforms;var $namespaceEvents;function xforms_lib($ns, $nsxforms, $nsevents){ $this->namespace = $ns; $this->namespaceXforms = $nsxforms; $this->namespaceEvents = $nsevents;}function htmlTag($customNS='', $customNSnamespace=''){ $xml = '<html'; if($this->namespace != '') $xml .= ' xmlns="'.$this->namespace.'"'; if($this->namespaceXforms != '') $xml .= ' xmlns:xforms="'.$this->namespaceXforms.'"'; if($this->namespaceEvents != '') $xml .= ' xmlns:ev="'.$this->namespaceEvents.'"'; if($this->customNS != '' && $this->customNSnamespace != '') $xml .= ' xmlns:'.$this->customNS. '="'.$this->customNSnamespace.'"'; $xml .= ' >'; return $xml;}function submissionTag($id, $action, $method = 'post', $ref='', $instance = '', $replace = ''){ $xml = '<xforms:submission id="'.$id.'" action="'.$action. '" method="'.$method.'"'; if($ref != '') $xml .= ' ref="'.$ref.'"'; if($instance != '') $xml .= ' instance="'.$instance.'"'; if($replace != '') $xml .= ' replace="'.$replace.'"'; $xml .= " />"; return $xml;}function bindTag($nodeset, $relevant = '', $calculate = '', $required = ''){ $xml = '<xforms:bind nodeset="'.$nodeset.'"'; if($relevant != '') $xml .= ' relevant="'.$relevant.'"'; if($calculate != '') $xml .= ' calculate="'.$calculate.'"'; $xml .= " />"; return $xml;}function dispatchTag($name, $target){ $xml = '<xforms:dispatch'; if($name != '') $xml .= ' name="'.$name.'"'; if($target != '') $xml .= ' target="'.$target.'"'; $xml .= " />"; return $xml;}function loadTag($resource = '', $ref = '', $show='replace'){ $xml = '<xforms:load show="'.$show.'"'; if($ref != '') $xml .= ' ref="'.$ref.'"'; else if($resource != '') $xml .= ' resource="'.$resource.'"'; $xml .= " />"; return $xml;}function insertTag($nodeset, $at, $position = 'after'){ $xml = '<xforms:insert nodeset="'.$nodeset.'" at="'.$at. '" position="'.$position.'" />'; return $xml;}function setvalueTag($ref, $value){ $xml = '<xforms:setvalue ref="'.$ref.'" value="'.$value.'" />'; return $xml;}function inputTag($ref, $label = ''){ $xml = '<xforms:input ref="'.$ref.'">'; if($label != '') $xml .= '<xforms:label>'.$label.'</xforms:label>'; $xml .= "</xforms:input>"; return $xml;}function outputTag($value){ $xml = '<xforms:output value="'.$value.'">'; $xml .= '</xforms:output>'; return $xml;}function select1Tag($ref, $label, $itemArray, $itemset, $appearance = 'minimal'){ $xml = '<xforms:select1 ref="'.$ref.'" appearance="'. $appearance.'">'; $xml .= '<xforms:label>'.$label.'</xforms:label>'; if(is_array($itemset)){ $xml .= '<xforms:itemset nodeset="'.$itemset['nodeset'].'">'; $xml .= '<xforms:label ref="'.$itemset['label'].'" />'; $xml .= '<xforms:value ref="'.$itemset['value'].'" />'; $xml .= '</xforms:itemset>'; } else if(is_array($itemArray)) foreach($itemArray as $item){ $xml .= '<xforms:item>'; $xml .= '<xforms:label>'.$item['label'].'</xforms:label>'; $xml .= '<xforms:value>'.$item['value'].'</xforms:value>'; $xml .= '</xforms:item>'; } $xml .= '</xforms:select1>'; return $xml;}function comment($comment){ $xml = '<!-- '.$comment.' -->'; return $xml;}function instanceTag($id = '', $instanceXML = '', $srchttp://stackoverflow.com/questions/12748156/= ''){ $xml = '<xforms:instance'; if($id != '') $xml .= ' id="'.$id.'"'; if($src != '') $xml .= ' src="'.$src.'"'; else if($instanceXML != ''){ $xml .= '>'."\r\n"; $xml .= $instanceXML; $xml .= "\r\n".'</xforms:instance>'; } else $xml .= " />"; return $xml;}function submitTag($submission, $label='Submit', $ref = ''){ $xml = '<xforms:submit submission="'.$submission.'"'; if($ref != '') $xml .= ' ref="'.$ref.'"'; $xml .= ' >'; $xml .= '<xforms:label>'.$label.'</xforms:label>'; $xml .= '</xforms:submit>'; return $xml;}function actionTagOpen($event){ $xml = '<xforms:action ev:event="'.$event.'">'; return $xml;}function actionTagClose(){ $xml = '</xforms:action>'; return $xml;}function repeatTagOpen($nodeset, $id = ''){ $xml = '<xforms:repeat nodeset="'.$nodeset.'"'; if($id != '') $xml .= ' id="'.$id.'"'; $xml .= ' >'; return $xml;}function repeatTagClose(){ $xml = '</xforms:repeat>'; return $xml;}function modelTagOpen($id = ''){ $xml = '<xforms:model'; if($id != '') $xml .= ' id="'.$id.'"'; $xml .= ' >'; return $xml;}function modelTagClose(){ $xml = '</xforms:model>'; return $xml;}function triggerTagOpen($ref, $submission = '', $label = 'default'){ $xml = '<xforms:trigger ref="'.$ref.'"'; if($submission != '') $xml .= ' submission="'.$submission.'"'; $xml .= ' >'; return $xml;} function triggerTagClose(){ $xml = '</xforms:trigger>'; return $xml; } } ?>\[/code\]This is my index page:\[code\] <?php header("Content-Type: application/xhtml+xml; charset=UTF-8"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php include('lib/xforms_lib.php'); $xformsDoc = new xforms_lib("http://www.w3.org/1999/xhtml", "http://www.w3.org/2002/xforms", "http://www.w3.org/2001/xml-events"); echo $xformsDoc->htmlTag(); ?> <head><title>XForms served via PHP</title> <?php // display model here $model1 = 'first'; $instance1 = 'firstInstance'; $xformsTestSubmit = 'xformsTest'; $instance1data = 'http://stackoverflow.com/questions/12748156/<root xmlns=""><data1/></root>'; echo $xformsDoc->modelTagOpen($model1); echo $xformsDoc->instanceTag($instance1, $instance1data); echo $xformsDoc->submissionTag($xformsTestSubmit, "receive.php", 'post'); echo $xformsDoc->modelTagClose(); ?> </head> <body> <?php // display form here echo $xformsDoc->inputTag("instance('$instance1')//data1", 'input1: '); echo $xformsDoc->submitTag($xformsTestSubmit); ?>\[/code\]I don't know what is being appended. But when I just copy the this page source from HTML portion onwards and run outside the php environment, the page renders fine. The following is the view source including the error block.\[code\] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br /> <font size='1'> <table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'> <tr><th align='left' bgcolor='#f57900' colspan="5"> <span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Undefined property: xforms_lib::$customNS in C:\wamp\www\IBM sample PHP library for XForms creation\code_part1\lib\xforms_lib.php on line <i>22</i> </th></tr> <tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr> <tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr> <tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0117</td><td bgcolor='#eeeeec' align='right'>680336</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:\wamp\www\IBM sample PHP library for XForms creation\code_part1\index.php' bgcolor='#eeeeec'>..\index.php<b>:</b>0</td></tr> <tr><td bgcolor='#eeeeec' align='center'>2</td> <td bgcolor='#eeeeec' align='center'>0.0134</td> <td bgcolor='#eeeeec' align='right'>770824</td> <td bgcolor='#eeeeec'>xforms_lib->htmlTag( )</td> <td title='C:\wamp\www\IBM sample PHP library for XForms creation\code_part1\index.php' bgcolor='#eeeeec'>..\index.php<b>:</b>12</td> </tr> </table></font><html xmlns="http://www.w3.org/1999/xhtml" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" > <head><title>XForms served via PHP</title> <xforms:model id="first" ><xforms:instance id="firstInstance"> <root xmlns=""><data1/></root> </xforms:instance><xforms:submission id="xformsTest" action="receive.php" method="post" /> </xforms:model> </head><body> <xforms:input ref="instance('firstInstance')//data1"> <xforms:label>input1: </xforms:label> </xforms:input> <xforms:submit submission="xformsTest" > <xforms:label>Submit</xforms:label> </xforms:submit></body> </html>\[/code\]
 
Back
Top