in reply to Re: XML-Twig - AS5.6.1 vs AS 5.8.8
in thread XML-Twig - AS5.6.1 vs AS 5.8.8

Yes, it does. Thanks, Michael. I implemented the method calls as you suggested, and it works, except for one small thing - the first time $balance->flush; is called, it writes a <Root> tag immediately preceding the <Aging> tag. As you can surmise, I'm processing a member billing file, and it doesn't write the <Root> tag on subsequent members, just the first one. I can hack my way around it, but I don't understand why it is happening. Thanks. -Mike

Replies are listed 'Best First'.
Re^3: XML-Twig - AS5.6.1 vs AS 5.8.8
by runrig (Abbot) on Mar 29, 2006 at 22:13 UTC
    A minimal test case with data would be helpful. Do you mean that each Aging element is a child of a different Root element? And that the parent element of your entire document is some other-named sort of "root" element? Or that all of your Aging elements are children of one Root element (in which case it sounds like it's behaving correctly)?
      Thanks for your previous response and this one, runrig. Here is the head of the original file. All of the tags that are opened above the <Aging> tag are subsequently closed properly. Names have been changed to protect the innocent:
      <?xml version="1.0" encoding="ISO-8859-1"?> <Root> <Billing> <STMT_HDR.AR> <StatementDate>20060228</StatementDate> <PreviousDate>20060131</PreviousDate> <DueDate>20060331</DueDate> <TransactionThruDate>20060228</TransactionThruDate> <MemberId> <MemberNumber>1000</MemberNumber> <MemberInfo> <MemberName>Mickey Mouse</MemberName> <Address> <Address1>6340 Disney Lane</Address1> <Address2>P.O. Box 730</Address2> <Address3></Address3> <City>Orlando</City> <State>FL</State> <ZipCode>33333</ZipCode> </Address> </MemberInfo> <BillingInfo> <PreviousBalance>2371.28</PreviousBalance> <ChargeTotal>567.78</ChargeTotal> <PymtAdjustTotal>2371.28</PymtAdjustTotal> <EndingBalance>567.78</EndingBalance> <AutomaticBilling> <Minimum>False</Minimum> <BillingCode></BillingCode> <BillingBalance></BillingBalance> </AutomaticBilling> <Aging> <BAL_30 Period="1">0.00</BAL_30> <BAL_60 Period="2">0.00</BAL_60> <BAL_90 Period="3">0.00</BAL_90> <BAL_120 Period="4">0.00</BAL_120> <BAL_150 Period="5">0.00</BAL_150> <BAL_180 Period="6">0.00</BAL_180> </Aging>

      Here is the result of the modifications:
      All is the same prior to this point -
      <BillingInfo> <PreviousBalance>2371.28</PreviousBalance> <ChargeTotal>567.78</ChargeTotal> <PymtAdjustTotal>2371.28</PymtAdjustTotal> <EndingBalance>567.78</EndingBalance> <AutomaticBilling> <Minimum>False</Minimum> <BillingCode></BillingCode> <BillingBalance></BillingBalance> </AutomaticBilling> <Root> <--This is the question <Aging> <BAL_30 Period="1">0.00</BAL_30> <BAL_60 Period="2">0.00</BAL_60> <BAL_90 Period="3">0.00</BAL_90> </Aging>

      Your help is greatly appreciated.
      -Mike
        I think that is a bug. Every element remembers whether or not its parent has been previously flushed, and if it hasn't, then it prints the parent tag first. On the first "Aging", it thinks the Root hasn't been flushed yet, even though it really has because of the twig_print_outside_roots, so it doesn't need to print the root tag, but flushing "Aging" goes ahead and prints the root tag anyway. This is probably one for mirod to fix (Update: I'm not sure anymore if it is a bug...I don't think it is...use print instead of flush).

        As a workaround hack, putting this right before the flush works (for now, probably at least until the module is fixed, so this is not really recommended as a permanent solution):

        # (update: ignore this code) $balance->parent->_set_flushed;

        Update: Instead of $balance->flush(\*OUTFILE) you should just $balance->print(\*OUTFILE).