473,387 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Removing an attribute from an element in xsl

15
Hi,
I am new in using xsl.I am stuck in a simple task,which is trying to remove an atribute from a node,and keep the rest of the attributes of this element in the xslt.
I have tried a couple of options but to no use so far!
Can any one shed some light on me?
Here's a sample of my original xml:

<?xml version="1.0" encoding="UTF-8" ?>
<dom xmlns="http://www.cdisc.org/ns/odm/v1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance"
xsi:schemaLocation="http://www.cdisc.org/ns/odm/v1.2 http://www.cdisc.org/schema/odm/v1.2.1/ODM121.xsd"
CreationDateTime="20060203T14:03:06" Granularity="All" AsOfDateTime="20060203T14:03:10">
/* children node here */

</dom>

And I want my transformed xml to be:
<?xml version="1.0" encoding="UTF-8" ?>
<dom xmlns="http://www.cdisc.org/ns/odm/v1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance"
xsi:schemaLocation="http://www.cdisc.org/ns/odm/v1.2 http://www.cdisc.org/schema/odm/v1.2.1/ODM121.xsd"
CreationDateTime="20060203T14:03:06" Granularity="All" >
/* children node here */

</dom>

removing the 'AsOfDateTime' attribute of the dom element.
Thanks your help in advance!

MedIt
Feb 22 '08 #1
2 12808
jkmyoung
2,057 Expert 2GB
AsOfDateTime

A typical copy template looks like so:
Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="*">
  2.   <xsl:copy>
  3.     <xsl:copy-of select="@*">
  4.     <xsl:apply-templates/>
  5.   </xsl:copy>
  6. </xsl:template>
So just change the copy-of to
<xsl:copy-of select="@*[name() != 'AsOfDateTime']">
Feb 22 '08 #2
MedIt
15
Thanks for your help!
I managed to alter a bit from what you specefied.
Thanks so much!
AsOfDateTime

A typical copy template looks like so:
Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="*">
  2.   <xsl:copy>
  3.     <xsl:copy-of select="@*">
  4.     <xsl:apply-templates/>
  5.   </xsl:copy>
  6. </xsl:template>
So just change the copy-of to
<xsl:copy-of select="@*[name() != 'AsOfDateTime']">
Feb 26 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Matt | last post by:
Hello, I have an XML document similar to the following: <DataItems> <Data xmlns="http://www.me.com"> <DataInformation xmlns:a="http://www.me.com/ASettings" xsi:type="a:Stuff1">...
2
by: bmgz | last post by:
I have written a simple function that validates a form based on the form objects' className attribute. The form basically write a "field required" message next to the form element that is blank(and...
2
by: Greg | last post by:
Hi. I have a rather large xml document (object) that can have one or more nodes with a certain attribute throughout (at ANY depth, not at the same level necessarily). I need to find this...
1
by: Maziar Aflatoun | last post by:
Hello, I have a string variable that contains XML data with many different namespaces. I like to remove all the namespaces from my XML (clean the XML). What's the quickest way to do this? Ex....
3
by: kevin | last post by:
Is that even possible? I am creating a web service in .NET to expose some already created .NET programs to other groups. One group is writing the client in PERL, and thus wishes the wsdl schema...
7
by: Simon Hart | last post by:
Hi, I have a requirement to remove the xmlns from the DOM in order to pass over to MS CRM 3.0 Fetch method.It seems the fetch method blows up if there is a xmlns present!?! The reason I have a...
6
by: Chris Chiasson | last post by:
Hi, After reading and experimenting for a several hours, I have this stylesheet: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"...
4
by: =?Utf-8?B?UmFqaXY=?= | last post by:
Hi, I have a webservices(developed in .net 2.0, using c#) with a webmethod that returns a XML document. The problem is that the XML returned from the webservice is having a attribute xmlns="" in...
10
by: Andy Fish | last post by:
hi, I have an XSLT which is producing XML output. many of the nodes in the output tree contain namespace declarations for namespaces that are used in the source document even though they are...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.