I have an xml format for creating a database; lets say a fragment looks
like this:
<insertValue type="int">7</insert>
<insertValue type="string">H ello everyone</insert>
now I have a document I am transforming into this format using XSLT:
<nDwarves>7</nDwarves>
<snowWhiteSays> Hello everyone</snowWhiteSays>
<groupReply><po ssibleReplies replyTo="greeti ng">hello</possibleReplies >
<possibleReplie s replyTo="workSi gnal">hi ho, hi ho</possibleReplies >
</groupReply>
My problem is that I want to put the entire contents of the <groupReply>
node into a string, escaping the "<" and ">", so that I have an
insertValue node containing the string which is essentially a bit of
escaped xml.
Unfortunately, <xsl:copy-of... > doesnt have an option to escape the xml
characters, so far as I can see. Is there another way?
background:
why do this?
I am using the Xerces2.3 parser to get the text content of the
<insertValue> nodes, then I upload it. If I have straight xml inside
this node, then getTextContent simply returns the collapsed text content
of all the child elements * with no element names etc, when what I want
is the actual xml fragment to insert in my database as a string. I hope
to get around this by escaping the xml, so it really looks like just
another string. 1 1749
In article
<sh************ *************** **@news-reader.wanadoop ortails.com>,
shaun roe <sh*******@wana doo.fr> wrote:
it probably bad form to answer your own question, but I think this will
do it:
<!-- serializing the embedded xml into a string -->
<xsl:template name="serialize ">
<xsl:param name="nodeset"/>
<!-- openstarttag, openendtag, closetag markers, and close empty tag
marker -->
<xsl:variable name="ot" select="'<'"/>
<xsl:variable name="oet" select="'</'"/>
<xsl:variable name="ct" select="'>'"/>
<xsl:variable name="cet" select="'/>'"/>
<xsl:for-each select="$nodese t">
<xsl:variable name="n" select="name()"/>
<xsl:variable name="value" select=".[not(./*)]"/>
<xsl:variable name="attribute s">
<xsl:for-each select="./@*">
<xsl:call-template name="serialize Attribute"/>
</xsl:for-each>
</xsl:variable>
<xsl:choose>
<xsl:when test="empty(.)" >
<xsl:value-of select="concat( $ot,$n,$attribu tes,$cet,$LF)"/>
</xsl:when>
<xsl:otherwis e>
<xsl:value-of select="concat( $ot,$n,$attribu tes,$ct,$value) "/>
<xsl:call-template name="serialize ">
<xsl:with-param name="nodeset" select="./*"/>
</xsl:call-template>
<xsl:value-of select="concat( $oet,$n,$ct,$LF )"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<!--serialize one attribute -->
<xsl:template name="serialize Attribute">
<xsl:variable name="q" select="'" '"/>
<xsl:variable name="an" select="name()"/>
<xsl:variable name="av" select="."/>
<xsl:value-of select="concat( ' ',$an,'=',$q,$a v,$q)"/>
</xsl:template> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Alicia Haumann |
last post by:
I accidentally sent this to webmaster@python.org, so this could be a
duplicate if "webmaster" forwards it to this list. :{
Hi, there.
Thanks for any help that can be offered. I've been working with Python for
a year or more now, but only doing simple extending in C/C++. I'm now
attempting some embedding and several questions have come...
|
by: Victor Fees |
last post by:
I have an XML string in a database that I would like to display using XSLT.
All of that works like a champ, but I can't figure out how to embed the XML
inside an ASPX page.
For example, I have an ASPX page with a Header User Control and a Footer
User Control. I'd like to put the transformed XML right in the middle. It
seems like this is...
|
by: Matt |
last post by:
I'm working on a plug-in for an application called DesktopSideBar for
Windows. It emulates to some degree the Longhorn sidebar. The SDK for
DesktopSideBar supports .NET plug-in development through COM Interop
and a provided reference DLL. In the SDK are two included samples...
One, called RecycleBin is written entirely in unmanaged C++ as a...
|
by: hq4000 |
last post by:
Given AStyleSheet.xsl :
<AStyleSheet>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.mytest.mytest2.mytest3.com"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:element name="Test">it works</xsl:element>
</xsl:template>
|
by: Fozzie |
last post by:
Hi,
I have a problem which is quite circular, and hopefully either someone
has encountered something similar or has a reason why this will not
work.
We have a COM library providing mathematics to various systems, most
functions are hard-coded but we want to embed a scripting language to
allow arbitrary functions to be used in the numeric...
| |
by: Andrew Backer |
last post by:
Is it possible to embed a newline constant in a string in the same way
as c#? I really don't want to do something like this:
++ String.Format("Line 1 : {0} " & vbcrlf & " Line 2 : {1}", o, t)
when I should be able to do
++ String.Format("Line 1 : {0}\nLine2 : {2}", o, t)
Not the best example, I am sure, but it does get worse in many cases?...
|
by: Jim Hill |
last post by:
Well, I've found about a hundred thousand web pages where people have
had the same problem I have but nary a page with a solution that works
for me.
I want to do a simple embed, so I've followed the example in the
Extending and Embedding documentation:
In the .c file,
#include <Python.h>
|
by: anonymisiert85 |
last post by:
At the moment i can run python-string-code from C (MinGW, WinXP)
But how can i register a C-function in python-RUNTIME and call this C
function from python - without wrapper dll's or libs???
STEPS:
initialize python
regsiter foo() ########### don't know how to do this
run python-script "c=foo(a,b)"
|
by: John Grandy |
last post by:
I am not having success embedding carriage return and line feed characters
into a string and displaying them with an ASP.NET label. Is anyone getting
either of the following to work ?
StringBuilder message = new StringBuilder();
message.Append("Line 1");
message.Append("\r\n");
message.Append("Line 2");
Label.Text = message.ToString();
|
by: Benke |
last post by:
Hello, I'm quite new to Python and embedding python in c++. I'm trying to write a function that i can use to call a python function. It should take 3 arguments, the name of the python file, the python function name and a std:vector with arguments for the python function. This is my code:
int main()
{
string arg1 = "runme"; //name of python...
|
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...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
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. ...
|
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...
|
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...
|
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...
|
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...
| |
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
| |