Re: [Servingxml-help] Formating distinct record lines
Brought to you by:
danielaparker
From: Daniel P. <dan...@sy...> - 2007-05-01 11:13:25
|
Sorry, there appears to be an issue with the proposed solution, I'll = need to investigate (I hadn't previously tested this case.) Daniel ----- Original Message -----=20 From: Daniel Parker=20 To: Jos=C3=A9 Santos ; ser...@li...=20 Sent: Monday, April 30, 2007 11:46 PM Subject: Re: [Servingxml-help] Formating distinct record lines Jose, The first example is no problem, you can use a resources script as = shown below. Note that the sx:when tests in the output record = definition are evaluated against the XML representation of the flattened = records. Since there's no obvious tag field, the test is performed = against the record type that is assigned to the record in the inverse = record mapping section, where the record type corresponds to the root = element of the record's XML representation. =20 <sx:resources xmlns:sx=3D"http://www.servingxml.com/core"> <sx:service id=3D"blocks"> <sx:recordStream> <sx:xmlRecordReader> <sx:transform> <sx:document/> </sx:transform> <sx:inverseRecordMapping ref=3D"blocksToFileMapping"/> </sx:xmlRecordReader> <sx:flatFileWriter> <sx:flatFile> <sx:flatFileBody> <sx:flatRecordType ref=3D"blockType"/> </sx:flatFileBody> </sx:flatFile> </sx:flatFileWriter> </sx:recordStream> </sx:service> <sx:flatRecordTypeChoice id=3D"blockType" name=3D"blockType"> <sx:positionalField name=3D"dummy" width=3D"1"/> <sx:when test=3D"/Block1Record"> <sx:flatRecordType name=3D"BLOCK1"> <sx:positionalField name=3D"Field1" width=3D"4"/> <sx:positionalField name=3D"Field2" width=3D"4"/> <sx:positionalField name=3D"Field3" width=3D"4"/> <sx:positionalField name=3D"Field4" width=3D"4"/> </sx:flatRecordType> </sx:when> <sx:when test=3D"/Block2Record"> <sx:flatRecordType name=3D"BLOCK2"> <sx:positionalField name=3D"Text1" width=3D"4"/> <sx:positionalField name=3D"Text2" width=3D"4"/> <sx:positionalField name=3D"Text3" width=3D"4"/> <sx:positionalField name=3D"Text4" width=3D"4"/> </sx:flatRecordType> </sx:when> <sx:when test=3D"/Block3Record"> <sx:flatRecordType name=3D"BLOCK3"> <sx:positionalField name=3D"Integer1" width=3D"4"/> <sx:positionalField name=3D"Integer2" width=3D"4"/> <sx:positionalField name=3D"Integer3" width=3D"4"/> </sx:flatRecordType> </sx:when> </sx:flatRecordTypeChoice> <sx:inverseRecordMapping id=3D"blocksToFileMapping"> <sx:onSubtree path=3D"/BLOCKS"> <sx:onSubtree path=3D"BLOCK1"> <sx:subtreeRecordMap recordType=3D"Block1Record"> <sx:subtreeFieldMap select=3D"FIELD1" field=3D"Field1"/> <sx:subtreeFieldMap select=3D"FIELD2" field=3D"Field2"/> <sx:subtreeFieldMap select=3D"FIELD3" field=3D"Field3"/> <sx:subtreeFieldMap select=3D"FIELD4" field=3D"Field4"/> </sx:subtreeRecordMap> </sx:onSubtree> <sx:onSubtree path=3D"BLOCK2"> <sx:subtreeRecordMap recordType=3D"Block2Record"> <sx:subtreeTextMap select=3D"TEXT1" field=3D"Text1"/> <sx:subtreeTextMap select=3D"TEXT2" field=3D"Text2"/> <sx:subtreeTextMap select=3D"TEXT3" field=3D"Text3"/> <sx:subtreeTextMap select=3D"TEXT4" field=3D"Text4"/> </sx:subtreeRecordMap> </sx:onSubtree> <sx:onSubtree path=3D"BLOCK3"> <sx:subtreeRecordMap recordType=3D"Block3Record"> <sx:subtreeIntegerMap select=3D"INTEGER1" = field=3D"Integer1"/> <sx:subtreeIntegerMap select=3D"INTEGER2" = field=3D"Integer2"/> <sx:subtreeIntegerMap select=3D"INTEGER3" = field=3D"Integer3"/> </sx:subtreeRecordMap> </sx:onSubtree> </sx:onSubtree> </sx:inverseRecordMapping> </sx:resources> I'll have to think about the second example, it may require an = enhancement. Regards, Daniel Parker ----- Original Message -----=20 From: Jos=C3=A9 Santos=20 To: ser...@li...=20 Sent: Monday, April 30, 2007 3:07 AM Subject: [Servingxml-help] Formating distinct record lines Hi, I am trying to use servingxml to transform xml files to flat files, = but I am having some problems solving some things like for instance, my = XML file has lots off different tags and I need to treat than separately = ( but not as a header) for istance:=20 <BLOCK1> <FIELD1>XXXX</FIELD1> <FIELD2>YYYY</FIELD2> <FIELD3>ZZZZ</FIELD3> <FIELD4>WWWW</FIELD4> </BLOCK1> <BLOCK2> <TEXT1>XXXX</TEXT1> <TEXT2>YYYY</TEXT2> <TEXT3>ZZZZ</TEXT3> <TEXT4>WWWW</TEXT4> </BLOCK2> <BLOCK3> <INTEGER1>1111</INTEGER1> <INTEGER2>2222</INTEGER2> <INTEGER2>3333</INTEGER2> </BLOCK4> I would like to have distinct record types for each block, and its = corresponding record mapping. Is this possible, for the same file? Another problem is that I need to correspond each level of a = hierarchy of tags to a record line in the output flat file, as an = example this XML entry: <Block270> <Field1>some text</Field1> <Field2>666666</Field2> <Block700> <Field3>something</Field3> <Field4>999999</Field4> <Block700> <Block800> <Field5>last</Field6> <Field6>007</Field6> <Block800> </Block270> <Block270> <Field1>some text2</Field1> <Field2>111111</Field2> <Block700> <Field3>something2</Field3> <Field4>888888</Field4> <Block700> <Block800> <Field5>last2</Field6> <Field6>008</Field6> <Block800> </Block270> And the desired output would be: some text666666 something999999 last007 some text2111111 something2888888 last2008 Is this possible, to do? If its not what source files should I change, to make this work. Thanks for your time, Jos=C3=A9 Santos -------------------------------------------------------------------------= --- = -------------------------------------------------------------------------= This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/=20 -------------------------------------------------------------------------= --- _______________________________________________ Servingxml-help mailing list Ser...@li... https://lists.sourceforge.net/lists/listinfo/servingxml-help -------------------------------------------------------------------------= ----- = -------------------------------------------------------------------------= This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ -------------------------------------------------------------------------= ----- _______________________________________________ Servingxml-help mailing list Ser...@li... https://lists.sourceforge.net/lists/listinfo/servingxml-help |