Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 24th, 2010, 01:08 AM
Authorized User
 
Join Date: Dec 2009
Posts: 23
Thanks: 3
Thanked 0 Times in 0 Posts
Default Remove Namespace from root tag using xslt namespce prefix

I have a XML file with namespace in the root element as below.(Other child element i have described in short to save space).

<T0020
xsi:schemaLocation="http://www.safersys.org/namespaces/T0020V1 T0020V1.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.safersys.org/namespaces/T0020V1">
<IRP_ACCOUNT> ....<IRP_ACCOUNT>
<IRP_ACCOUNT> ....<IRP_ACCOUNT>
</T0020>

It was huge file so i have applied xslt to split it into multiple file for that my xslt is as below.

Code:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:t="http://www.safersys.org/namespaces/T0020V1" version="2.0">
<xsl:output method="xml" indent="yes" name="xml" /> 
<xsl:variable name="accounts" select="t:T0020/t:IRP_ACCOUNT" /> 
<xsl:variable name="size" select="30" />
<xsl:template match="/">
<xsl:for-each select="$accounts[position() mod $size = 1]">
<xsl:variable name="filename" select="resolve-uri(concat('output/',position(),'.xml'))" /> 
<xsl:result-document href="{$filename}" method="xml">
<T0020>
<xsl:for-each select=". | following-sibling::t:IRP_ACCOUNT[position() &lt; $size]">
<xsl:copy-of select="." /> 
</xsl:for-each>	
</T0020>
</xsl:result-document>	
</xsl:for-each>
</xsl:template>
When i do Transformation my xml file are coming with name space in <T0020>
and <IRP_ACCOUNT> tag like below...

Code:
<T0020 xmlns:t="http://www.safersys.org/namespaces/T0020V1"><IRP_ACCOUNT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.safersys.org/namespaces/T0020V1">
That was not needed.It should be
Code:
<T0020> <IRP_ACCOUNT></IRP_ACCOUNT><T0020>
when i applied like <t:T0020> in xslt it was same reflected with t prefix in
T0020 tag.

Can you please help me that how to remove name space from this tag ?

Thanks in Advance.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove Namespace from tag using tag nisargmca XSLT 9 March 19th, 2010 06:40 AM
to remove namespace prefix form input xml using xslt robin_stringss XSLT 4 May 17th, 2009 06:50 AM
Remove root namespace help? JohnBampton XSLT 2 March 6th, 2009 06:49 AM
Remove namespace prefix from XmlBean ratzko BOOK: Professional Java Development with the Spring Framework 0 August 10th, 2008 01:23 PM
How a additional prefix in a namespace comes? diang BOOK: ASP.NET Website Programming Problem-Design-Solution 0 July 13th, 2006 10:40 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.