[Servingxml-help] xml->flat repeatingGroup
Brought to you by:
danielaparker
From: Ravikumar T. <ra...@gm...> - 2007-04-16 01:18:16
|
Daniel Trying a case in xml to flat. Flat file record needs a repeating group. The input xml is of the following form. There could be any number of compositeA elements and any number of compositeB elements. Expected output is given below. Since the # of compositeA is unknown I am trying to use <sx:repeatingGroup> in the flat file recordType. But it doesnot seem to recognize it. Can you please help with this. <all> <field1>val1</field1> <field2>val2</field2> <field3>val3</field3> <compositeA attr1="av11" attr2="av21" attr3="av31"/> <compositeA attr1="av21" attr2="av22" attr3="av23"/> <compositeA attr1="av31" attr2="av32" attr3="av33"/> <compositeB attrx="avx" attry="avy"/> </all> Expected Output: val1 val2 val3 av11 av21 av31 av21 av22 av23 av31 av32 av33 avx avy <sx:flatRecordType id="allType" name="allType"> <sx:positionalField name="f1" label="F1" width="10"/> <sx:positionalField name="f2" label="F2" width="10"/> <sx:positionalField name="f3" label="F3" width="10"/> <sx:repeatingGroup name="compA"> <sx:flatRecordType name="compARecord"> <sx:positionalField name="ca1" width="5"/> <sx:positionalField name="ca2" width="5"/> <sx:positionalField name="ca3" width="5"/> </sx:flatRecordType> </sx:repeatingGroup> <sx:repeatingGroup name="compB"> <sx:flatRecordType name="compBRecord"> <sx:positionalField name="cb1" width="5"/> <sx:positionalField name="cb2" width="5"/> </sx:flatRecordType> </sx:repeatingGroup> </sx:flatRecordType> <sx:inverseRecordMapping id="allToFileMapping"> <sx:onSubtree path="/all"> <sx:subtreeRecordMap recordType="allType"> <sx:subtreeFieldMap select="field1" field="f1"/> <sx:subtreeFieldMap select="field2" field="f2"/> <sx:subtreeFieldMap select="field3" field="f3"/> <sx:onSubtree path="compositeA"> <sx:subtreeRecordMap recordType="compARecord"> <sx:subtreeFieldMap select="@attr1" field="ca1"/> <sx:subtreeFieldMap select="@attr2" field="ca2"/> <sx:subtreeFieldMap select="@attr3" field="ca3"/> </sx:subtreeRecordMap> </sx:onSubtree> <sx:onSubtree path="compositeB"> <sx:subtreeRecordMap recordType="compBRecord"> <sx:subtreeFieldMap select="@attrx" field="cb1"/> <sx:subtreeFieldMap select="@attry" field="cb2"/> </sx:subtreeRecordMap> <sx:onSubtree> </sx:subtreeRecordMap> </sx:onSubtree> </sx:inverseRecordMapping> |