Posted: Fri Apr 27, 2012 3:59 am Post subject: XML tag declaration
Newbie
Joined: 16 Apr 2012 Posts: 5
I am facing a problem in creating XML tags
below I have provided my code...
WHILE CARDINALITY(InputRoot.Collection.Input1.MRM.type1[])>= J DO
WHILE CARDINALITY(InputRoot.Collection.Input2.MRM.Body[])>= I DO
IF InputRoot.Collection.Input1.MRM.type1[J].Property = SUBSTRING(InputRoot.Collection.Input2.MRM.Body[I].Concept AFTER ':')
THEN
SET MainTag = InputRoot.Collection.Input2.MRM.Body[I].Concept;
IF SUBSTRING(FIELDNAME(InputRoot.Collection.Input1.MRM.type1.Y2007)AFTER 'Y') = SUBSTRING(InputRoot.Collection.Input2.MRM.Body[I].Context AFTER '-')
THEN
CREATE LASTCHILD OF OutputRoot.XMLNSC.XBRL Name MainTag;
SET OutputRoot.XMLNSC.XBRL.{MainTag} = InputRoot.Collection.Input1.MRM.type1[J].Y2007;
SET OutputRoot.XMLNSC.XBRL.{MainTag}.(XMLNSC.Attribute)contextRef = InputRoot.Collection.Input2.MRM.Body[I].Context;
SET OutputRoot.XMLNSC.XBRL.{MainTag}.(XMLNSC.Attribute)unitRef =InputRoot.Collection.Input2.MRM.Body[I].Unit;
SET OutputRoot.XMLNSC.XBRL.{MainTag}.(XMLNSC.Attribute)decimals =InputRoot.Collection.Input2.MRM.Body[I].Decimal;
--
ELSE
CREATE LASTCHILD OF OutputRoot.XMLNSC.XBRL Name MainTag;
SET OutputRoot.XMLNSC.XBRL.{MainTag} = InputRoot.Collection.Input1.MRM.type1[J].Y2006;
SET OutputRoot.XMLNSC.XBRL.{MainTag}.(XMLNSC.Attribute)contextRef = InputRoot.Collection.Input2.MRM.Body[I].Context;
SET OutputRoot.XMLNSC.XBRL.{MainTag}.(XMLNSC.Attribute)unitRef =InputRoot.Collection.Input2.MRM.Body[I].Unit;
SET OutputRoot.XMLNSC.XBRL.{MainTag}.(XMLNSC.Attribute)decimals =InputRoot.Collection.Input2.MRM.Body[I].Decimal;
-- SET OutputRoot.XMLNSC.XBRL.{MainTag} = InputRoot.Collection.Input1.MRM.type1.Y2006;
END IF;
SET I = I+ 1;
SET loopterminater=loopterminater+1;
IF loopterminater=2 THEN
SET I =CARDINALITY(InputRoot.Collection.Input2.MRM.Body[])+1;
SET loopterminater = 0;
END IF;
ELSE
SET I = I + 1;
END IF;
END WHILE;
SET J = J + 1;
SET I = 1;
END WHILE;
You should:
- use [c o d e] tags when you post source code or XML. Reading what you posted makes my eyes hurt.
- when building the output tree, use a REFERENCE variable that points at the specific tag that you want to modify. The SET OutputRoot.x.y technique will apply your changes to the first match that it finds ( as you have discovered ).
Someone will be along shortly to tell you not to use CARDINALITY because it's bad for performance. Which is true in cases where the returned value is large. It's certainly true that REFERENCE variables can reduce CPU usage, and you will not need CARDINALITY if you use REFERENCEs.
I haven't analysed your ESQL in detail, but I *suspect* ( I will not put it any more strongly than that ) that you could replace those loops with one or two SELECT statements.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum