Sign Up
Search
Options
search
Chat
Help
News
Log in
Not Logged in
Home
»
Boards
»
Stylus Studio Developer Network
»
XSLT Help and Discussion
»
Add a namespace
Topic
Topic Page
1
2
3
4
5
6
7
8
9
Prev Topic
Next Topic
next
Subject:
Add a namespace
Author:
Andres Garcia
Date:
02 Jun 2007 12:42 PM
Originally Posted: 02 Jun 2007 12:35 PM
Hello.
I have a xml input that can have or not a namespace defined. If not, I have to add a default one, like the following:
input:
<a>
<b>
xxx
</b>
</a>
expected output:
<rq:a xmlns:req="
http://xyz">
<rq:b>
xxx
</rq:b>
</rq:a>
How can this be done with a xlst transformation?
Thanks in advance.
next
Subject:
Add a namespace
Author:
(Deleted User)
Date:
04 Jun 2007 03:18 PM
Hi Andres,
you should have a template matching the namespace-less node that generates the correct version:
<xsl:stylesheet version="1.0" xmlns:rq="
http://xyz"
xmlns:xsl="
http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:apply-templates select="*"/>
</xsl:template>
<xsl:template match="*[namespace-uri()='']">
<xsl:element name="rq:{local-name(.)}">
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Hope this helps,
Alberto
top
Subject:
Add a namespace
Author:
Andres Garcia
Date:
05 Jun 2007 11:55 AM
Thanks very much Alberto. It is exactly what I needed.
andres.
Topic Page
1
2
3
4
5
6
7
8
9
Prev Topic
Next Topic
Powered by
Stylus Studio
, the world's leading
XML IDE
for
XML
,
XSLT
,
XQuery
,
XML Schema
,
DTD
,
XPath
,
WSDL
,
XHTML
,
SQL/XML
, and
XML Mapping
!
Go to Conference:
Select Conference
Stylus Studio Feature Requests
Stylus Studio Technical Forum
Website Feedback
XSLT Help and Discussion
XQuery Help and Discussion
Stylus Studio FAQs
Stylus Studio Code Samples & Utilities
Stylus Studio Announcements
go
Log In Options
Username:
Password:
Site Map
|
Privacy Policy
|
Terms of Use
|
Trademarks
Stylus Scoop XML Newsletter:
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.