Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

How to add an attribute

Question posted by: moonlight0211 (Newbie) on June 23rd, 2008 12:23 PM
Hi All

Help me
How to add a "xmlns:xsi" as an attribute to the root of my xml document if it is not coming from the source xml.

Thanks in advance

Mona
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
jkmyoung's Avatar
jkmyoung
Moderator
765 Posts
June 23rd, 2008
02:50 PM
#2

Re: How to add an attribute
This is actually a namespace node, not an attribute.

If you mean add to your result using xslt, simply put the node in your stylesheet node, and it will get copied over.

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

Reply
moonlight0211's Avatar
moonlight0211
Newbie
2 Posts
June 25th, 2008
07:20 AM
#3

Re: How to add an attribute
Quote:
Originally Posted by jkmyoung
This is actually a namespace node, not an attribute.

If you mean add to your result using xslt, simply put the node in your stylesheet node, and it will get copied over.

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"



Thanks for replying

I don't want to copy it over but to generated it using xslt. The code i wrote is as follows:
<xsl:attribute name="xmlns:xsi" namespace="xmlns">
<xsl:text>http://www.w3.org/2001/XMLSchema-instance</xsl:text>
</xsl:attribute>

But the i output i am getting is breaked as follows
<Update xmlns:ns0="xmlns" ns0:xsi="http://www.w3.org/2001/XMLSchema-instance">

When i am trying to validate it against schema it is not getting validated.

Reply
jkmyoung's Avatar
jkmyoung
Moderator
765 Posts
June 26th, 2008
07:45 PM
#4

Re: How to add an attribute
Really, just put it in your stylesheet node like so:

Code: ( text )
  1. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">


It should appear in your root node.

Reply
Reply
Not the answer you were looking for? Post your question . . .
182,080 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Top XML Forum Contributors