|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] [XQuery Update Newbie] Rename all element nodes(in no namespace) to the same name, but in a namespace?Michael Kay mike at saxonica.comMon Feb 22 15:00:57 PST 2010
Thanks, now fixed, see
https://sourceforge.net/tracker/?func=detail&aid=2956607&group_id=29872&atid
=397617
Regards,
Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay
> -----Original Message-----
> From: Costello, Roger L. [mailto:http://x-query.com/mailman/listinfo/talk]
> Sent: 22 February 2010 12:33
> To: Michael Kay; http://x-query.com/mailman/listinfo/talk
> Subject: RE: [XQuery Update Newbie] Rename all
> element nodes(in no namespace) to the same name, but in a namespace?
>
> Hi Michael,
>
> Here is the XQuery Update file I used:
> ---------------------------------------------------
> for $i in doc('FitnessCenter.xml')//*
> return rename node $i as QName('http://www.gym.com',
> concat('gym:', local-name($i)))
> ---------------------------------------------------
>
> Here is FitnessCenter.xml:
> ---------------------------------------------------
> <FitnessCenter>
> <Member Level="platinum">
> <Name>Jeff</Name>
> <FavoriteColor>lightgrey</FavoriteColor>
> </Member>
> <Member Level="gold">
> <Name>David</Name>
> <FavoriteColor>lightblue</FavoriteColor>
> </Member>
> <Member Level="platinum">
> <Name>Roger</Name>
> <FavoriteColor>lightyellow</FavoriteColor>
> </Member>
> </FitnessCenter>
> ---------------------------------------------------
>
> Here is the result:
> ---------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <gym:FitnessCenter xmlns:gym="http://www.gym.com">
>
> <gym:Member xmlns:gym="http://www.gym.com"
> xmlns:gym="http://www.gym.com" Level="platinum">
>
> <gym:Name xmlns:gym="http://www.gym.com"
> xmlns:gym="http://www.gym.com">Jeff</gym:Name>
>
> <gym:FavoriteColor xmlns:gym="http://www.gym.com"
> xmlns:gym="http://www.gym.com">lightgrey</gym:FavoriteColor>
>
> </gym:Member>
>
> <gym:Member xmlns:gym="http://www.gym.com"
> xmlns:gym="http://www.gym.com" Level="gold">
>
> <gym:Name xmlns:gym="http://www.gym.com"
> xmlns:gym="http://www.gym.com">David</gym:Name>
>
> <gym:FavoriteColor xmlns:gym="http://www.gym.com"
> xmlns:gym="http://www.gym.com">lightblue</gym:FavoriteColor>
>
> </gym:Member>
>
> <gym:Member xmlns:gym="http://www.gym.com"
> xmlns:gym="http://www.gym.com" Level="platinum">
>
> <gym:Name xmlns:gym="http://www.gym.com"
> xmlns:gym="http://www.gym.com">Roger</gym:Name>
>
> <gym:FavoriteColor xmlns:gym="http://www.gym.com"
> xmlns:gym="http://www.gym.com">lightyellow</gym:FavoriteColor>
>
> </gym:Member>
> </gym:FitnessCenter>
> ---------------------------------------------------
>
> I am using Saxon, version 9.2.0.6
>
> Here's how I invoked Saxon:
> ---------------------------------------------------
> java -classpath %CLASSPATH% net.sf.saxon.Query -update:on
> -tree:linked -backup:on FitnessCenter.xu
> ---------------------------------------------------
>
> /Roger
>
>
> ________________________________________
> From: Michael Kay [http://x-query.com/mailman/listinfo/talk]
> Sent: Monday, February 22, 2010 7:20 AM
> To: Costello, Roger L.; http://x-query.com/mailman/listinfo/talk
> Subject: RE: [XQuery Update Newbie] Rename all
> element nodes(in no namespace) to the same name, but in a namespace?
>
> Roger, I have managed to reproduce (and fix) the cases where
> you were getting an error about a spurious namespace
> conflict. But I haven't been able to reproduce the case where
> you get duplicate namespace declarations in the output.
>
> Can you let me know exactly how you were running this to
> obtain this output?
>
> Regards,
>
> Michael Kay
> http://www.saxonica.com/
> http://twitter.com/michaelhkay
>
>
>
> > Ghislain Fourny wrote:
> >
> > > How about
> > > for $i in doc('FitnessCenter.xml')//*
> > > return rename node $i as QName('http://www.gym.com',
> > > concat('gym:', local-name($i)))
> >
> > I tried that. This time I didn't get an error message from Saxon.
> > However, the output is not right. On all elements, except the root
> > element, there are two (repeat) namespace
> > declarations:
> >
> > <gym:FitnessCenter xmlns:gym="http://www.gym.com">
> > <gym:Member xmlns:gym="http://www.gym.com"
> > xmlns:gym="http://www.gym.com" level="platinum">
> > <gym:Name xmlns:gym="http://www.gym.com"
> > xmlns:gym="http://www.gym.com">Jeff</gym:Name>
> > <gym:FavoriteColor xmlns:gym="http://www.gym.com"
> > xmlns:gym="http://www.gym.com">lightgrey</gym:FavoriteColor>
> > </gym:Member>
> > <gym:Member xmlns:gym="http://www.gym.com"
> > xmlns:gym="http://www.gym.com" level="gold">
> > <gym:Name xmlns:gym="http://www.gym.com"
> > xmlns:gym="http://www.gym.com">David</gym:Name>
> > <gym:FavoriteColor xmlns:gym="http://www.gym.com"
> > xmlns:gym="http://www.gym.com">lightblue</gym:FavoriteColor>
> > </gym:Member>
> > <gym:Member xmlns:gym="http://www.gym.com"
> > xmlns:gym="http://www.gym.com" level="platinum">
> > <gym:Name xmlns:gym="http://www.gym.com"
> > xmlns:gym="http://www.gym.com">Roger</gym:Name>
> > <gym:FavoriteColor xmlns:gym="http://www.gym.com"
> > xmlns:gym="http://www.gym.com">lightyellow</gym:FavoriteColor>
> > </gym:Member>
> > </gym:FitnessCenter>
> >=
|
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


![[XQuery Update Newbie] Rename all element nodes(in
no namespace) to the same name](/images/get_stylus.gif)





