[xquery-talk] renaming single attributes
Howard Katz
howardk at fatdog.com
Mon Jun 20 15:15:07 PDT 2005
Obviously trivial if your implementation does update! If not, then there's
always Mike's wd-sanctioned solution.
Howard
> -----Original Message-----
> From: Jason Hunter [mailto:jhunter at xquery.com]
> Sent: Monday, June 20, 2005 2:02 PM
> To: Howard Katz
> Cc: talk at xquery.com
> Subject: Re: [xquery-talk] renaming single attributes
>
> > 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
>
> As I know you've been using MarkLogic Server for some of
> your work, here's how you'd do it there:
>
> for $att3 in $doc//@att3
> return
> xdmp:node-replace($att3, attribute { "NEW-att3" } { string($att3) })
>
> -jh-
>
More information about the talk
mailing list