- From: Chen Ya Bing <iscp0054@nus.edu.sg>
- Date: Tue, 19 Feb 2002 10:29:07 +0800
- To: "Jim Davies" <jdavies@neocore.com>
- Cc: <www-ql@w3.org>
- Message-ID: <003701c1b8ed$34c35120$96538489@comp.nus.edu.sg>
Messagebut 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 21:29:26 UTC