|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: change a list of attribute name
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








