[xquery-talk] renaming single attributes

Howard Katz howardk at fatdog.com
Mon Jun 20 10:29:27 PDT 2005


What's the easiest and/or most concise way of effecting a transformation
that renames a single named attribute, if present, and leaves everything
else the same?  For example, I might want to rename every occurrence of
@att3 (two instances below) as @NEW-att3. Here's some sample "before" data:

    <record att1="att1" att3="att3" att4="att4">content1</record>
    <record att3="att3" att4="att4">content2</record>
    <record att4="att4" att5="att5">content3</record>

Here's the "after" version of the same. Note that all nodes except @att3
remains the same:

    <record att1="att1" NEW-att3="att3" att4="att4">content1</record>
    <record NEW-att3="att3" att4="att4">content2</record>
    <record att4="att4" att5="att5">content3</record>

What's the simplest document tranformation that will accomplish this goal?
Howard

PS: As per my committment here on Saturday I've made a PayPal donation of
$3.44 to Michael Kay's sourceforge account. Since PayPal requires payments
in increments of $5, I actually donated $10, with the balance of $6.56 going
toward "Michael's contributions on behalf of oss".

I encourage other readers to reward elegant and/or particularly interesting
or useful submissions to this list in similar fashion.



More information about the talk mailing list