hello all,
In XSL what would be the easiest way to remove only the <information> element of my xml file, but at the same time keeping the child elements and its contents?
Source xml file:
<envelope>
<body>
<information>
<lang>en</lang>
</information>
</body>
</envelope>
Wished transformed xml file:
<envelope>
<body>
<lang>...
</body>
</envelope>
I've managed to do it using xsl:variable with xsl:copy-of select but the problem is that I need to rewrite the tags above <information> manually in my <xsl:template > in order for them to appear. I wonder if there is an easiest way such as making a direct string replacement of the node itself such as in other programming langues (sth like a {xml document}.repla ceAll('<informa tion>', ' '), {xml document}.repla ceAll('</information>',' '). Is this possible with XSL?
Thanks,
James
2 3433 jkmyoung 2,057
Recognized Expert Top Contributor
Starting with the copy template: -
<?xml version="1.0" encoding="UTF-8"?>
-
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
-
<xsl:template match="*">
-
<xsl:copy>
-
<xsl:copy-of select="@*"/>
-
<xsl:apply-templates/>
-
</xsl:copy>
-
</xsl:template>
-
</xsl:stylesheet>
-
We make a special rule for information, where we don't copy the node. -
<xsl:template match="information">
-
<xsl:apply-templates/>
-
</xsl:template>
-
Oh well, you really made my day, thank you! Pretty tricky though, to have a <xsl:copy-of> inside a <xsl:copy>...
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Jean-Christophe Michel |
last post by:
Hi,
In a complex merging of two (non ordered) xml files
i need to keep track of the elements of the second tree that were already
merged with first tree, to copy only unused elements at the end.
I tried two solutions:
* first is to 'substract' the used element from existing tree
|
by: Fredrik Henricsson |
last post by:
Hey, I'm building an ontology in Protégé and I want to transform parts of it
(e.g. the instances) to HTML with XSL. When I was transforming another file
with 'simple' XML-tags like <author> before, I got it working, but the
OWL-file is formatted differently and I don't know how to access the
elements. I'll post the .owl file below, but this is basically what I want
to get from the file (the course name):
<Course...
|
by: jimbo_vr5 |
last post by:
Hey
I think i've figured out the idea behind apply-templates. But going
through the tutorial on
<http://www.w3schools.com/xsl/xsl_apply_templates.asp> theres simply
just something that i dont get! In the following i've copy pasted the
example from <http://www.w3schools.com/xsl/xsl_apply_templates.asp>
into this post. I divide into sections and my real question will come
after the code snippet:
|
by: MedIt |
last post by:
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"...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |