Subject: [xsl] Convert XML elements with extended attributes into CSV From: Xiaocun Xu <xiaocunxu@xxxxxxxxx> Date: Fri, 25 May 2001 20:07:59 -0700 (PDT) |
Hi, I have a problem trying to convert XML elements with extended attributes into CSV format. For example, I have a XML with the following structure: first part defines the necessary extended attributes, the second part has LineItems use both fixed and extend attributes <RFQ> <RFQExtendAttrDef Domain="line_item" Code="item_ext1" Name="item_ext1"/> <RFQExtendAttrDef Domain="line_item" Code="item_ext2" Name="item_ext2"/> <RFQExtendAttrDef Domain="bid" Code="bid_ext1" Name="bid_ext1"/> <LineItem Name="item1" Category="cat1"> <ExtendAttr Code="item_ext2" Value="item1 ext2"/> </LineItem> <LineItem Name="item2" Category="cat1"> <ExtendAttr Code="item_ext1" Value="item2 ext1"/> <ExtendAttr Code="item_ext2" Value="item2 ext2"/> </LineItem> </RFQ> The resulting CSV I need is: Domain,Code,Name line_item,item_ext1,item_ext1 line_item,item_ext2,item_ext2 Name,Category,item_ext1,item_ext2 item1,cat1,,item1 ext2 item2,cat1,item2 ext1,item2 ext2 I thought the best way to attack this would be: 1. build each of the two section headers into a node, including both fixed and extended attributes. For LineItem, it would like: <LineItemHeader> <cell column="1">Name</cell> <cell column="2">Category</cell> <cell column="3">item_ext1</cell> <cell column="4">item_ext2</cell> </LineItemHeader> 2. for each LineItem element, process its attributes sequentially according to the column number indicated in the header node, such as the LineItemHeader shown above. So my questions are: 1. Is the above solution fesible? 2. Is there better way to do this? 3. If there is no better way to do this, how can the first step, i.e. build the header node, be achieved? 4. Would this solution be still fesible if the RFQExtendAttrDef elements does NOT exist? (this is a possibility in certain cases) Building the header node would require scan all LineItem elements for unique attributes. Sorry for the long winded description, hope I managed to describe the problem clearly. Any suggestions would be very much appreciated. Thanks, Xiaocun __________________________________________________ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] How to perse the whole so, Michael Kay | Thread | Re: [xsl] Convert XML elements with, Jeni Tennison |
[xsl] XSL List, Gustaf Liljegren | Date | [xsl] Re: (xsl) processing siblings, Dimitre Novatchev |
Month |