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

Re: change a list of attribute name

Subject: Re: change a list of attribute name
From: Xiaocun Xu <xiaocunxu@xxxxxxxxx>
Date: Fri, 3 Aug 2001 13:31:49 -0700 (PDT)
change name in yahoo messenger
Great :)  Thanks for the tip.  This solution would
leave the XSL to be free of this mapping clutter.  I
will experiment with the approach this weekend.

Much thanks,
Xiaocun

--- Jeni Tennison <mail@xxxxxxxxxxxxxxxx> wrote:
> Hi Xiaocun,
> 
> > I failed to show the more complicated case where
> "Organization
> > Unique ID" need to be transformed into
> "OrganizationCode". There
> > isn't a set rule to transform from one to another.
> So I am looking
> > for a more general solution where one set of
> values can be mapped to
> > another set.
> 
> Oh right. I was confused by the fact that you said
> you were
> *generating* the node set of new node names - I
> thought you meant that
> you were generating the new node names on the fly,
> not that they were
> static. In that case I'd probably use a document
> holding the mapping
> information for those that had non-standard maps,
> have something like
> map.xml:
> 
> <maps>
>   <map value="Organization Unique ID"
> name="OrganizationCode" />
>   ...
> </maps>
> 
> Hold that document in a variable:
> 
> <xsl:variable name="maps"
> select="document('map.xml')" />
> 
> Define a key that indexed the names by the values
> that should be
> converted into those names:
> 
> <xsl:key name="maps" match="map/@name"
> use="../@value" />
> 
> And then do something similar to what I said before:
> 
>   <xsl:for-each select="$header/cell">
>     <xsl:variable name="value" select="." />
>     <xsl:variable name="attrName">
>        <xsl:for-each select="$maps">
>          <xsl:variable name="mapName"
> select="key('maps', $value)" />
>          <xsl:value-of select="$mapName" />
>          <xsl:if test="not($mapName)">
>            <xsl:value-of select="translate($value, '
> ', '')" />
>          </xsl:if>
>        </xsl:for-each>
>     </xsl:variable>
>     <xsl:attribute name="{$attrName}">
>       ...
>     </xsl:attribute>
>   </xsl:for-each>
> 
> There's no need to use a node-set() extension
> function if you access
> the information about the non-standard names using
> the document()
> function.
>   
> Cheers,
> 
> Jeni
> 
> ---
> Jeni Tennison
> http://www.jenitennison.com/
> 
> 
>  XSL-List info and archive: 
> http://www.mulberrytech.com/xsl/xsl-list
> 


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.