Add namespace prefix using XSL

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>
pattabi23inAsked:
Who is Participating?
 
Geert BormansConnect With a Mentor Information ArchitectCommented:
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
 
pattabi23inAuthor Commented:
Thank you very much.
0
 
Geert BormansInformation ArchitectCommented:
welcome
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.