@@ -255,112 +255,114 @@ public function singlePcmlToParam(\SimpleXmlElement $dataElement)
255255 $ subElements = array ();
256256
257257 // each item should have tag name <data>
258- if ($ tagName == 'data ' ) {
259-
260- $ type = (isset ($ attrs ['type ' ])) ? (string ) $ attrs ['type ' ] : '' ;
261-
262- // Get initial value, if specified by PCML.
263- $ dataValue = (isset ($ attrs ['init ' ])) ? (string ) $ attrs ['init ' ] : '' ;
264-
265- // if a struct then we need to recurse.
266- if ($ type == 'struct ' ) {
267- $ theStruct = null ; // init
268-
269- // look for matching struct definition encountered earlier.
270- if ($ this ->_pcmlStructs ) {
271-
272- // @todo verify type with is_array and count
273- foreach ($ this ->_pcmlStructs as $ possibleStruct ) {
274- $ possStructAttrs = $ possibleStruct ->attributes ();
275-
276- if ($ possStructAttrs ['name ' ] == $ structName ) {
277- $ theStruct = $ possibleStruct ;
278- $ structAttrs = $ possStructAttrs ;
279- break ;
280- }
281- }
282- }
283-
284- // if struct was not found, generate error for log
285- if (!$ theStruct ) {
286- // $this->getConnection->logThis("PCML structure '$structName' not found.");
287- return null ;
288- }
289-
290- // count can also be defined at the structure level. If so, it will override count from data level)
291- if (isset ($ structAttrs ['count ' ])) {
292- $ count = (string ) $ structAttrs ['count ' ];
293- }
294-
295- // "usage" (in/out/inherit) can be defined here, at the structure level.
296- $ structUsage = (isset ($ structAttrs ['usage ' ])) ? (string ) $ structAttrs ['usage ' ] : '' ;
297-
298- // if we're not inheriting from our parent data element, but there is a struct usage, use the struct's usage (input, output, or inputoutput).
299- if (!empty ($ structUsage ) && ($ structUsage != 'inherit ' )) {
300- $ usage = $ structUsage ;
301- }
302-
303- $ structSubDataElementsXmlObj = $ theStruct ->xpath ('data ' );
304- if ($ structSubDataElementsXmlObj ) {
305- foreach ($ structSubDataElementsXmlObj as $ subDataElementXmlObj ) {
306-
307- if ($ subDataElementXmlObj ->attributes ()->usage == 'inherit ' ) {
308- // subdata is inheriting type from us. Give it to them.
309- $ subDataElementXmlObj ->attributes ()->usage = $ usage ;
310- }
258+ if ($ tagName != 'data ' ) {
259+ return false ;
260+ }
311261
312- // here's where the recursion comes in. Convert data and add to array for our struct.
313- $ subElements [] = $ this ->singlePcmlToParam ($ subDataElementXmlObj );
262+ $ type = (isset ($ attrs ['type ' ])) ? (string ) $ attrs ['type ' ] : '' ;
263+
264+ // Get initial value, if specified by PCML.
265+ $ dataValue = (isset ($ attrs ['init ' ])) ? (string ) $ attrs ['init ' ] : '' ;
266+
267+ // if a struct then we need to recurse.
268+ if ($ type == 'struct ' ) {
269+ $ theStruct = null ; // init
270+
271+ // look for matching struct definition encountered earlier.
272+ if ($ this ->_pcmlStructs ) {
273+
274+ // @todo verify type with is_array and count
275+ foreach ($ this ->_pcmlStructs as $ possibleStruct ) {
276+ $ possStructAttrs = $ possibleStruct ->attributes ();
277+
278+ if ($ possStructAttrs ['name ' ] == $ structName ) {
279+ $ theStruct = $ possibleStruct ;
280+ $ structAttrs = $ possStructAttrs ;
281+ break ;
314282 }
315283 }
316284 }
317-
318- /* explanation of the terms "length" and "precision" in PCML:
319- * http://publib.boulder.ibm.com/infocenter/iadthelp/v6r0/index.jsp?topic=/com.ibm.etools.iseries.webtools.doc/ref/rdtcattr.htm
320- *
321- * For "int" values, length is the number of bytes; precision represents the number of bits. (Can be ignored here)
322- * For zoned and packed values, length is the maximum number of digits; precision represents the maximum decimal places.
323- *
324- */
325- $ length = (isset ($ attrs ['length ' ])) ? (string ) $ attrs ['length ' ] : '' ;
326- $ precision = (isset ($ attrs ['precision ' ])) ? (string ) $ attrs ['precision ' ] : '' ;
327-
328- $ passBy = '' ; // default of blank will become 'ref'/Reference in XMLSERVICE. Blank is fine here.
329- if (isset ($ attrs ['passby ' ]) && ($ attrs ['passby ' ] == 'value ' )) {
330- $ passBy = 'val ' ; // rare. PCML calls it 'value'. XMLSERVICE calls it 'val'.
285+
286+ // if struct was not found, generate error for log
287+ if (!$ theStruct ) {
288+ // $this->getConnection->logThis("PCML structure '$structName' not found.");
289+ return null ;
331290 }
332-
333- // find new toolkit equivalent of PCML data type
334- if (isset ($ this ->_pcmlTypeMap [$ type ])) {
335- // a simple type mapping
336- $ newType = (string ) $ this ->_pcmlTypeMap [$ type ];
337- } elseif ($ type == 'int ' ) {
338- // one of the integer types. Need to use length to determine which one.
339- if ($ length == '2 ' ) {
340- $ newType = '5i0 ' ; // short ints have two bytes
341- } elseif ($ length == '4 ' ) {
342- $ newType = '10i0 ' ; // normal ints have four bytes
343- } else {
344- $ newType = '' ; // no match
345- } //(length == 2, et al.)
346-
291+
292+ // count can also be defined at the structure level. If so, it will override count from data level)
293+ if (isset ($ structAttrs ['count ' ])) {
294+ $ count = (string ) $ structAttrs ['count ' ];
347295 }
348-
349- $ newInout = (isset ($ this ->_pcmlInoutMap [$ usage ])) ? (string ) $ this ->_pcmlInoutMap [$ usage ] : '' ;
350-
351- // @todo correct all this isArray business.
352- // Can we manage without isArray?
353- // well, it's already handled by toolkit....try and see, though.
354- // poss. eliminate extra object levels, at least?
355-
356- if ($ count > 1 ) {
357- $ isArray = true ;
358- } else {
359- // no need for any dummy value.Could be 'init' from above, or leave the default.
360- $ isArray = false ;
296+
297+ // "usage" (in/out/inherit) can be defined here, at the structure level.
298+ $ structUsage = (isset ($ structAttrs ['usage ' ])) ? (string ) $ structAttrs ['usage ' ] : '' ;
299+
300+ // if we're not inheriting from our parent data element, but there is a struct usage, use the struct's usage (input, output, or inputoutput).
301+ if (!empty ($ structUsage ) && ($ structUsage != 'inherit ' )) {
302+ $ usage = $ structUsage ;
303+ }
304+
305+ $ structSubDataElementsXmlObj = $ theStruct ->xpath ('data ' );
306+ if ($ structSubDataElementsXmlObj ) {
307+ foreach ($ structSubDataElementsXmlObj as $ subDataElementXmlObj ) {
308+
309+ if ($ subDataElementXmlObj ->attributes ()->usage == 'inherit ' ) {
310+ // subdata is inheriting type from us. Give it to them.
311+ $ subDataElementXmlObj ->attributes ()->usage = $ usage ;
312+ }
313+
314+ // here's where the recursion comes in. Convert data and add to array for our struct.
315+ $ subElements [] = $ this ->singlePcmlToParam ($ subDataElementXmlObj );
316+ }
361317 }
362318 }
363319
320+ /* explanation of the terms "length" and "precision" in PCML:
321+ * http://publib.boulder.ibm.com/infocenter/iadthelp/v6r0/index.jsp?topic=/com.ibm.etools.iseries.webtools.doc/ref/rdtcattr.htm
322+ *
323+ * For "int" values, length is the number of bytes; precision represents the number of bits. (Can be ignored here)
324+ * For zoned and packed values, length is the maximum number of digits; precision represents the maximum decimal places.
325+ *
326+ */
327+ $ length = (isset ($ attrs ['length ' ])) ? (string ) $ attrs ['length ' ] : '' ;
328+ $ precision = (isset ($ attrs ['precision ' ])) ? (string ) $ attrs ['precision ' ] : '' ;
329+
330+ $ passBy = '' ; // default of blank will become 'ref'/Reference in XMLSERVICE. Blank is fine here.
331+ if (isset ($ attrs ['passby ' ]) && ($ attrs ['passby ' ] == 'value ' )) {
332+ $ passBy = 'val ' ; // rare. PCML calls it 'value'. XMLSERVICE calls it 'val'.
333+ }
334+
335+ // find new toolkit equivalent of PCML data type
336+ if (isset ($ this ->_pcmlTypeMap [$ type ])) {
337+ // a simple type mapping
338+ $ newType = (string ) $ this ->_pcmlTypeMap [$ type ];
339+ } elseif ($ type == 'int ' ) {
340+ // one of the integer types. Need to use length to determine which one.
341+ if ($ length == '2 ' ) {
342+ $ newType = '5i0 ' ; // short ints have two bytes
343+ } elseif ($ length == '4 ' ) {
344+ $ newType = '10i0 ' ; // normal ints have four bytes
345+ } else {
346+ $ newType = '' ; // no match
347+ } //(length == 2, et al.)
348+ } else {
349+ $ newType = '' ;
350+ }
351+
352+ $ newInout = (isset ($ this ->_pcmlInoutMap [$ usage ])) ? (string ) $ this ->_pcmlInoutMap [$ usage ] : '' ;
353+
354+ // @todo correct all this isArray business.
355+ // Can we manage without isArray?
356+ // well, it's already handled by toolkit....try and see, though.
357+ // poss. eliminate extra object levels, at least?
358+
359+ if ($ count > 1 ) {
360+ $ isArray = true ;
361+ } else {
362+ // no need for any dummy value.Could be 'init' from above, or leave the default.
363+ $ isArray = false ;
364+ }
365+
364366 // @todo I think simply add 'counterLabel' and 'countedLabel'.
365367 // count
366368 $ newCount = 0 ; // initialize
0 commit comments