[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: generating xml from xml

Subject: Re: generating xml from xml
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 10 Nov 2003 11:19:09 -0500
xml from xml

Keys were invented for just this kind of application.

Declare a key that lets you retrieve your field mapping elements by their id values:

<xsl:key name="field-by-id" match="_" use="@id"/>

Then, for example,

<xsl:template match="Trade/*">
  <xsl:element name="key('field-by-id',local-name())/fn">

would match a child of Trade and create an element with the appropriate name (if I have it right).

Really, I'm helping you less by writing the code than I would by explaining it better -- but you can (and should) find a good explanation of keys in a published resource.

Whether MSXML3.0 supports keys, I can't say for sure (though I think it does). If not, this can still be done with brute force (albeit expensively) using an XPath location path.


At 10:31 AM 11/10/2003, you wrote:
I have a situation where I have to apply xsl on some xml and generate slightly different xml. I hope you people can help me.

this is my xml :

<Data Timestamp="2003-11-05 21:00:07">
                <_ fn="Level1" id="F0"/>
                <_ fn="Level2" id="F1"/>
                <_ fn="Level3" id="F2"/>
                <_ fn="TradeDate" id="F3"/>
                <_ fn="TradeId" id="F4"/>
                <_ fn="User" id="F5"/>

and I am trying to generate :

<Data Timestamp="2003-11-05 21:00:07"> <Trades> <Trade> <Level1/> <Level2/> </Trade> <Trade> <Level1/> <Level2>Entry</Level2> <Level3/> </Trade> <Trade> <Level1>Mid</Level1> <Level2/> <Level3/> <TradeDate/> <TradeId>126</TradeId> </Trade> </Trades> </Data>

and my limitation is, the parser I can use should be MSXML3.0 or less.

Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
  Mulberry Technologies: A Consultancy Specializing in SGML and XML

XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.