- From: Chen Ya Bing <iscp0054@nus.edu.sg>
- Date: Tue, 19 Feb 2002 11:47:46 +0800
- To: "Michael Rys" <mrys@microsoft.com>
- Cc: <www-ql@w3.org>
- Message-ID: <005f01c1b8f8$31d4e2c0$96538489@comp.nus.edu.sg>
Messagecould you give me more detail of how to use the data() function? is it like that: for $x in document("test.xml")/test return <test> <a> {$x/@a/data()} </a> {$x/b} </test> I tried to execute it with quip or microsoft demo, but both failed. maybe they do not support it now. Best regards, ----- Original Message ----- From: Michael Rys To: Chen Ya Bing ; Jim Davies Cc: www-ql@w3.org Sent: Tuesday, February 19, 2002 10:31 AM Subject: RE: transform an attribute to an element Text() is an XPath node test and thus cannot work on attributes (thanks to XPath 1.0). Use data() instead. Best regards Michael -----Original Message----- From: Chen Ya Bing [mailto:iscp0054@nus.edu.sg] Sent: Monday, February 18, 2002 18:29 PM To: Jim Davies Cc: www-ql@w3.org Subject: Re: transform an attribute to an element but it failed when using Quip from SoftwareAG. I think the function text() can only apply to elements, not to attributes. ----- Original Message ----- From: Jim Davies To: Chen Ya Bing Sent: Tuesday, February 19, 2002 1:06 AM Subject: RE: transform an attribute to an element Hello, You can do this fairly simply with a for loop and element constructors, like this: for $x in /test return <test> <a>{$x/@a/text()}</a> {$x/b} </test> where the text() is necessary to make sure that the value of @a gets returned rather than having it remain an attribute. Basically this loop just takes the original document apart and then re-assemble it without the attribute but with the new child element. Hope that helps (I'm still learning this stuff also... :-) Jim Davies Senior Engineer Neocore Inc. jdavies@neocore.com "There is a difference between knowing the path and walking the path." -- Morpheus, "The Matrix" -----Original Message----- From: Chen Ya Bing [mailto:iscp0054@nus.edu.sg] Sent: Monday, February 18, 2002 2:04 AM To: www-ql@w3.org Subject: transform an attribute to an element Hi, who can tell me if I can use XQuery to transform an attribute to an element? for example, the document is <test a="123"> <b>321</b> </test> I'd like to transform the attribute "a" to an element of test. <test> <a>123</a> <b>321</b> </test> thank you!
Received on Monday, 18 February 2002 22:47:58 UTC