473,414 Members | 1,936 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,414 software developers and data experts.

XSLT preserve whitespaces

Hi there
I am using XSLT to process an XML file.I want to copy all whole XML and want to modify some attribute node.I using follwing code
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3.     xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
  4.      xmlns:db="http://tempuri.org/DatabaseXMLSchema.xsd">
  5.   <xsl:output method="xml" indent="yes"/>
  6.   <xsl:template match="@* | node()">
  7.     <xsl:copy>
  8.       <xsl:apply-templates select="@* | node()"/>
  9.     </xsl:copy>
  10.   </xsl:template>
  11.   </xsl:stylesheet>
but i lost the whitespaces in this case if I add the " xml:space='preserve'" and use follwing
<xsl:template match="@* | node()" xml:space="preserve">
then I got follwing error
Attribute and namespace nodes cannot be added to the parent element after a text, comment, pi, or sub-element node has already been added.

please help me how can I do that....
Jan 8 '10 #1
1 1726
Frinavale
9,735 Expert Mod 8TB
Have you tried adding xml:space="preserve" to the template before adding the child element?

-Frinny
Jan 8 '10 #2

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

Similar topics

3
by: Phil | last post by:
Hi everybody, I am a XSLT beginner and the following problem really makes me crazy ! I have a main "contacts.xml" document which contains references to several contact data XML files. My aim...
2
by: Joe | last post by:
How would you preserve tags from an XML element in XSLT output.. Example: XML document has an ELEMENT "SECTION" allowing contained HTML This element might have an element such as <A...
4
by: Luke Dalessandro | last post by:
I have some XML data that has mixed content XML tags that embed XHTML tags, for instance: <note>Somebody wrote this note in XHTML and wanto to <a href="link.html" target="_new">link</a> to a...
2
by: Gibson | last post by:
Hi all, i transform xml A to xml B with an xslt. Is it possible to use that xslt to tranform xml B to xml A? Or exist tools to create a corresponding xslt B from the original xslt? Thanks for...
4
by: dwergkees | last post by:
Hi, Got a litte problem here. I'm trying to create a XSLT file that will do a transformation from WordML format (MS Word XML format, see...
2
by: rn5a | last post by:
When a Button is clicked in a Form, the JavaScript 'prompt' dialog pops-up for users to enter any text. When the user clicks OK in the prompt dialog, the text is populated in a TextBox & the Form...
4
by: n.phelge | last post by:
I need to perform an XSLT to set the namespace on some XML and I need to preserve the original document line formatting to assist with error handling (so the line number from any schema validation...
3
by: realmerl | last post by:
Hi All. I'm trying to transform a html document into plain text via xslt. Simple you say! (i hope) I have got it working, by using the magnificent <xsl:value-of select="."/>. This returns the...
18
by: malathib | last post by:
Hi, while trasforming xml to html using xslt, i dont want to lose xml tags.I want to preserve it. After transforming to html and displaying in browser and if you are right clicking and viewing...
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.