?
Solved

Add namespace prefix using XSL

Posted on 2008-11-06
3
Medium Priority
?
1,545 Views
Last Modified: 2013-11-18
I wanted to know whether it would be possible to apply namespace prefix to all the nodes within a given xml?

For example I want to convert the following xml
<head>
<child1>
</child1>
</head>

to:
<s:head xmlns:s="hello"><s:child1></s:child1></s:head>
0
Comment
Question by:pattabi23in
  • 2
3 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 2000 total points
ID: 22894995
one way to do this
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:s="hello">
    <xsl:template match="*">
        <xsl:element name="s:{local-name()}">
            <xsl:apply-templates select="node()"/>
        </xsl:element>
    </xsl:template>
</xsl:stylesheet>

Open in new window

0
 

Author Closing Comment

by:pattabi23in
ID: 31513885
Thank you very much.
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 22895281
welcome
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question