a follow up with new problems from my previous post:
I have xml encoded in a string with elements like <myElemen t/>
e.g
<codeFragment > <myElement&g t;some text</myElement>
</codeFragment>
I parse this in Xerces and I can see it has done the correct thing,
but now I want to serialize the output so it **looks** like valid xml,
i.e.
<codeFragment > <myElement>some Text</myElement> </codeFragment>
this doesnt happen; instead I get
<codeFragment > <myElement>s omeText </myElement> </codeFragment>
I dont want to change the DOM model, I just want the serializer to
output text which has the "<" in it. Is there some way of stopping it
escaping the "<" ?
note: unfortunately I am restricted to simple text in the node, I cannot
insert a CDATA. (not sure this would solve it anyway).
cheers
shaun 3 2561
shaun roe (sh*******@wana doo.fr) wrote:
: a follow up with new problems from my previous post:
: I have xml encoded in a string with elements like <myElemen t/>
: e.g
: <codeFragment > <myElement&g t;some text</myElement>
: </codeFragment>
: I parse this in Xerces and I can see it has done the correct thing,
: but now I want to serialize the output so it **looks** like valid xml,
: i.e.
: <codeFragment > <myElement>some Text</myElement> </codeFragment>
: this doesnt happen; instead I get
: <codeFragment > <myElement>s omeText </myElement> </codeFragment>
: I dont want to change the DOM model, I just want the serializer to
: output text which has the "<" in it. Is there some way of stopping it
: escaping the "<" ?
: note: unfortunately I am restricted to simple text in the node, I cannot
: insert a CDATA. (not sure this would solve it anyway).
Is there some option to _not_ escape the text? I know that using xalan
you can use an option (it's part of xlst) to not escape text. Since xalan
is based on xerces, I wonder if it is xerces that has an option to do
this?
OR
Take your text after it is un-escaped and parse that a second time. Now
take that small node tree and splice it into the original in place of the
text that contained the escaped < & >'s. When the whole is serialized
then that part of the xml will be output with tags as you wish. ($0.10)
--
This programmer available for rent.
shaun roe wrote: I have xml encoded in a string with elements like <myElemen t/>
e.g
<codeFragment > <myElement&g t;some text</myElement> </codeFragment>
I parse this in Xerces and I can see it has done the correct thing, but now I want to serialize the output so it **looks** like valid xml, i.e. <codeFragment > <myElement>some Text</myElement> </codeFragment>
You can only talk about "valid" XML if you have a DTD or schema.
As for those snippets, both are "well-formed" XML, obviously the first
one is one elements with some text as a child node while the second is
an element with text and an element as child nodes.
this doesnt happen; instead I get
<codeFragment > <myElement>s omeText </myElement> </codeFragment>
Text has to be serialized with '<' escaped as <, otherwise it is not
a proper serialization.
I dont want to change the DOM model, I just want the serializer to output text which has the "<" in it. Is there some way of stopping it escaping the "<" ?
If you first choose to escape some XML markup as text in an XML document
you can't complain that the XML tools then treat that as text. Of course
with the DOM you can read out the text contents of an element and then
feed that to a new DOM parser to parse it as XML.
Or you would need to write your own serializer traversing a DOM tree and
not escaping text contents or perhaps not escaping text contents in
certain elements.
--
Martin Honnen http://JavaScript.FAQTs.com/
shaun roe wrote: a follow up with new problems from my previous post:
I have xml encoded in a string with elements like <myElemen t/>
e.g
<codeFragment > <myElement&g t;some text</myElement> </codeFragment>
That isn't XML. It's text that happens to have character entities in it.
I parse this in Xerces and I can see it has done the correct thing, but now I want to serialize the output so it **looks** like valid xml, i.e. <codeFragment > <myElement>some Text</myElement> </codeFragment>
this doesnt happen; instead I get
<codeFragment > <myElement>s omeText </myElement> </codeFragment>
I dont want to change the DOM model, I just want the serializer to output text which has the "<" in it. Is there some way of stopping it escaping the "<" ?
note: unfortunately I am restricted to simple text in the node, I cannot insert a CDATA. (not sure this would solve it anyway).
See the FAQ: http://xml.silmaril.ie/authors/html/
///Peter This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: wenke |
last post by:
Hi,
I am using the following code (see below) from php.net
(http://www.php.net/manual/en/ref.xml.php, example 1) to parse an XML
file (encoded in UTF-8). I changed the code slightly so that the cdata
sections will be echoed an not the element names as in the original
example.
In the cdata sections of my XML file I have terms like this:
|
by: Donald Firesmith |
last post by:
I am having trouble having Google Adsense code stored in XSL converted
properly into HTML. The <> unfortunately become < and > and then
no longer work.
XSL code is:
<script type="text/javascript">
<!]>
</script>
<script type="text/javascript"
|
by: Sammy |
last post by:
Hi, my mind is going crazy. I have tried everything I can think of to
no
avail.
I have tried Disable Output Escaping.
I tried to think of a way of enclosing the attribute data in a CDATA
element. That did not parse.
Here is my question:
How can I get attribute values to not get converted from ' to '
|
by: higabe |
last post by:
Three questions
1)
I have a string function that works perfectly but according to W3C.org
web site is syntactically flawed because it contains the characters </
in sequence. So how am I supposed to write this function?
String.replace(/</g,'<');
|
by: Francesco Moi |
last post by:
Hello.
I designed a form to edit some DataBase's fields. But some
of these fields contain '<' and '>' characters. And
these characters are '<' and '>' in HTML.
So if want to edit these fields, the form converts them
into '<' and '>'. And I want to mantain '<' and '>'
Mi piece of code:
| |
by: andrew007 |
last post by:
I do xml / xslt transformation using asp.net but I found
any value (w/xml format) in xml node html-encoded to < and > format if
it's > or < tag.
Since I have sub xml data in a parent xml node as a value.
Check out the following problem. I want to convert the value in <WpDatesXml>
node to have a valid "<" and ">" instead of < or > format so that I can
use this xml for another use. Please help!
<NewDataSet>
<Table1>
|
by: webmasterATflymagnetic.com |
last post by:
Folks,
I'm struggling to put the question together, but I have this problem.
I have written an HTML form that I can use for data entry. This uses
PHP to write a SQL UPDATE command that gets written to my MySQL
database. I can later view this data back in the form.
One thing I've noticed happening is if I enter code such as < it
gets rewritten as < (ie the less-than sign). Now I don't want this to
happen, but something somewhere is...
|
by: mark4asp |
last post by:
I have an element, report which contains tags which have been
transformed. E.g. <pis <p>
<myXml>
<report>This text has html tags in it.<p> which but <has been
changed to <></report>
</myXml>
I there a way that the XSLT transformation can render the content as
html rather than text?
|
by: ismailc |
last post by:
Hi, I need help please.
Update system to to new version & moved on to .Net2
But now my code that worked in my .Net1 xslt does not work.
.Net1 fine:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:asp="remove" xmlns:igchart="remove" xmlns:igsch="remove">
<td class='rowDet' id="td_<xsl:value-of select='@name' />">
.Net2 don't work:
<xsl:stylesheet...
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |