Subject: RE: [xsl] Novice question: selecting an element based on an attribute id From: ohmson@xxxxxxxxxxxx (ohmson ampere) Date: Wed, 20 Mar 2002 13:46:43 -0500 |
"Michael Kay" <michael.h.kay@xxxxxxxxxxxx> wrote: >> I'm an novice user of XSLT but was tasked to transform an >> incoming XML file into another format. So far so good but I >> ran into a perplexing problem. Here's the short example of an >> incoming XML file: >> >> <object> >> <class name="TestF"> >> <field name="_str1" type="java.lang.String"/> >> <field name="_str3" type="java.lang.String"/> >> </class> >> <String field="_str1" myId="28"><![CDATA[a test of >> referencing.]]></String> >> <String field="_str3" myIdRef="28"/> >> </object> >> >> This needs to be transformed simply to >> >> </object> >> <_str1><![CDATA[a test of string referencing.]]></_str1> >> <_str3><![CDATA[a test of string referencing.]]></_str3> >> </object> >> >> As you can see, > >I may be blind, but I can't see. Could you explain more clearly the >relationship of your output to your input? > I apologize for the quick cut-n-paste and the opening tag should be <object>. Anyway, the transformation is: 1. Look for elements in the source with the attribute "field" and use that as an element in the target. Hence, you see that <String field="_str1" myId="28"><![CDATA[a test of referencing.]]></String> becomes <_str1><![CDATA[a test of string referencing.]]></_str1> 2. If the element contains a reference instead, look for the data in the source instead of just using the reference. Hence, <String field="_str3" myIdRef="28"/> becomes <_str3><![CDATA[a test of string referencing.]]></_str3> instead of <_str3 myIdRef="28" /> I saw that one of the previous post actually address the problem pretty. Thanks to Jenni. Cheers -- __________________________________________________________________ Your favorite stores, helpful shopping tools and great gift ideas. Experience the convenience of buying online with Shop@Netscape! http://shopnow.netscape.com/ Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Novice question: selectin, Michael Kay | Thread | RE: [xsl] Novice question: selectin, Michael Kay |
RE: [xsl] Novice question: selectin, Brinkman, Theodore | Date | [xsl] More efficient way than follo, Michael Glick (B) |
Month |