Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Attributes to end element

0 views
Skip to first unread message

nakutts

unread,
Sep 11, 2009, 7:29:22 AM9/11/09
to

Hi..
I am trying to add an attribute to the end element.I believe that
attributes
to the end element are allowed in the extensions provided to xml.
Can anyone provide me information on what options i have to add to
the schema
to enable this?

I am trying to calculate the CRC of a xml file and write it to xml as
the attribute
of the end element.
Thanks in advance
Bhavana

Bob

unread,
Sep 14, 2009, 6:52:01 AM9/14/09
to
Here is a demo:

DECLARE @xml XML, @i INT

SET @xml = '<root><element1></element1><element2></element2></root>'
SET @i = 2

SELECT 'before', @xml

-- Add attribute to root node
SET @xml.modify('insert attribute records {sql:variable("@i")} into root[1]')

SELECT 'after', @xml

If this does not work for you, can you provide a small sample of what your
XML looks like before and your expected results?

HTH
wBob

Bob

unread,
Sep 14, 2009, 7:17:01 AM9/14/09
to
I also got his to work using the XQuery last function:

SET @xml.modify('insert attribute records {sql:variable("@i")} into

(//*[last()])[1]')

0 new messages