Categories > TinyButStrong general >

Bug in MergeField

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Roland
Date: 2011-09-20
Time: 22:37

Bug in MergeField

we have an xml doc used as the source document.
it contains the following tag...

<BuiltEntity>
        <BuiltEntityAddresses>
            <BuiltEntityAddress>
                <AddressLine1>[built_entity.address_physical.address1]</AddressLine1>

When the our code that is walking the nodes of the data doc -provides "built_entity" as a field
the MergeField identifies [built_entity.address_physical.address1] as a match location.

when TBS runs the function meth_Locator_Replace( ...
I get this warning...

$this->meth_Misc_Alert($Loc,'item before \''.$x.'\' is neither an object nor an array. Its type is '.gettype($Value).'.',true);

then it replaces the found tag with "" -thus removing the tag from the source doc, preventing a match further along
when the node walker eventually gets to the "built_entity.address_physical.address1"

this also does not correctly match replace a simple 2 level path  -such as "doc_info.type"


are we doing something wrong?   I've verified this behavior with ver: 3.70 as well on PHP5

thanks


By: Skrol29
Date: 2011-09-20
Time: 23:59

Re: Bug in MergeField

Hi Roland,

This is quite normal. The dot ('.') is the sub-item separator for TBS and is is core coded.

I can see 2 ways to work around your problem :

1) Merge the long named fields first.
Merge 'built_entity.address_physical.address1' and then 'built_entity.address_physical' and then 'built_entity'.

or :

2) Do not use '.' in your field's name.
By: Roland
Date: 2011-09-21
Time: 15:30

Re: Bug in MergeField

Thanks for the response.

The data fields are from a JSON document, so the "." is actually object and property separator
so built_entity is an object, and address_physical is an (object) property and address1 is a property of address_physical.

I can't change the field names -this is how JSON works
and merging longer fields, its much of an option as we are walking the nodes of the document
so there is no way of knowing what the longer fields are, without hard coding...

I guess I write my own merge (search/replace)
By: Skrol29
Date: 2011-09-23
Time: 03:04

Re: Bug in MergeField

Hi Roland,

If you have  an XML template snippet such as
[built_entity.address_physical.address1]

And then you merge is using something like:
$obj->address_physical->address1 = 'hello Roland';
$TBS->MergeField('built_entity', $obj);

Then the TBS field [built_entity.address_physical.address1] should be replaced with 'hello Roland'.

If that does not help as much, then could you give mode detail about what you're trying to code?